Add interfaces for content parser.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 9 Mar 2009 16:57:24 +0000 (17:57 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 9 Mar 2009 16:57:24 +0000 (17:57 +0100)
src/net/pterodactylus/arachne/parser/Parser.java [new file with mode: 0644]
src/net/pterodactylus/arachne/parser/ParserListener.java [new file with mode: 0644]

diff --git a/src/net/pterodactylus/arachne/parser/Parser.java b/src/net/pterodactylus/arachne/parser/Parser.java
new file mode 100644 (file)
index 0000000..28d8706
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * © 2009 David ‘Bombe’ Roden
+ */
+package net.pterodactylus.arachne.parser;
+
+import java.io.InputStream;
+
+/**
+ * Interface for a parser. A parser understands the format it should parse and
+ * can generate events based on the parsed content.
+ *
+ * @see ParserListener
+ * @author David ‘Bombe’ Roden <bombe@pterodactylus.net>
+ */
+public interface Parser {
+
+       /**
+        * Parses the given input stream and sends events to the given listener.
+        *
+        * @param parserListener
+        *            The listener to send events to
+        * @param inputStream
+        *            The input stream to parse
+        */
+       public void parse(ParserListener parserListener, InputStream inputStream);
+
+}
diff --git a/src/net/pterodactylus/arachne/parser/ParserListener.java b/src/net/pterodactylus/arachne/parser/ParserListener.java
new file mode 100644 (file)
index 0000000..de81233
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * © 2009 David ‘Bombe’ Roden
+ */
+package net.pterodactylus.arachne.parser;
+
+import java.io.InputStream;
+import java.util.EventListener;
+
+/**
+ * Interface for objects that need to be notified when a {@link Parser} finds
+ * indexable content.
+ *
+ * @author David ‘Bombe’ Roden <bombe@pterodactylus.net>
+ */
+public interface ParserListener extends EventListener {
+
+       /**
+        * Notifies a listener that a title was identified in the parsed content.
+        *
+        * @param inputStream
+        *            The parsed input stream
+        * @param title
+        *            The title that was found
+        */
+       public void parsedTitle(InputStream inputStream, String title);
+
+       /**
+        * Notifies a listener that a link to a (maybe) different document was
+        * identified in the parsed content. The link may be in absolute or relative
+        * (to the URL of the streamed content) form.
+        *
+        * @param inputStream
+        *            The parsed input stream
+        * @param link
+        *            The identified link
+        */
+       public void parsedLink(InputStream inputStream, String link);
+
+}