Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added new entry class for embed tags

Michael Peter Christen09484955dc5e
diff --git a/source/net/yacy/document/parser/html/EmbedEntry.java b/source/net/yacy/document/parser/html/EmbedEntry.java
new file mode 100644
index 000000000..f64d02427
--- /dev/null
+++ b/source/net/yacy/document/parser/html/EmbedEntry.java
@@ -0,0 +1,79 @@
+/**
+ * EmbedEntry
+ * Copyright 2012 by Michael Peter Christen, [email protected], Frankfurt am Main, Germany
+ * First released 27.04.2012 at http://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.yacy.document.parser.html;
+
+import net.yacy.cora.document.MultiProtocolURI;
+
+public class EmbedEntry {
+
+ private final MultiProtocolURI url;
+ private final int width, height;
+ private final String type, pluginspage;
+
+ public EmbedEntry(final MultiProtocolURI url, int width, int height, String type, String pluginspage) {
+ this.url = url;
+ this.width = width;
+ this.height = height;
+ this.type = type;
+ this.pluginspage = pluginspage;
+ }
+
+ public MultiProtocolURI getUrl() {
+ return this.url;
+ }
+
+ public final int getWidth() {
+ return this.width;
+ }
+
+ public final int getHeight() {
+ return this.height;
+ }
+
+ public final String getType() {
+ return this.type;
+ }
+
+ public final String getPluginspage() {
+ return this.pluginspage;
+ }
+
+ @Override
+ public String toString() {
+ return "<embed url=\"" + this.url.toNormalform(false, false, false, false) + "\"" +
+ (this.type != null && this.type.length() > 0 ? " type=\"" + this.type + "\"" : "") +
+ (this.pluginspage != null && this.pluginspage.length() > 0 ? " pluginspage=\"" + this.pluginspage + "\"" : "") +
+ (this.width >= 0 ? " width=\"" + this.width + "\"" : "") +
+ (this.height >= 0 ? " height=\"" + this.height + "\"" : "") +
+ ">";
+ }
+
+ @Override
+ public int hashCode() {
+ // if htmlFilterImageEntry elements are stored in a TreeSet, the biggest images shall be listed first
+ // this hash method therefore tries to compute a 'perfect hash' based on the size of the images
+ // unfortunately it can not be ensured that all images get different hashes, but this should appear
+ // only in very rare cases
+ if (this.width < 0 || this.height < 0)
+ return /*0x7FFF0000 |*/ (this.url.hashCode() & 0xFFFF);
+ return ((0x7FFF - (((this.width * this.height) >> 9) & 0x7FFF)) << 16) | (this.url.hashCode() & 0xFFFF);
+ }
+}