APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.beans.decoder

public final Class DocumentHandler

extends DefaultHandler
Class Inheritance
Imports
com.sun.beans.finder.ClassFinder, java.beans.ExceptionListener, java.io.IOException, .StringReader, java.lang.ref.Reference, .WeakReference, java.util.ArrayList, .HashMap, .List, .Map, javax.xml.parsers.ParserConfigurationException, .SAXParserFactory, org.xml.sax.Attributes, .InputSource, .SAXException, org.xml.sax.helpers.DefaultHandler, jdk.internal.access.SharedSecrets

The main class to parse JavaBeans XML archive.
Author
Sergey A. Malenkov
Since
1.7
See Also
ElementHandler

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private ElementHandler
private final Map<String, Class<? extends ElementHandler>>
private ExceptionListener
private Reference<ClassLoader>
private final List<Object>
private Object

Constructor Summary

AccessConstructor and Description
public
DocumentHandler()

Creates new instance of document handler.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addObject(Object
the object that is read from XML document
object
)

Adds the object to the list of read objects.

public void
characters(char[]
the array of characters
chars
,
int
the start position in the character array
start
,
int
the number of characters to use
length
)

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Parses character data inside XML element.

public void
endElement(String
the namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed
uri
,
String
the local name (without prefix), or the empty string if namespace processing is not being performed
localName
,
String
the qualified name (with prefix), or the empty string if qualified names are not available
qName
)

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Parses closing tag of XML element using corresponding element handler.

public Class<?>

Returns:

the object that represents the class
findClass
(String
the name of the class
name
)

Resolves class by name using current class loader.

public ClassLoader

Returns:

the class loader used to instantiate objects
getClassLoader
()

Returns the class loader used to instantiate objects.

public Class<? extends ElementHandler>

Returns:

the corresponding element handler
getElementHandler
(String
the name of the element
name
)

Returns the handler for the element with specified name.

public ExceptionListener

Returns:

the exception listener for parsing
getExceptionListener
()

Returns the exception listener for parsing.

public Object[]

Returns:

the array of read objects
getObjects
()

Returns the array of read objects.

public Object

Returns:

the owner of this document handler
getOwner
()

Returns the owner of this document handler.

public Object

Returns:

the value of the variable
getVariable
(String
the identifier
id
)

Returns the value of the variable with specified identifier.

public void
handleException(Exception
an exception to handle
exception
)

Handles an exception using current exception listener.

public boolean

Returns:

true if the variable is defined; false otherwise
hasVariable
(String
the identifier
id
)

Indicates whether the variable with specified identifier is defined.

public void
parse(final InputSource
the input source to parse
input
)

Starts parsing of the specified input source.

public InputSource
resolveEntity(String publicId, String systemId)

Overrides org.xml.sax.helpers.DefaultHandler.resolveEntity.

Implements org.xml.sax.EntityResolver.resolveEntity.

Disables any external entities.

public void
setClassLoader(ClassLoader
a classloader to use
loader
)

Sets the class loader used to instantiate objects.

public void
setElementHandler(String
the name of the element
name
,
Class<? extends ElementHandler>
the corresponding element handler
handler
)

Sets the handler for the element with specified name.

public void
setExceptionListener(ExceptionListener
the exception listener for parsing
listener
)

Sets the exception listener for parsing.

public void
setOwner(Object
the owner of this document handler
owner
)

Sets the owner of this document handler.

public void
setVariable(String
the identifier
id
,
Object
new value of the variable
value
)

Sets new value of the variable with specified identifier.

public void
startDocument()

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Prepares this handler to read objects from XML document.

public void
startElement(String
the namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed
uri
,
String
the local name (without prefix), or the empty string if namespace processing is not being performed
localName
,
String
the qualified name (with prefix), or the empty string if qualified names are not available
qName
,
Attributes
the attributes attached to the element
attributes
)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Parses opening tag of XML element using corresponding element handler.

Inherited from org.xml.sax.helpers.DefaultHandler:
endDocumentendPrefixMappingerrorfatalErrorignorableWhitespacenotationDeclprocessingInstructionsetDocumentLocatorskippedEntitystartPrefixMappingunparsedEntityDeclwarning

Field Detail

environmentback to summary
private final Map<String, Object> environment
handlerback to summary
private ElementHandler handler
handlersback to summary
private final Map<String, Class<? extends ElementHandler>> handlers
listenerback to summary
private ExceptionListener listener
loaderback to summary
private Reference<ClassLoader> loader
objectsback to summary
private final List<Object> objects
ownerback to summary
private Object owner

Constructor Detail

DocumentHandlerback to summary
public DocumentHandler()

Creates new instance of document handler.

Method Detail

addObjectback to summary
pack-priv void addObject(Object object)

Adds the object to the list of read objects.

Parameters
object:Object

the object that is read from XML document

charactersback to summary
public void characters(char[] chars, int start, int length)

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Parses character data inside XML element.

Parameters
chars:char[]

the array of characters

start:int

the start position in the character array

length:int

the number of characters to use

Annotations
@Override
endElementback to summary
public void endElement(String uri, String localName, String qName)

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Parses closing tag of XML element using corresponding element handler.

Parameters
uri:String

the namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if namespace processing is not being performed

qName:String

the qualified name (with prefix), or the empty string if qualified names are not available

Annotations
@Override
findClassback to summary
public Class<?> findClass(String name)

Resolves class by name using current class loader. This method handles exception using current exception listener.

Parameters
name:String

the name of the class

Returns:Class<?>

the object that represents the class

getClassLoaderback to summary
public ClassLoader getClassLoader()

Returns the class loader used to instantiate objects. If the class loader has not been explicitly set then null is returned.

Returns:ClassLoader

the class loader used to instantiate objects

getElementHandlerback to summary
public Class<? extends ElementHandler> getElementHandler(String name)

Returns the handler for the element with specified name.

Parameters
name:String

the name of the element

Returns:Class<? extends ElementHandler>

the corresponding element handler

getExceptionListenerback to summary
public ExceptionListener getExceptionListener()

Returns the exception listener for parsing. The exception listener is notified when handler catches recoverable exceptions. If the exception listener has not been explicitly set then default exception listener is returned.

Returns:ExceptionListener

the exception listener for parsing

getObjectsback to summary
public Object[] getObjects()

Returns the array of read objects.

Returns:Object[]

the array of read objects

getOwnerback to summary
public Object getOwner()

Returns the owner of this document handler.

Returns:Object

the owner of this document handler

getVariableback to summary
public Object getVariable(String id)

Returns the value of the variable with specified identifier.

Parameters
id:String

the identifier

Returns:Object

the value of the variable

handleExceptionback to summary
public void handleException(Exception exception)

Handles an exception using current exception listener.

Parameters
exception:Exception

an exception to handle

See Also
setExceptionListener
hasVariableback to summary
public boolean hasVariable(String id)

Indicates whether the variable with specified identifier is defined.

Parameters
id:String

the identifier

Returns:boolean

true if the variable is defined; false otherwise

parseback to summary
public void parse(final InputSource input)

Starts parsing of the specified input source.

Parameters
input:InputSource

the input source to parse

resolveEntityback to summary
public InputSource resolveEntity(String publicId, String systemId)

Overrides org.xml.sax.helpers.DefaultHandler.resolveEntity.

Implements org.xml.sax.EntityResolver.resolveEntity.

Disables any external entities.

Annotations
@Override
setClassLoaderback to summary
public void setClassLoader(ClassLoader loader)

Sets the class loader used to instantiate objects. If the class loader is not set then default class loader will be used.

Parameters
loader:ClassLoader

a classloader to use

setElementHandlerback to summary
public void setElementHandler(String name, Class<? extends ElementHandler> handler)

Sets the handler for the element with specified name.

Parameters
name:String

the name of the element

handler:Class<? extends ElementHandler>

the corresponding element handler

setExceptionListenerback to summary
public void setExceptionListener(ExceptionListener listener)

Sets the exception listener for parsing. The exception listener is notified when handler catches recoverable exceptions.

Parameters
listener:ExceptionListener

the exception listener for parsing

setOwnerback to summary
public void setOwner(Object owner)

Sets the owner of this document handler.

Parameters
owner:Object

the owner of this document handler

setVariableback to summary
public void setVariable(String id, Object value)

Sets new value of the variable with specified identifier.

Parameters
id:String

the identifier

value:Object

new value of the variable

startDocumentback to summary
public void startDocument()

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Prepares this handler to read objects from XML document.

Annotations
@Override
startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Parses opening tag of XML element using corresponding element handler.

Parameters
uri:String

the namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if namespace processing is not being performed

qName:String

the qualified name (with prefix), or the empty string if qualified names are not available

attributes:Attributes

the attributes attached to the element

Annotations
@Override
@SuppressWarnings:deprecation
Exceptions
SAXException:

Doc from org.xml.sax.helpers.DefaultHandler.startElement.

Any SAX exception, possibly wrapping another exception.