Class SecureUnmarshaller
- All Implemented Interfaces:
Unmarshaller
- Version:
- $Revision: 1.1 $ Created Feb 1, 2012
- Author:
- Ron Sigal
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.xml.bind.Unmarshaller
Unmarshaller.Listener -
Constructor Summary
ConstructorsConstructorDescriptionSecureUnmarshaller(Unmarshaller delegate, boolean disableExternalEntities, boolean enableSecureProcessingFeature, boolean disableDTDs) -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidconfigureParserFactory(SAXParserFactory factory, boolean disableExternalEntities, boolean enableSecureProcessingFeature, boolean disableDTDs) <A extends XmlAdapter>
AgetAdapter(Class<A> type) Return the current event handler or the default event handler if one hasn't been set.ReturnUnmarshaller.Listenerregistered with thisUnmarshaller.getProperty(String name) Get the particular property in the underlying implementation ofUnmarshaller.Get the JAXPSchemaobject being used to perform unmarshal-time validation.Get an unmarshaller handler object that can be used as a component in an XML pipeline.booleanDeprecated.voidsetAdapter(XmlAdapter adapter) Associates a configured instance ofXmlAdapterwith this unmarshaller.<A extends XmlAdapter>
voidsetAdapter(Class<A> type, A adapter) voidAssociate a context that resolves cid's, content-id URIs, to binary data passed as attachments.voidsetDelegate(Unmarshaller delegate) voidsetEventHandler(ValidationEventHandler handler) Allow an application to register aValidationEventHandler.voidsetListener(Unmarshaller.Listener listener) Register unmarshal event callbackUnmarshaller.Listenerwith thisUnmarshaller.voidsetProperty(String name, Object value) Set the particular property in the underlying implementation ofUnmarshaller.voidSpecify the JAXPSchemaobject that should be used to validate subsequent unmarshal operations against.voidsetValidating(boolean validating) Deprecated.since JAXB2.0, please seegetSchema()Unmarshal XML data from the specified file and return the resulting content tree.unmarshal(InputStream is) Turns off expansion of external entities.Unmarshal XML data from the specified Reader and return the resulting content tree.Unmarshal XML data from the specified URL and return the resulting content tree.unmarshal(XMLEventReader reader) Unmarshal XML data from the specified pull parser and return the resulting content tree.<T> JAXBElement<T>unmarshal(XMLEventReader reader, Class<T> declaredType) Unmarshal root element to Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.unmarshal(XMLStreamReader reader) Unmarshal XML data from the specified pull parser and return the resulting content tree.<T> JAXBElement<T>unmarshal(XMLStreamReader reader, Class<T> declaredType) Unmarshal root element to Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.Unmarshal XML data from the specified XML Source and return the resulting content tree.<T> JAXBElement<T>Unmarshal XML data from the specified XML Source bydeclaredTypeand return the resulting content tree.Unmarshal global XML data from the specified DOM tree and return the resulting content tree.<T> JAXBElement<T>Unmarshal XML data by Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.unmarshal(InputSource source) Turns off expansion of external entities.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.xml.bind.Unmarshaller
getAdapter, setAdapter
-
Constructor Details
-
SecureUnmarshaller
public SecureUnmarshaller(Unmarshaller delegate, boolean disableExternalEntities, boolean enableSecureProcessingFeature, boolean disableDTDs)
-
-
Method Details
-
getAdapter
-
getAttachmentUnmarshaller
- Specified by:
getAttachmentUnmarshallerin interfaceUnmarshaller
-
getEventHandler
Description copied from interface:UnmarshallerReturn the current event handler or the default event handler if one hasn't been set.- Specified by:
getEventHandlerin interfaceUnmarshaller- Returns:
- the current ValidationEventHandler or the default event handler if it hasn't been set
- Throws:
JAXBException- if an error was encountered while getting the current event handler
-
getListener
Description copied from interface:UnmarshallerReturn
Unmarshaller.Listenerregistered with thisUnmarshaller.- Specified by:
getListenerin interfaceUnmarshaller- Returns:
- registered
Unmarshaller.Listenerornullif no Listener is registered with this Unmarshaller.
-
getProperty
Description copied from interface:UnmarshallerGet the particular property in the underlying implementation ofUnmarshaller. This method can only be used to get one of the standard Jakarta XML Binding defined properties above or a provider specific property. Attempting to get an undefined property will result in a PropertyException being thrown. See Supported Properties.- Specified by:
getPropertyin interfaceUnmarshaller- Parameters:
name- the name of the property to retrieve- Returns:
- the value of the requested property
- Throws:
PropertyException- when there is an error retrieving the given property or value property name
-
getSchema
Description copied from interface:UnmarshallerGet the JAXPSchemaobject being used to perform unmarshal-time validation. If there is no Schema set on the unmarshaller, then this method will return null indicating that unmarshal-time validation will not be performed.- Specified by:
getSchemain interfaceUnmarshaller- Returns:
- the Schema object being used to perform unmarshal-time validation or null if not present
-
getUnmarshallerHandler
Description copied from interface:UnmarshallerGet an unmarshaller handler object that can be used as a component in an XML pipeline.The Jakarta XML Binding Provider can return the same handler object for multiple invocations of this method. In other words, this method does not necessarily create a new instance of
UnmarshallerHandler. If the application needs to use more than oneUnmarshallerHandler, it should create more than oneUnmarshaller.- Specified by:
getUnmarshallerHandlerin interfaceUnmarshaller- Returns:
- the unmarshaller handler object
- See Also:
-
isValidating
Deprecated.This method is deprecated as of JAXB 2.0 - please use the newgetSchema()API.- Throws:
JAXBException
-
setAdapter
Description copied from interface:UnmarshallerAssociates a configured instance ofXmlAdapterwith this unmarshaller.This is a convenience method that invokes
setAdapter(adapter.getClass(),adapter);.- Specified by:
setAdapterin interfaceUnmarshaller- Parameters:
adapter- the configured instance ofXmlAdapter- See Also:
-
setAdapter
-
setAttachmentUnmarshaller
Description copied from interface:UnmarshallerAssociate a context that resolves cid's, content-id URIs, to binary data passed as attachments. Unmarshal time validation, enabled viaUnmarshaller.setSchema(Schema), must be supported even when unmarshaller is performing XOP processing.- Specified by:
setAttachmentUnmarshallerin interfaceUnmarshaller- Parameters:
au- the attachment unmarshaller to be set
-
setEventHandler
Description copied from interface:UnmarshallerAllow an application to register aValidationEventHandler.The
ValidationEventHandlerwill be called by the Jakarta XML Binding Provider if any validation errors are encountered during calls to any of the unmarshal methods. If the client application does not register aValidationEventHandlerbefore invoking the unmarshal methods, thenValidationEventswill be handled by the default event handler which will terminate the unmarshal operation after the first error or fatal error is encountered.Calling this method with a null parameter will cause the Unmarshaller to revert back to the default event handler.
- Specified by:
setEventHandlerin interfaceUnmarshaller- Parameters:
handler- the validation event handler- Throws:
JAXBException- if an error was encountered while setting the event handler
-
setListener
Description copied from interface:UnmarshallerRegister unmarshal event callback
Unmarshaller.Listenerwith thisUnmarshaller.There is only one Listener per Unmarshaller. Setting a Listener replaces the previous set Listener. One can unregister current Listener by setting listener to
null.- Specified by:
setListenerin interfaceUnmarshaller- Parameters:
listener- provides unmarshal event callbacks for thisUnmarshaller
-
setProperty
Description copied from interface:UnmarshallerSet the particular property in the underlying implementation ofUnmarshaller. This method can only be used to set one of the standard Jakarta XML Binding defined properties above or a provider specific property. Attempting to set an undefined property will result in a PropertyException being thrown. See Supported Properties.- Specified by:
setPropertyin interfaceUnmarshaller- Parameters:
name- the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.value- the value of the property to be set- Throws:
PropertyException- when there is an error processing the given property or value
-
setSchema
Description copied from interface:UnmarshallerSpecify the JAXPSchemaobject that should be used to validate subsequent unmarshal operations against. Passing null into this method will disable validation.Initially this property is set to
null.- Specified by:
setSchemain interfaceUnmarshaller- Parameters:
schema- Schema object to validate unmarshal operations against or null to disable validation
-
setValidating
Deprecated.since JAXB2.0, please seegetSchema()- Throws:
JAXBException
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified file and return the resulting content tree.Implements Unmarshal Global Root Element.
- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
f- the file to unmarshal XML data from- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Turns off expansion of external entities.- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
is- the InputStream to unmarshal XML data from- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified Reader and return the resulting content tree. Validation event location information may be incomplete when using this form of the unmarshal API, because a Reader does not provide the system ID.Implements Unmarshal Global Root Element.
- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
reader- the Reader to unmarshal XML data from- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified URL and return the resulting content tree.Implements Unmarshal Global Root Element.
- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
url- the url to unmarshal XML data from- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Turns off expansion of external entities.- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
source- the input source to unmarshal XML data from- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal global XML data from the specified DOM tree and return the resulting content tree.Implements Unmarshal Global Root Element.
- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
node- the document/element to unmarshal XML data from. The caller must support at least Document and Element.- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data- See Also:
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified XML Source and return the resulting content tree.Implements Unmarshal Global Root Element.
A client application can choose not to use the default parser mechanism supplied with their Jakarta XML Binding provider. Any SAX 2.0 compliant parser can be substituted for the Jakarta XML Binding provider's default mechanism. To do so, the client application must properly configure a
SAXSourcecontaining anXMLReaderimplemented by the SAX 2.0 parser provider. If theXMLReaderhas anorg.xml.sax.ErrorHandlerregistered on it, it will be replaced by the Jakarta XML Binding Provider so that validation errors can be reported via theValidationEventHandlermechanism of Jakarta XML Binding. If theSAXSourcedoes not contain anXMLReader, then the Jakarta XML Binding provider's default parser mechanism will be used.This parser replacement mechanism can also be used to replace the Jakarta XML Binding provider's unmarshal-time validation engine. The client application must properly configure their SAX 2.0 compliant parser to perform validation (as shown in the example above). Any
SAXParserExceptionsencountered by the parser during the unmarshal operation will be processed by the Jakarta XML Binding provider and converted into Jakarta XML BindingValidationEventobjects which will be reported back to the client via theValidationEventHandlerregistered with theUnmarshaller. Note: specifying a substitute validating SAX 2.0 parser for unmarshalling does not necessarily replace the validation engine used by the Jakarta XML Binding provider for performing on-demand validation.The only way for a client application to specify an alternate parser mechanism to be used during unmarshal is via the
unmarshal(SAXSource)API. All other forms of the unmarshal method (File, URL, Node, etc.) will use the Jakarta XML Binding provider's default parser and validator mechanisms.- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
source- the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)- Returns:
- the newly created root object of the java content tree
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data- See Also:
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified pull parser and return the resulting content tree.Implements Unmarshal Global Root Element.
This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the
readerwill be pointing at the token right after the end event.- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
reader- The parser to be read.- Returns:
- the newly created root object of the java content tree.
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data- See Also:
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified pull parser and return the resulting content tree.This method is an Unmarshal Global Root method.
This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the
readerwill be pointing at the token right after the end event.- Specified by:
unmarshalin interfaceUnmarshaller- Parameters:
reader- The parser to be read.- Returns:
- the newly created root object of the java content tree.
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data- See Also:
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data by Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.Implements Unmarshal by Declared Type
- Specified by:
unmarshalin interfaceUnmarshaller- Type Parameters:
T- the XML Binding mapped class- Parameters:
node- the document/element to unmarshal XML data from. The caller must support at least Document and Element.declaredType- appropriate Jakarta XML Binding mapped class to holdnode's XML data.- Returns:
- JAXBElement representation of
node - Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
Description copied from interface:UnmarshallerUnmarshal XML data from the specified XML Source bydeclaredTypeand return the resulting content tree.Implements Unmarshal by Declared Type
- Specified by:
unmarshalin interfaceUnmarshaller- Type Parameters:
T- the XML Binding mapped class- Parameters:
source- the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)declaredType- appropriate Jakarta XML Binding mapped class to holdsource's xml root element- Returns:
- Java content rooted by JAXBElement
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> declaredType) throws JAXBException Description copied from interface:UnmarshallerUnmarshal root element to Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.This method implements unmarshal by declaredType.
This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the
readerwill be pointing at the token right after the end event.- Specified by:
unmarshalin interfaceUnmarshaller- Type Parameters:
T- the XML Binding mapped class- Parameters:
reader- The parser to be read.declaredType- appropriate Jakarta XML Binding mapped class to holdreader's START_ELEMENT XML data.- Returns:
- content tree rooted by JAXBElement representation
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> declaredType) throws JAXBException Description copied from interface:UnmarshallerUnmarshal root element to Jakarta XML Binding mappeddeclaredTypeand return the resulting content tree.This method implements unmarshal by declaredType.
This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the
readerwill be pointing at the token right after the end event.- Specified by:
unmarshalin interfaceUnmarshaller- Type Parameters:
T- the XML Binding mapped class- Parameters:
reader- The parser to be read.declaredType- appropriate Jakarta XML Binding mapped class to holdreader's START_ELEMENT XML data.- Returns:
- content tree rooted by JAXBElement representation
- Throws:
JAXBException- If any unexpected errors occur while unmarshallingUnmarshalException- If theValidationEventHandlerreturns false from itshandleEventmethod or theUnmarshalleris unable to perform the XML to Java binding. See Unmarshalling XML Data
-
getDelegate
-
setDelegate
-
configureParserFactory
protected static void configureParserFactory(SAXParserFactory factory, boolean disableExternalEntities, boolean enableSecureProcessingFeature, boolean disableDTDs) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
-
getSchema()API.