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.ContentHandler
A SAX content handler that builds a VinciFrame corresponding to the SAX events received.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuffer
mCharContentBuffer
The m char content buffer.private org.xml.sax.Attributes
mCurrentFrameAttrs
The m current frame attrs.private java.lang.String
mCurrentFrameName
The m current frame name.private java.util.Stack
mOpenFrames
The m open frames.
-
Constructor Summary
Constructors Constructor Description SaxVinciFrameBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
Characters.void
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName)
End element.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.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.void
setParentFrame(AFrame aParentFrame)
Sets the parent frame, to which frames built by the object will be added.void
startDocument()
Start document.void
startElement(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.SAXException
Start document.- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in 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.SAXException
Called for each start tag encountered.- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in 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:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in 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:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in 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.
-
-