[Yanel-commits] rev 44041 -
public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search
michi at wyona.com
michi at wyona.com
Thu Aug 6 22:35:09 CEST 2009
Author: michi
Date: 2009-08-06 22:35:09 +0200 (Thu, 06 Aug 2009)
New Revision: 44041
Added:
public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBean.java
public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBeanContentHandler.java
Log:
utility classes added
Added: public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBean.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBean.java (rev 0)
+++ public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBean.java 2009-08-06 20:35:09 UTC (rev 44041)
@@ -0,0 +1,26 @@
+/**
+ * Licensed to Wyona
+ */
+package org.wyona.yanel.impl.resources.search;
+
+/**
+ *
+ */
+public class XHTMLBean {
+
+ private String title;
+
+ /**
+ *
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * /html/head/title
+ */
+ public String getTitle() {
+ return title;
+ }
+}
Added: public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBeanContentHandler.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBeanContentHandler.java (rev 0)
+++ public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/XHTMLBeanContentHandler.java 2009-08-06 20:35:09 UTC (rev 44041)
@@ -0,0 +1,98 @@
+/**
+ * Licensed to Wyona
+ */
+package org.wyona.yanel.impl.resources.search;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Content handler for collecting the various typical XHTML content which has been generated by some parser implementation
+ */
+public class XHTMLBeanContentHandler implements ContentHandler {
+
+ private static Logger log = Logger.getLogger(XHTMLBeanContentHandler.class);
+
+ private XHTMLBean xhtmlBean;
+ private boolean insideTitle = false;
+
+ /**
+ * @param xhtmlBean XHTMLBean to set various content
+ */
+ public XHTMLBeanContentHandler(XHTMLBean xhtmlBean) {
+ this.xhtmlBean = xhtmlBean;
+ }
+
+ public void setDocumentLocator (Locator locator) {
+ log.warn("Hello from setDocumentLocator()!");
+ }
+
+ public void startDocument ()
+ throws SAXException {
+ log.warn("Hello from startDocument()!");
+ }
+
+ public void endDocument()
+ throws SAXException {
+ log.warn("Hello from endDocument()!");
+ }
+
+ public void startPrefixMapping (String prefix, String uri)
+ throws SAXException {
+ log.warn("Hello from startPrefixMapping()!");
+ }
+
+ public void endPrefixMapping (String prefix)
+ throws SAXException {
+ log.warn("Hello from endPrefixMapping()!");
+ }
+
+ /**
+ *
+ */
+ public void startElement (String uri, String localName, String qName, Attributes atts) throws SAXException {
+ log.warn("Local name: " + localName);
+ log.warn("qName: " + qName);
+ log.warn("uri: " + uri);
+ if (localName.equals("title")) {
+ insideTitle = true;
+ }
+ }
+
+ /**
+ *
+ */
+ public void endElement (String uri, String localName, String qName) throws SAXException {
+ log.warn("Local name: " + localName);
+ if (localName.equals("title")) {
+ insideTitle = false;
+ }
+ }
+
+ /**
+ *
+ */
+ public void characters (char ch[], int start, int length) throws SAXException {
+ if (insideTitle) xhtmlBean.setTitle(new String(ch));
+ log.warn("" + ch);
+ }
+
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException {
+ log.warn("Hello from ignorableWhitespace()!");
+ }
+
+ public void processingInstruction (String target, String data)
+ throws SAXException {
+ log.warn("Hello from processingInstruction()!");
+ }
+
+ public void skippedEntity (String name)
+ throws SAXException {
+ log.warn("Hello from skippedEntity()!");
+ }
+}
More information about the Yanel-commits
mailing list