Class SaxVinciFrameBuilder
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.uima.adapter.vinci.util.SaxVinciFrameBuilder
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
UimaSaxVinciFrameBuilder
public class SaxVinciFrameBuilder extends org.xml.sax.helpers.DefaultHandler implements org.xml.sax.ContentHandlerA SAX content handler that builds a VinciFrame corresponding to the SAX events received.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuffermCharContentBufferThe m char content buffer.private org.xml.sax.AttributesmCurrentFrameAttrsThe m current frame attrs.private java.lang.StringmCurrentFrameNameThe m current frame name.private java.util.StackmOpenFramesThe m open frames.
-
Constructor Summary
Constructors Constructor Description SaxVinciFrameBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Characters.voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName)End element.protected java.lang.StringgetLeafContent(java.lang.String aFrameName, org.xml.sax.Attributes aAttributes, java.lang.StringBuffer aContentBuf)Gets the content to be included in a FrameLeaf.protected java.lang.StringgetName(java.lang.String s1, java.lang.String s2)If the first String parameter is nonempty, return it, else return the second string parameter.voidsetParentFrame(AFrame aParentFrame)Sets the parent frame, to which frames built by the object will be added.voidstartDocument()Start document.voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attributes)Called for each start tag encountered.-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
mOpenFrames
private java.util.Stack mOpenFrames
The m open frames.
-
mCurrentFrameName
private java.lang.String mCurrentFrameName
The m current frame name.
-
mCurrentFrameAttrs
private org.xml.sax.Attributes mCurrentFrameAttrs
The m current frame attrs.
-
mCharContentBuffer
private java.lang.StringBuffer mCharContentBuffer
The m char content buffer.
-
-
Method Detail
-
setParentFrame
public void setParentFrame(AFrame aParentFrame)
Sets the parent frame, to which frames built by the object will be added. This MUST be called before parsing a document.- Parameters:
aParentFrame- the parent frame
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionStart document.- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- the SAX exception- See Also:
ContentHandler.startDocument()
-
startElement
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXExceptionCalled for each start tag encountered.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- Required if the namespaces property is true.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.qualifiedName- The qualified name (with prefix), or the empty string if qualified names are not available.attributes- The specified or defaulted attributes.- Throws:
org.xml.sax.SAXException- the SAX exception
-
characters
public void characters(char[] ch, int start, int length)Characters.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ch- the chstart- the startlength- the length- See Also:
ContentHandler.characters(char[],int,int)
-
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName)End element.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- the namespace URIlocalName- the local namequalifiedName- the qualified name- See Also:
ContentHandler.endElement(String,String,String)
-
getLeafContent
protected java.lang.String getLeafContent(java.lang.String aFrameName, org.xml.sax.Attributes aAttributes, java.lang.StringBuffer aContentBuf)Gets the content to be included in a FrameLeaf. This method just returns the contents of the provided StringBuffer, but subclasses can override to provide specialized content.- Parameters:
aFrameName- name of the FrameLeafaAttributes- attributes of FrameLeafaContentBuf- StringBuffer containing the character data obtained from the SAX parser- Returns:
- the data to be included in the Vinci FrameLeaf
-
getName
protected java.lang.String getName(java.lang.String s1, java.lang.String s2)If the first String parameter is nonempty, return it, else return the second string parameter.- Parameters:
s1- The string to be tested.s2- The alternate String.- Returns:
- s1 if it isn't empty, else s2.
-
-