org.apache.struts.tiles.xmlDefinition
public class I18nFactorySet extends FactorySet
templateDefinitions_fr.xml
). If no file is found under this name, use default file.Modifier and Type | Field and Description |
---|---|
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.
|
factories
Constructor and Description |
---|
I18nFactorySet()
Parameterless Constructor.
|
I18nFactorySet(javax.servlet.ServletContext servletContext,
java.util.Map properties)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
getDefinition, getFactory
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
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.DefinitionsFactoryException
public void initFactory(javax.servlet.ServletContext servletContext, java.util.Map properties) throws DefinitionsFactoryException
initFactory
in interface ComponentDefinitionsFactory
initFactory
in class FactorySet
servletContext
- 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.java.io.FileNotFoundException
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 FactorySet
name
- 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 FactorySet
key
- 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 localeprivate 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
Copyright ? 2000-2014 - The Apache Software Foundation