|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.apache.struts.tiles.xmlDefinition.FactorySet
|
+--org.apache.struts.tiles.xmlDefinition.I18nFactorySet
Definitions factory.
This implementation allows to have a set of definition factories.
There is a main factory and one factory for each file associated to a Locale.
To retrieve a definition, we first search for the appropriate factory using
the Locale found in session context. If no factory is found, use the
default one. Then we ask the factory for the definition.
A definition factory file is loaded using main filename extended with locale code
(ex : templateDefinitions_fr.xml). If no file is found under this name, use default file.
| Field Summary | |
static java.lang.String[] |
DEFAULT_DEFINITION_FILENAMES
Possible definition filenames. |
protected DefinitionsFactory |
defaultFactory
Default factory. |
static java.lang.String |
DEFINITIONS_CONFIG_PARAMETER_NAME
Config file parameter name. |
static java.lang.String |
FILENAME_EXTENSION
Default filenames extension. |
private java.util.List |
filenames
Names of files containing instances descriptions. |
protected boolean |
isValidatingParser
Do we want validating parser. |
private java.util.Map |
loaded
Collection of already loaded definitions set, referenced by their suffix. |
protected static org.apache.commons.logging.Log |
log
Commons Logging instance. |
static java.lang.String |
PARSER_DETAILS_PARAMETER_NAME
Config file parameter name. |
static java.lang.String |
PARSER_VALIDATE_PARAMETER_NAME
Config file parameter name. |
protected int |
parserDetailLevel
Parser detail level. |
protected XmlParser |
xmlParser
XML parser used. |
| Fields inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet |
factories |
| Constructor Summary | |
I18nFactorySet()
Parameterless Constructor. |
|
I18nFactorySet(javax.servlet.ServletContext servletContext,
java.util.Map properties)
Constructor. |
|
| Method Summary | |
private java.util.List |
calculateSuffixes(java.util.Locale locale)
Calculate the suffixes based on the locale. |
private java.lang.String |
concatPostfix(java.lang.String name,
java.lang.String postfix)
Concat postfix to the name. |
protected DefinitionsFactory |
createDefaultFactory(javax.servlet.ServletContext servletContext)
Create default factory . |
protected DefinitionsFactory |
createFactory(java.lang.Object key,
javax.servlet.ServletRequest request,
javax.servlet.ServletContext servletContext)
Create a factory for specified key. |
protected DefinitionsFactory |
getDefaultFactory()
Get default factory. |
protected java.lang.Object |
getDefinitionsFactoryKey(java.lang.String name,
javax.servlet.ServletRequest request,
javax.servlet.ServletContext servletContext)
Extract key that will be used to get the sub factory. |
void |
initFactory(javax.servlet.ServletContext servletContext,
java.util.Map properties)
Initialization method. |
protected void |
initFactory(javax.servlet.ServletContext servletContext,
java.lang.String proposedFilename)
Initialization method. |
private XmlDefinitionsSet |
parseXmlFile(javax.servlet.ServletContext servletContext,
java.lang.String filename,
XmlDefinitionsSet xmlDefinitions)
Parse specified xml file and add definition to specified definitions set. |
private XmlDefinitionsSet |
parseXmlFiles(javax.servlet.ServletContext servletContext,
java.lang.String postfix,
XmlDefinitionsSet xmlDefinitions)
Parse files associated to postix if they exist. |
java.lang.String |
toString()
Return String representation. |
| Methods inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet |
getDefinition, getFactory |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected static org.apache.commons.logging.Log log
public static final java.lang.String DEFINITIONS_CONFIG_PARAMETER_NAME
public static final java.lang.String PARSER_DETAILS_PARAMETER_NAME
public static final java.lang.String PARSER_VALIDATE_PARAMETER_NAME
public static final java.lang.String[] DEFAULT_DEFINITION_FILENAMES
public static final java.lang.String FILENAME_EXTENSION
protected DefinitionsFactory defaultFactory
protected transient XmlParser xmlParser
protected boolean isValidatingParser
false.
Can be set from servlet config file.protected int parserDetailLevel
private java.util.List filenames
private java.util.Map loaded
| Constructor Detail |
public I18nFactorySet()
initFactory(javax.servlet.ServletContext, java.util.Map) must be called prior to any use of created factory.
public I18nFactorySet(javax.servlet.ServletContext servletContext,
java.util.Map properties)
throws DefinitionsFactoryException
servletContext - Servlet context.properties - Map containing all properties.FactoryNotFoundException - Can't find factory configuration file.| Method Detail |
public void initFactory(javax.servlet.ServletContext servletContext,
java.util.Map properties)
throws DefinitionsFactoryException
initFactory in class FactorySetservletContext - Servlet Context passed to newly created factory.properties - Map of name/property passed to newly created factory. Map can contains
more properties than requested.DefinitionsFactoryException - An error occur during initialization.
protected void initFactory(javax.servlet.ServletContext servletContext,
java.lang.String proposedFilename)
throws DefinitionsFactoryException,
java.io.FileNotFoundException
servletContext - Servlet Context passed to newly created factory.proposedFilename - File names, comma separated, to use as base file names.DefinitionsFactoryException - An error occur during initialization.protected DefinitionsFactory getDefaultFactory()
getDefaultFactory in class FactorySet
protected DefinitionsFactory createDefaultFactory(javax.servlet.ServletContext servletContext)
throws DefinitionsFactoryException,
java.io.FileNotFoundException
servletContext - Current servlet context. Used to open file.DefinitionsFactoryException - If an error occur while creating factory.java.io.FileNotFoundException - if factory can't be loaded from filenames.
protected java.lang.Object getDefinitionsFactoryKey(java.lang.String name,
javax.servlet.ServletRequest request,
javax.servlet.ServletContext servletContext)
getDefinitionsFactoryKey in class FactorySetname - Name of requested definitionrequest - Current servlet request.servletContext - Current servlet context.null if not found.
protected DefinitionsFactory createFactory(java.lang.Object key,
javax.servlet.ServletRequest request,
javax.servlet.ServletContext servletContext)
throws DefinitionsFactoryException
createFactory in class FactorySetkey - The key.request - Servlet request.servletContext - Servlet context.DefinitionsFactoryException - If an error occur while creating factory.private java.util.List calculateSuffixes(java.util.Locale locale)
locale - the locale
private XmlDefinitionsSet parseXmlFiles(javax.servlet.ServletContext servletContext,
java.lang.String postfix,
XmlDefinitionsSet xmlDefinitions)
throws DefinitionsFactoryException
null.postfix - Postfix to add to each description file.xmlDefinitions - Definitions set to which definitions will be added. If null, a definitions
set is created on request.DefinitionsFactoryException - On errors parsing file.
private XmlDefinitionsSet parseXmlFile(javax.servlet.ServletContext servletContext,
java.lang.String filename,
XmlDefinitionsSet xmlDefinitions)
throws DefinitionsFactoryException
null, create a new set. Otherwise, return
passed definition set (can be null).servletContext - Current servlet context. Used to open file.filename - Name of file to parse.xmlDefinitions - Definitions set to which definitions will be added. If null, a definitions
set is created on request.DefinitionsFactoryException - On errors parsing file.
private java.lang.String concatPostfix(java.lang.String name,
java.lang.String postfix)
name - Filename.postfix - Postfix to add.public java.lang.String toString()
toString in class FactorySet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||