Top Description Fields Constructors Methods
org.eclipse.persistence.oxm

public Class XMLValidator

extends Object
Class Inheritance
Imports
org.eclipse.persistence.exceptions.XMLMarshalException, org.eclipse.persistence.internal.oxm.Root, org.eclipse.persistence.platform.xml.XMLParser, .XMLPlatform, .XMLPlatformException, .XMLPlatformFactory, org.w3c.dom.Document, org.xml.sax.ErrorHandler

Class used to validate XML. This is used to check if the XML created during a marshal operation would be valid XML before the marshal operation is performed.

Create an XMLValidator from an XMLContext.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLValidator validator = context.createValidator();

The validateRoot method is used to validate objects which are mapped to global elements in a schema and which have a default root element specified in the TopLink project. The validate method is used to validate all other mapped objects.

See Also
org.eclipse.persistence.oxm.XMLContext

Field Summary

Modifier and TypeField and Description
public static final int
private ErrorHandler
private XMLMarshaller
public static final int
public static final int
private XMLContext

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public ErrorHandler

Returns:

the error handler associated with this XMLValidator
getErrorHandler
()

Get the error handler to be used during validation

public void
setErrorHandler(ErrorHandler
the error handler to be used during validation
handler
)

Set the error handler to be used during validation

public boolean

Returns:

true if this is a valid object, otherwise false
validate
(Object
A single object to validate
object
)

Validate the given object.

public boolean

Returns:

true if this is a valid object, otherwise false
validateRoot
(Object
A single root object to validate
rootObject
)

Validate the given root object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DTD_VALIDATIONback to summary
public static final int DTD_VALIDATION
errorHandlerback to summary
private ErrorHandler errorHandler
marshallerback to summary
private XMLMarshaller marshaller
NONVALIDATINGback to summary
public static final int NONVALIDATING
SCHEMA_VALIDATIONback to summary
public static final int SCHEMA_VALIDATION
xmlContextback to summary
private XMLContext xmlContext

Constructor Detail

XMLValidatorback to summary
protected XMLValidator(XMLContext xmlContext)

Method Detail

getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

Get the error handler to be used during validation

Returns:ErrorHandler

the error handler associated with this XMLValidator

setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler handler)

Set the error handler to be used during validation

Parameters
handler:ErrorHandler

the error handler to be used during validation

validateback to summary
public boolean validate(Object object) throws XMLMarshalException

Validate the given object.

Parameters
object:Object

A single object to validate

Returns:boolean

true if this is a valid object, otherwise false

validateRootback to summary
public boolean validateRoot(Object rootObject) throws XMLMarshalException

Validate the given root object.

Parameters
rootObject:Object

A single root object to validate

Returns:boolean

true if this is a valid object, otherwise false