Bug fixes + rework of BasicSupport
[gofetch.git] / src / be / nikiroo / gofetch / support / ElementProcessor.java
diff --git a/src/be/nikiroo/gofetch/support/ElementProcessor.java b/src/be/nikiroo/gofetch/support/ElementProcessor.java
new file mode 100644 (file)
index 0000000..69e291d
--- /dev/null
@@ -0,0 +1,67 @@
+package be.nikiroo.gofetch.support;
+
+import org.jsoup.nodes.Node;
+
+/**
+ * Used to process an element into lines.
+ * 
+ * @author niki
+ */
+interface ElementProcessor {
+       /**
+        * Detect if this node is a quote and should be trated as such.
+        * 
+        * @param node
+        *            the node to check
+        * @return TRUE if it is
+        */
+       public boolean detectQuote(Node node);
+
+       /**
+        * Process text content (will be called on each text element, allowing you
+        * to modify it if needed).
+        * 
+        * @param text
+        *            the text to process
+        * 
+        * @return the resulting text
+        */
+       public String processText(String text);
+
+       /**
+        * Ignore this node.
+        * 
+        * @param node
+        *            the node to ignore
+        * @return TRUE if it has to be ignored
+        */
+       public boolean ignoreNode(Node node);
+
+       /**
+        * Manually process this node (and return the manual processing value) if so
+        * desired.
+        * <p>
+        * If the node is manually processed, it and its children will not be
+        * automatically processed.
+        * 
+        * @param node
+        *            the node to optionally process
+        * 
+        * @return NULL if not processed (will thus be automatically processed as
+        *         usual), a {@link String} (may be empty) if we process it manually
+        *         -- the given {@link String} will be used instead of the usual
+        *         automatic processing if not NULL
+        */
+       public String manualProcessing(Node node);
+
+       /**
+        * This {@link Node} is a subtitle and should be treated as such
+        * (highlighted).
+        * 
+        * @param node
+        *            the node to check
+        * 
+        * @return NULL if it is not a subtitle, the subtitle to use if it is
+        */
+       public String isSubtitle(Node node);
+}
\ No newline at end of file