public class DigesterDefinitionsReader extends Object implements DefinitionsReader
Definition
objects from
an XML InputStream using Digester.
This DefinitionsReader
implementation expects the source to be
passed as an InputStream
. It parses XML data from the source
and builds a Map of Definition objects.
The Digester object can be configured by passing in initialization
parameters. Currently the only parameter that is supported is the
validating
parameter. This value is set to false
by default. To enable DTD validation for XML Definition files, give the init
method a parameter with a key of
org.apache.tiles.definition.digester.DigesterDefinitionsReader.PARSER_VALIDATE
and a value of "true"
.
The Definition objects are stored internally in a Map. The Map is stored as
an instance variable rather than a local variable in the read
method. This means that instances of this class are not
thread-safe and access by multiple threads must be synchronized.
Modifier and Type | Class and Description |
---|---|
class |
DigesterDefinitionsReader.AddNestedDefinitionRule
Digester rule to manage assignment of a nested definition in an attribute
value.
|
static class |
DigesterDefinitionsReader.FillAttributeRule
Digester rule to manage attribute filling.
|
static class |
DigesterDefinitionsReader.FillDefinitionRule
Digester rule to manage definition filling.
|
static class |
DigesterDefinitionsReader.PutAttributeRule
Digester rule to manage assignment of the attribute to the parent
element.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFINITION_HANDLER_CLASS
The handler to create definitions.
|
protected Digester |
digester
Digester object used to read Definition data
from the source. |
protected static String |
LIST_HANDLER_CLASS
The handler to create list attributes.
|
static String |
PARSER_VALIDATE_PARAMETER_NAME
Digester validation parameter name.
|
protected static String |
PUT_ATTRIBUTE_HANDLER_CLASS
The handler to create attributes.
|
protected String[] |
registrations
The set of public identifiers, and corresponding resource names for
the versions of the configuration file DTDs we know about.
|
Constructor and Description |
---|
DigesterDefinitionsReader()
Creates a new instance of DigesterDefinitionsReader.
|
Modifier and Type | Method and Description |
---|---|
void |
addDefinition(Definition definition)
Adds a new
Definition to the internal Map or replaces
an existing one. |
protected String |
getNextUniqueDefinitionName(Map<String,Definition> definitions)
Create a unique definition name usable to store anonymous definitions.
|
protected String[] |
getRegistrations()
Returns the registrations for local DTDs.
|
protected void |
initSyntax(Digester digester)
Initialised the syntax for reading XML files containing Tiles
definitions.
|
Map<String,Definition> |
read(Object source)
Reads
objects from a source. |
void |
setValidating(boolean validating)
Sets the validation of XML files.
|
public static final String PARSER_VALIDATE_PARAMETER_NAME
protected static final String DEFINITION_HANDLER_CLASS
protected static final String PUT_ATTRIBUTE_HANDLER_CLASS
protected static final String LIST_HANDLER_CLASS
protected Digester digester
Digester
object used to read Definition data
from the source.protected String[] registrations
public DigesterDefinitionsReader()
public void setValidating(boolean validating)
validating
- true
means that XML validation is turned
on. false
otherwise.public Map<String,Definition> read(Object source)
Definition
objects from a source.
Implementations should publish what type of source object is expected.read
in interface DefinitionsReader
source
- The InputStream
source from which definitions
will be read.Definition
objects read from
the source.DefinitionsFactoryException
- If the source is invalid or
an error occurs when reading definitions.protected void initSyntax(Digester digester)
digester
- The digester to initialize.public void addDefinition(Definition definition)
Definition
to the internal Map or replaces
an existing one.definition
- The Definition object to be added.protected String[] getRegistrations()
protected String getNextUniqueDefinitionName(Map<String,Definition> definitions)
definitions
- The already created definitions.Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.