Class SAXUnmarshallerHandlerImpl
- java.lang.Object
-
- com.sun.identity.wsfederation.jaxb.entityconfig.impl.runtime.SAXUnmarshallerHandlerImpl
-
- All Implemented Interfaces:
SAXUnmarshallerHandler,UnmarshallingContext,UnmarshallerHandler,NamespaceContext,ContentHandler
public class SAXUnmarshallerHandlerImpl extends Object implements SAXUnmarshallerHandler, UnmarshallingContext
Implementation ofUnmarshallerHandler. This object converts SAX events into unmarshaller events and cooridnates the entire unmarshalling process.- Author:
- Kohsuke KAWAGUCHI
-
-
Constructor Summary
Constructors Constructor Description SAXUnmarshallerHandlerImpl(UnmarshallerImpl _parent, GrammarInfo _gi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPatcher(Runnable job)Adds a job that will be executed at the last of the unmarshalling.StringaddToIdTable(String id)Adds the object which is currently being unmarshalled to the ID table.voidcharacters(char[] buf, int start, int len)voidconsumeAttribute(int idx)Fires an attribute event for the specified attribute, and marks the attribute as "used".protected voidconsumeText(String str, boolean ignorable)StringeatAttribute(int idx)Marks the attribute as "used" and return the value of the attribute.voidendDocument()voidendElement(String uri, String local, String qname)voidendPrefixMapping(String prefix)String[]getAllDeclaredPrefixes()Returns a list of all in-scope prefixes.intgetAttribute(String uri, String local)Gets the index of the attribute with the specified name.StringgetBaseUri()UnmarshallingEventHandlergetCurrentHandler()Gets the current handler.GrammarInfogetGrammarInfo()Obtains a reference to the current grammar info.LocatorgetLocator()Gets the current source location information.StringgetNamespaceURI(String prefix)String[]getNewlyDeclaredPrefixes()Returns a list of prefixes newly declared on this element.ObjectgetObjectFromId(String id)Looks up the ID table and gets associated object.StringgetPrefix(String uri)IteratorgetPrefixes(String uri)ObjectgetResult()com.sun.xml.bind.unmarshaller.TracergetTracer()Gets a tracer object.AttributesgetUnconsumedAttributes()Gets all the unconsumed attributes.voidhandleEvent(ValidationEvent event, boolean canRecover)Reports an error to the user, and asks if s/he wants to recover.voidignorableWhitespace(char[] buf, int start, int len)booleanisNotation(String s)booleanisUnparsedEntity(String s)voidpopAttributes()Discards the previously stored attribute set.voidpopContentHandler()Pops a content handler from the stack and registers it as the current content handler.voidprocessingInstruction(String target, String data)voidpushAttributes(Attributes atts, boolean collectTextFlag)Stores a new attribute set.voidpushContentHandler(UnmarshallingEventHandler handler, int memento)Pushes the current content handler into the stack and registers the newly specified content handler so that it can receive SAX events.StringresolveNamespacePrefix(String prefix)voidsetDocumentLocator(Locator loc)voidsetTracer(com.sun.xml.bind.unmarshaller.Tracer t)voidskippedEntity(String name)voidstartDocument()voidstartElement(String uri, String local, String qname, Attributes atts)voidstartPrefixMapping(String prefix, String uri)
-
-
-
Constructor Detail
-
SAXUnmarshallerHandlerImpl
public SAXUnmarshallerHandlerImpl(UnmarshallerImpl _parent, GrammarInfo _gi)
-
-
Method Detail
-
getGrammarInfo
public GrammarInfo getGrammarInfo()
Description copied from interface:UnmarshallingContextObtains a reference to the current grammar info.- Specified by:
getGrammarInfoin interfaceUnmarshallingContext
-
startDocument
public void startDocument() throws SAXException- Specified by:
startDocumentin interfaceContentHandler- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException- Specified by:
endDocumentin interfaceContentHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Throws:
SAXException
-
endElement
public final void endElement(String uri, String local, String qname) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Throws:
SAXException
-
getResult
public Object getResult() throws UnmarshalException
- Specified by:
getResultin interfaceUnmarshallerHandler- Throws:
UnmarshalException
-
pushContentHandler
public void pushContentHandler(UnmarshallingEventHandler handler, int memento)
Description copied from interface:UnmarshallingContextPushes the current content handler into the stack and registers the newly specified content handler so that it can receive SAX events.- Specified by:
pushContentHandlerin interfaceUnmarshallingContextmemento- When this newly specified handler will be removed from the stack, the leaveChild event will be fired to the parent handler with this memento.
-
popContentHandler
public void popContentHandler() throws SAXExceptionDescription copied from interface:UnmarshallingContextPops a content handler from the stack and registers it as the current content handler.This method will also fire the leaveChild event with the associated memento.
- Specified by:
popContentHandlerin interfaceUnmarshallingContext- Throws:
SAXException
-
getCurrentHandler
public UnmarshallingEventHandler getCurrentHandler()
Description copied from interface:UnmarshallingContextGets the current handler.- Specified by:
getCurrentHandlerin interfaceUnmarshallingContext
-
consumeText
protected void consumeText(String str, boolean ignorable) throws SAXException
- Throws:
SAXException
-
characters
public final void characters(char[] buf, int start, int len)- Specified by:
charactersin interfaceContentHandler
-
ignorableWhitespace
public final void ignorableWhitespace(char[] buf, int start, int len)- Specified by:
ignorableWhitespacein interfaceContentHandler
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri)
- Specified by:
startPrefixMappingin interfaceContentHandler
-
endPrefixMapping
public void endPrefixMapping(String prefix)
- Specified by:
endPrefixMappingin interfaceContentHandler
-
resolveNamespacePrefix
public String resolveNamespacePrefix(String prefix)
- Specified by:
resolveNamespacePrefixin interfaceUnmarshallingContext
-
getNewlyDeclaredPrefixes
public String[] getNewlyDeclaredPrefixes()
Description copied from interface:UnmarshallingContextReturns a list of prefixes newly declared on this element. This method has to be called after theUnmarshallingContext.pushAttributes(org.xml.sax.Attributes, boolean)method is called.- Specified by:
getNewlyDeclaredPrefixesin interfaceUnmarshallingContext- Returns:
- A possible zero-length array of prefixes. The default prefix is represented by the empty string.
-
getAllDeclaredPrefixes
public String[] getAllDeclaredPrefixes()
Description copied from interface:UnmarshallingContextReturns a list of all in-scope prefixes.- Specified by:
getAllDeclaredPrefixesin interfaceUnmarshallingContext- Returns:
- A possible zero-length array of prefixes. The default prefix is represented by the empty string.
-
getPrefixes
public Iterator getPrefixes(String uri)
- Specified by:
getPrefixesin interfaceNamespaceContext
-
getPrefix
public String getPrefix(String uri)
- Specified by:
getPrefixin interfaceNamespaceContext
-
getNamespaceURI
public String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURIin interfaceNamespaceContext
-
pushAttributes
public void pushAttributes(Attributes atts, boolean collectTextFlag)
Description copied from interface:UnmarshallingContextStores a new attribute set. This method should be called by the generated code when it "eats" an enterElement event.- Specified by:
pushAttributesin interfaceUnmarshallingContextcollectTextFlag- false if the context doesn't need to fire text events for texts inside this element. True otherwise.
-
popAttributes
public void popAttributes()
Description copied from interface:UnmarshallingContextDiscards the previously stored attribute set. This method should be called by the generated code when it "eats" a leaveElement event.- Specified by:
popAttributesin interfaceUnmarshallingContext
-
getUnconsumedAttributes
public Attributes getUnconsumedAttributes()
Description copied from interface:UnmarshallingContextGets all the unconsumed attributes. If you need to find attributes based on more complex filter, you need to use this method.- Specified by:
getUnconsumedAttributesin interfaceUnmarshallingContext
-
getAttribute
public int getAttribute(String uri, String local)
Description copied from interface:UnmarshallingContextGets the index of the attribute with the specified name. This is usually faster when you only need to test with a simple name.- Specified by:
getAttributein interfaceUnmarshallingContext- Parameters:
uri- ,local has to be interned.- Returns:
- -1 if not found.
-
consumeAttribute
public void consumeAttribute(int idx) throws SAXExceptionDescription copied from interface:UnmarshallingContextFires an attribute event for the specified attribute, and marks the attribute as "used".- Specified by:
consumeAttributein interfaceUnmarshallingContext- Throws:
SAXException
-
eatAttribute
public String eatAttribute(int idx) throws SAXException
Description copied from interface:UnmarshallingContextMarks the attribute as "used" and return the value of the attribute.- Specified by:
eatAttributein interfaceUnmarshallingContext- Throws:
SAXException
-
addPatcher
public void addPatcher(Runnable job)
Description copied from interface:UnmarshallingContextAdds a job that will be executed at the last of the unmarshalling. This method is used to support ID/IDREF feature, but it can be used for other purposes as well.- Specified by:
addPatcherin interfaceUnmarshallingContext- Parameters:
job- The run method of this object is called.
-
addToIdTable
public String addToIdTable(String id)
Description copied from interface:UnmarshallingContextAdds the object which is currently being unmarshalled to the ID table.- Specified by:
addToIdTablein interfaceUnmarshallingContext- Returns:
- Returns the value passed as the parameter. This is a hack, but this makes it easier for ID transducer to do its job.
-
getObjectFromId
public Object getObjectFromId(String id)
Description copied from interface:UnmarshallingContextLooks up the ID table and gets associated object.- Specified by:
getObjectFromIdin interfaceUnmarshallingContext- Returns:
- If there is no object associated with the given id, this method returns null.
-
skippedEntity
public void skippedEntity(String name)
- Specified by:
skippedEntityin interfaceContentHandler
-
processingInstruction
public void processingInstruction(String target, String data)
- Specified by:
processingInstructionin interfaceContentHandler
-
setDocumentLocator
public void setDocumentLocator(Locator loc)
- Specified by:
setDocumentLocatorin interfaceContentHandler
-
getLocator
public Locator getLocator()
Description copied from interface:UnmarshallingContextGets the current source location information.- Specified by:
getLocatorin interfaceUnmarshallingContext
-
handleEvent
public void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException
Description copied from interface:SAXUnmarshallerHandlerReports an error to the user, and asks if s/he wants to recover. If the canRecover flag is false, regardless of the client instruction, an exception will be thrown. Only if the flag is true and the user wants to recover from an error, the method returns normally. The thrown exception will be catched by the unmarshaller.- Specified by:
handleEventin interfaceSAXUnmarshallerHandler- Specified by:
handleEventin interfaceUnmarshallingContext- Throws:
SAXException
-
getBaseUri
public String getBaseUri()
- Specified by:
getBaseUriin interfaceUnmarshallingContext
-
isUnparsedEntity
public boolean isUnparsedEntity(String s)
- Specified by:
isUnparsedEntityin interfaceUnmarshallingContext
-
isNotation
public boolean isNotation(String s)
- Specified by:
isNotationin interfaceUnmarshallingContext
-
setTracer
public void setTracer(com.sun.xml.bind.unmarshaller.Tracer t)
-
getTracer
public com.sun.xml.bind.unmarshaller.Tracer getTracer()
Description copied from interface:UnmarshallingContextGets a tracer object. Tracer can be used to trace the unmarshalling behavior. Note that to debug the unmarshalling process, you have to configure XJC so that it will emit trace codes in the unmarshaller.- Specified by:
getTracerin interfaceUnmarshallingContext
-
-