edu.ksi.virtualclassroom.mappers.jaxb.xmlwrapper.impl.runtime
Interface UnmarshallingContext

All Superinterfaces:
javax.xml.namespace.NamespaceContext
All Known Implementing Classes:
SAXUnmarshallerHandlerImpl

public interface UnmarshallingContext
extends javax.xml.namespace.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 UnrepotedException or reported through the handleEvent method of this interface.

Version:
$Revision$
Author:
Kohsuke KAWAGUCHI

Method Summary
 void addPatcher(java.lang.Runnable job)
          Adds a job that will be executed at the last of the unmarshalling.
 java.lang.String addToIdTable(java.lang.String id)
          Adds the object which is currently being unmarshalled to the ID table.
 void consumeAttribute(int idx)
          Fires an attribute event for the specified attribute, and marks the attribute as "used".
 java.lang.String eatAttribute(int idx)
          Marks the attribute as "used" and return the value of the attribute.
 java.lang.String[] getAllDeclaredPrefixes()
          Returns a list of all in-scope prefixes.
 int getAttribute(java.lang.String uri, java.lang.String name)
          Gets the index of the attribute with the specified name.
 java.lang.String getBaseUri()
          Method getBaseUri
 UnmarshallingEventHandler getCurrentHandler()
          Gets the current handler.
 GrammarInfo getGrammarInfo()
          Obtains a reference to the current grammar info.
 org.xml.sax.Locator getLocator()
          Gets the current source location information.
 java.lang.String[] getNewlyDeclaredPrefixes()
          Returns a list of prefixes newly declared on this element.
 java.lang.Object getObjectFromId(java.lang.String id)
          Looks up the ID table and gets associated object.
 com.sun.xml.bind.unmarshaller.Tracer getTracer()
          Gets a tracer object.
 org.xml.sax.Attributes getUnconsumedAttributes()
          Gets all the unconsumed attributes.
 void handleEvent(javax.xml.bind.ValidationEvent event, boolean canRecover)
          Reports an error to the user, and asks if s/he wants to recover.
 boolean isNotation(java.lang.String notationName)
          Method isNotation
 boolean isUnparsedEntity(java.lang.String entityName)
          Method isUnparsedEntity
 void popAttributes()
          Discards the previously stored attribute set.
 void popContentHandler()
          Pops a content handler from the stack and registers it as the current content handler.
 void pushAttributes(org.xml.sax.Attributes atts, boolean collectText)
          Stores a new attribute set.
 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.
 java.lang.String resolveNamespacePrefix(java.lang.String prefix)
          Method resolveNamespacePrefix
 
Methods inherited from interface javax.xml.namespace.NamespaceContext
getNamespaceURI, getPrefix, getPrefixes
 

Method Detail

getGrammarInfo

public GrammarInfo getGrammarInfo()
Obtains a reference to the current grammar info. * @return GrammarInfo

Returns:
GrammarInfo

pushContentHandler

public 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:
handler - UnmarshallingEventHandler
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

public void popContentHandler()
                       throws org.xml.sax.SAXException
Pops 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:
org.xml.sax.SAXException

getCurrentHandler

public UnmarshallingEventHandler getCurrentHandler()
Gets the current handler.

Returns:
UnmarshallingEventHandler

getNewlyDeclaredPrefixes

public java.lang.String[] getNewlyDeclaredPrefixes()
Returns a list of prefixes newly declared on this element. This method has to be called after the pushAttributes(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

public java.lang.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

public void pushAttributes(org.xml.sax.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:
atts - Attributes
collectText - false if the context doesn't need to fire text events for texts inside this element. True otherwise.

popAttributes

public void popAttributes()
Discards the previously stored attribute set. This method should be called by the generated code when it "eats" a leaveElement event.


getAttribute

public int getAttribute(java.lang.String uri,
                        java.lang.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.

Parameters:
uri - String
name - String
Returns:
-1 if not found.

getUnconsumedAttributes

public org.xml.sax.Attributes getUnconsumedAttributes()
Gets all the unconsumed attributes. If you need to find attributes based on more complex filter, you need to use this method.

Returns:
Attributes

consumeAttribute

public void consumeAttribute(int idx)
                      throws org.xml.sax.SAXException
Fires an attribute event for the specified attribute, and marks the attribute as "used".

Parameters:
idx - int
Throws:
org.xml.sax.SAXException

eatAttribute

public java.lang.String eatAttribute(int idx)
                              throws org.xml.sax.SAXException
Marks the attribute as "used" and return the value of the attribute.

Parameters:
idx - int
Returns:
String
Throws:
org.xml.sax.SAXException

addPatcher

public void addPatcher(java.lang.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

public java.lang.String addToIdTable(java.lang.String id)
Adds the object which is currently being unmarshalled to the ID table.

Parameters:
id - String
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 java.lang.Object getObjectFromId(java.lang.String id)
Looks up the ID table and gets associated object.

Parameters:
id - String
Returns:
If there is no object associated with the given id, this method returns null.

getLocator

public org.xml.sax.Locator getLocator()
Gets the current source location information.

Returns:
Locator

handleEvent

public void handleEvent(javax.xml.bind.ValidationEvent event,
                        boolean canRecover)
                 throws org.xml.sax.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.

Parameters:
event - ValidationEvent
canRecover - boolean
Throws:
org.xml.sax.SAXException

resolveNamespacePrefix

public java.lang.String resolveNamespacePrefix(java.lang.String prefix)
Method resolveNamespacePrefix

Parameters:
prefix - String
Returns:
String

getBaseUri

public java.lang.String getBaseUri()
Method getBaseUri

Returns:
String

isUnparsedEntity

public boolean isUnparsedEntity(java.lang.String entityName)
Method isUnparsedEntity

Parameters:
entityName - String
Returns:
boolean

isNotation

public boolean isNotation(java.lang.String notationName)
Method isNotation

Parameters:
notationName - String
Returns:
boolean

getTracer

public 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.

Returns:
Tracer