|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.xwiki.xml.ExtractHandler
public class ExtractHandler
Extracts a well-formed XML fragment by listening to SAX events. The result has the following semantic:
xmlInput.dropAllTags().substring(start, length).unDropAssociatedTags()
So basically we would create an instance like new ExtractHandler(0, 400) in order to obtain an XML
fragment with its inner text length of at most 400 characters, starting at position (character) 0 in the source
(input) XML's inner text. The ExtractHandler is used in feed plug-in to obtain a preview of an XML (HTML, to be more
specific). Another use case could be to paginate an XML source (keeping pages well-formed).
As an example, the result of applying an ExtractHandler(3, 13) to:
<p>click <a href="realyLongURL" title="Here">here</a> to view the result</p>
is:
<p>ck <a href="realyLongURL" title="Here">here</a> to</p>
| Constructor Summary | |
|---|---|
ExtractHandler(int start,
int length)
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
|
void |
endDocument()
|
void |
endElement(String namespaceURI,
String localName,
String qName)
|
String |
getResult()
|
boolean |
isFinished()
|
void |
startDocument()
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
|
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExtractHandler(int start,
int length)
throws SAXException
start - The character index from where to start the extraction.length - The number of plain text characters to extract.
SAXException - if start is less than zero or length is less than or equal to zero.| Method Detail |
|---|
public String getResult()
public boolean isFinished()
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerSAXExceptionDefaultHandler.startDocument()
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerSAXExceptionDefaultHandler.startElement(String, String, String, Attributes)
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerSAXExceptionDefaultHandler.characters(char[], int, int)
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerSAXExceptionDefaultHandler.endElement(String, String, String)
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerSAXExceptionDefaultHandler.endDocument()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||