Interface UnmarshallingContext
-
- All Superinterfaces:
NamespaceContext
- All Known Implementing Classes:
SAXUnmarshallerHandlerImpl
public interface UnmarshallingContext extends NamespaceContext
Methods exposed by the unmarshalling coordinator object to the generated code. This interface will be implemented by the coordinator, which converts whatever events (e.g., SAX) into unmarshalling events.Errors detected by the AbstractUnmarshallingEventHandlerImpl-derived classes should be either thrown as
UnrepotedExceptionor reported through the handleEvent method of this interface.- Author:
- Kohsuke KAWAGUCHI
-
-
Method Summary
All Methods Instance Methods Abstract 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.voidconsumeAttribute(int idx)Fires an attribute event for the specified attribute, and marks the attribute as "used".StringeatAttribute(int idx)Marks the attribute as "used" and return the value of the attribute.String[]getAllDeclaredPrefixes()Returns a list of all in-scope prefixes.intgetAttribute(String uri, String name)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.String[]getNewlyDeclaredPrefixes()Returns a list of prefixes newly declared on this element.ObjectgetObjectFromId(String id)Looks up the ID table and gets associated object.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.booleanisNotation(String notationName)booleanisUnparsedEntity(String entityName)voidpopAttributes()Discards the previously stored attribute set.voidpopContentHandler()Pops a content handler from the stack and registers it as the current content handler.voidpushAttributes(Attributes atts, boolean collectText)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)-
Methods inherited from interface javax.xml.namespace.NamespaceContext
getNamespaceURI, getPrefix, getPrefixes
-
-
-
-
Method Detail
-
getGrammarInfo
GrammarInfo getGrammarInfo()
Obtains a reference to the current grammar info.
-
pushContentHandler
void pushContentHandler(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.- Parameters:
memento- 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
void popContentHandler() throws SAXExceptionPops 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.
- Throws:
SAXException
-
getCurrentHandler
UnmarshallingEventHandler getCurrentHandler()
Gets the current handler.
-
getNewlyDeclaredPrefixes
String[] getNewlyDeclaredPrefixes()
Returns a list of prefixes newly declared on this element. This method has to be called after thepushAttributes(org.xml.sax.Attributes, boolean)method is called.- Returns:
- A possible zero-length array of prefixes. The default prefix is represented by the empty string.
-
getAllDeclaredPrefixes
String[] getAllDeclaredPrefixes()
Returns a list of all in-scope prefixes.- Returns:
- A possible zero-length array of prefixes. The default prefix is represented by the empty string.
-
pushAttributes
void pushAttributes(Attributes atts, boolean collectText)
Stores a new attribute set. This method should be called by the generated code when it "eats" an enterElement event.- Parameters:
collectText- false if the context doesn't need to fire text events for texts inside this element. True otherwise.
-
popAttributes
void popAttributes()
Discards the previously stored attribute set. This method should be called by the generated code when it "eats" a leaveElement event.
-
getAttribute
int getAttribute(String uri, String name)
Gets the index of the attribute with the specified name. This is usually faster when you only need to test with a simple name.- Returns:
- -1 if not found.
-
getUnconsumedAttributes
Attributes getUnconsumedAttributes()
Gets all the unconsumed attributes. If you need to find attributes based on more complex filter, you need to use this method.
-
consumeAttribute
void consumeAttribute(int idx) throws SAXExceptionFires an attribute event for the specified attribute, and marks the attribute as "used".- Throws:
SAXException
-
eatAttribute
String eatAttribute(int idx) throws SAXException
Marks the attribute as "used" and return the value of the attribute.- Throws:
SAXException
-
addPatcher
void addPatcher(Runnable job)
Adds 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.- Parameters:
job- The run method of this object is called.
-
addToIdTable
String addToIdTable(String id)
Adds the object which is currently being unmarshalled to the ID table.- 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
Object getObjectFromId(String id)
Looks up the ID table and gets associated object.- Returns:
- If there is no object associated with the given id, this method returns null.
-
getLocator
Locator getLocator()
Gets the current source location information.
-
handleEvent
void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException
Reports 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.- Throws:
SAXException
-
getBaseUri
String getBaseUri()
-
isUnparsedEntity
boolean isUnparsedEntity(String entityName)
-
isNotation
boolean isNotation(String notationName)
-
getTracer
com.sun.xml.bind.unmarshaller.Tracer getTracer()
Gets 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.
-
-