From b96150ff4c48c55a027dd68a680b2ec112108891 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 9 Mar 2009 17:57:24 +0100 Subject: [PATCH] Add interfaces for content parser. --- src/net/pterodactylus/arachne/parser/Parser.java | 27 +++++++++++++++ .../arachne/parser/ParserListener.java | 39 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/net/pterodactylus/arachne/parser/Parser.java create mode 100644 src/net/pterodactylus/arachne/parser/ParserListener.java diff --git a/src/net/pterodactylus/arachne/parser/Parser.java b/src/net/pterodactylus/arachne/parser/Parser.java new file mode 100644 index 0000000..28d8706 --- /dev/null +++ b/src/net/pterodactylus/arachne/parser/Parser.java @@ -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 + */ +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 index 0000000..de81233 --- /dev/null +++ b/src/net/pterodactylus/arachne/parser/ParserListener.java @@ -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 + */ +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); + +} -- 2.7.4