|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.xmlc.XMLCStdFactory | +--org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory
Factory class to create instances of an XMLC-generated class with "deferred parsing". Deferred parsing means that the DOM is parsed from a file on first access and re-parsed on subsequent accesses whenever the DOM is out of date with regard to the source file.
Constructor Summary | |
XMLCDeferredParsingFactory(DocumentLoader docLoader,
ClassLoader classLoader,
XMLCLogger logger)
|
Method Summary | |
void |
addPackagePrefix(String prefix)
|
void |
addResourceDir(String path)
|
XMLObject |
create(XMLCCreateOptions xmlcCreateOptions)
Creates an instance of an XMLC-generated class, or a class derived from one, using the associated classloader, given one of the following... |
XMLObject |
createFromFile(String filename)
Deprecated. use #create(XMLCCreateOptions) instead |
XMLObject |
createFromFile(String filename,
String domFactoryClassName)
Deprecated. use #create(XMLCCreateOptions) instead |
protected XMLObject |
doCreate(Class xmlcBasedClass)
Create a new document instance. |
protected XMLObject |
doCreate(String xmlcClassName,
ClassLoader classLoader)
Do the actual work of creating a new object given a name. |
static Object |
getClassConstant(Class xmlcBasedClass,
String constName)
Get one of the compiled-in constants in a XMLC-generated class (or subclass). |
String |
getDefaultMetaDataFile()
|
URL |
getDefaultMetaDataURL()
|
Locale[] |
getLocales()
Meant to provide the DocumentLoader instance, associated with the current instance of this class, access to user-defined Locale objects (user and developer-preferred fallback) for use in loading localized markup files. |
(package private) List |
getPackagePrefixList()
|
String[] |
getPathsFromPackagePrefixes(String path)
Get possible file paths by subtracting each respective package prefix from the path prefix. |
URL |
getPathURLFromClasspath(String path)
|
URL |
getPathURLFromResourceDir(String path)
|
(package private) List |
getResourceDirList()
|
static String |
getSourceFilePath(Class docClass)
Get the name of the source file associated with docClass |
static String |
getXmlcClassMetaDataFilePath(Class xmlcClass)
|
String[] |
getXmlcClassMetaDataFilePaths(Class docClass)
Get the metadata file paths. |
String[] |
getXmlcSourceMetaDataFilePaths(String xmlcSourceFilePath)
Get the metadata file paths. |
boolean |
isEnableI18n()
|
MetaData |
loadMetaData(URL metaDataURL,
ErrorReporter errorReporter)
|
void |
remove(String prefix)
Deprecated. |
void |
removePackagePrefix(String prefix)
|
void |
removeResourceDir(String path)
|
void |
setDefaultFallbackLocale(Locale defaultFallbackLocale)
|
void |
setDefaultMetaDataPath(String path)
|
void |
setEnableI18n(boolean enableI18n)
Set the flag to enable Internationalization (I18n), or Localization (L10n). |
Methods inherited from class org.enhydra.xml.xmlc.XMLCStdFactory |
create, create, getDefaultClassLoader, getLogger, handleError |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public XMLCDeferredParsingFactory(DocumentLoader docLoader, ClassLoader classLoader, XMLCLogger logger)
docLoader
- Document loader to use or null
classLoader
- Classloader used to load classes when a class name
is specified. If null, the system classload is used.
for the StandardDocumentLoader
logger
- XMLC logger or null for no logging.Method Detail |
protected XMLObject doCreate(Class xmlcBasedClass) throws ClassNotFoundException, IllegalAccessException, InstantiationException
doCreate
in class XMLCStdFactory
protected XMLObject doCreate(String xmlcClassName, ClassLoader classLoader) throws ClassNotFoundException, IllegalAccessException, InstantiationException
doCreate
in class XMLCStdFactory
public XMLObject create(XMLCCreateOptions xmlcCreateOptions)
xmlcClass
(implementation or interface)xmlcClassName
(implementation or interface)dynMarkupFilePath
When using
dynamic loading
,
one may define the optional
dynDomFactoryClassName
, define it in the default metadata, or just fall back to the
XMLCDomFactoryCache
class default, in that order.
The optional user
and
fallback
Locales
are utilized in choosing the markup file associated
with the class. Locale-named markup files, if found, are used in
preference to the base markup file. If the user Locale is null, the
fallback Locale is used in its place. If the fallback Locale is null,
the defaultFallbackLocale
is used in
its place (as well as the user Locale if it is also null).
Markup files are looked up based first on user Locale and, if not found, then on fallback Locale and, if not found, finally the base markup file is used.
Note that the Locales are ignored if isEnableI18n()
returns false
or the Locales are null.
xmlcCreateOptions
- the XMLC create options providing information on
how to load the XMLObjectsetEnableI18n(boolean)
,
setDefaultFallbackLocale(java.util.Locale)
public XMLObject createFromFile(String filename)
createFromFile(String, String)
,
create(XMLCCreateOptions)
public XMLObject createFromFile(String filename, String domFactoryClassName)
create(XMLCCreateOptions)
public void addResourceDir(String path)
path
- a path to add as a resource directorypublic void removeResourceDir(String path)
path
- a path to remove as a resource directoryList getResourceDirList()
public void addPackagePrefix(String prefix)
prefix
- a package prefix to addpublic void removePackagePrefix(String prefix)
prefix
- a package prefix to removepublic void remove(String prefix)
prefix
- a package prefix to removeremovePackagePrefix(java.lang.String)
List getPackagePrefixList()
public void setDefaultMetaDataPath(String path)
path
- the path to the meta data filepublic String getDefaultMetaDataFile()
public final boolean isEnableI18n()
setEnableI18n(boolean)
public final void setEnableI18n(boolean enableI18n)
Note it's capital "I", and it's "I18n", not "Il8n" (Number "1", not letter "l"). See http://www.i18nguy.com/origini18n.html
enableI18n
- true to enable, false to disable (default)getLocales()
public final void setDefaultFallbackLocale(Locale defaultFallbackLocale)
defaultFallbackLocale
- the default fallback Locale, used in the case
where I18n is enabled and no fallbackLocale
(or user locale) is specified on the
create(XMLCCreateOptions) method.setEnableI18n(boolean)
public final Locale[] getLocales()
Note that this method is guaranteed to return null unless
setEnableI18n(true)
is called.
Note also that the value returned by this method is time/unit-of-work context dependent on a per/thread basis. The value will be null when called out of context or even when in context but no non-null user-defined Locales are provided. As such, take care to check for null prior to using the returned value and, of course, don't cache it either.
create(XMLCCreateOptions)
invocation on a per/thread thread basis.setEnableI18n(boolean)
,
setDefaultFallbackLocale(java.util.Locale)
public final MetaData loadMetaData(URL metaDataURL, ErrorReporter errorReporter) throws XMLCException
metaDataURL
- the URL of the metadata fileerrorReporter
- used to report metadata parse errorsXMLCException
- if something goes wrong loading metadatapublic final URL getDefaultMetaDataURL()
document loader
implementationgetDefaultMetaDataFile()
,
getPathsFromPackagePrefixes(String)
public final String[] getXmlcClassMetaDataFilePaths(Class docClass)
An ascending sort is applied resulting in a consistent order when dealing with configured package prefix paths and interface -vs- "Impl" extensions.
xmlcClassMetaDataFilePath
- a relative path (no leading slash) to
the meta data file for an XMLC classgetXmlcClassMetaDataFilePath(Class)
,
getXmlcSourceMetaDataFilePaths(String)
,
getPathsFromPackagePrefixes(String)
public final String[] getXmlcSourceMetaDataFilePaths(String xmlcSourceFilePath)
xmlcSourceFilePath
- a relative path (no leading slash) to a source
markup filegetPathsFromPackagePrefixes(String)
public static Object getClassConstant(Class xmlcBasedClass, String constName)
public static String getSourceFilePath(Class docClass) throws XMLCRuntimeException
docClass
public final String[] getPathsFromPackagePrefixes(String path)
path
- a relative path (no leading slash) to either a source markup
file or XMLC metadata filepublic final URL getPathURLFromResourceDir(String path)
path
- the relative path to the source filepublic final URL getPathURLFromClasspath(String path)
path
- the fully qualified path to the source file (with no leading slashes)public static String getXmlcClassMetaDataFilePath(Class xmlcClass)
xmlcClass
- an XMLC class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |