|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dhmp.util.xml.SchemaCollection
Container for parsed schema. If the schema is not in the container, it looks for the, XSD document (XML Schema Document) from URL provided, parse and stock the result.
SchemaCollection is not fully compliant with W3C Recommendation. It only implements a subset required to validate HierarchicalMap. All XSD document must be a valid XML Schema Document. The result of passing malformed XSD document is unpredictable!
The interpretarion of HierarchicalMap node, like number and date are locale-sensitive. The interpretation of date anda datetime depends on TimeZone setting. Note that data is locale-sensitive though value space definition on XSD document is not. It means that HierarchicalMap can contain "12,789" as a value, using comma as decimal separator, but the value space, like minInclusive, must be defined as "12.5".
Schema
Constructor Summary | |
SchemaCollection()
Constructs a SchemaCollection with the default locale and time zone. |
|
SchemaCollection(java.util.Locale locale)
Constructs a SchemaCollection with the default locale and specified time zone. |
|
SchemaCollection(java.util.TimeZone timezone)
Constructs a SchemaCollection with the specified locale and default time zone. |
|
SchemaCollection(java.util.TimeZone timezone,
java.util.Locale locale)
Constructs a SchemaCollection with the specified locale and time zone. |
Method Summary | |
Schema |
get(java.io.InputStream schemaIn)
This will return the Schema instance for XML Schema read from InputStream. |
Schema |
get(java.io.InputStream schemaIn,
java.io.InputStream messageIn)
This will return the Schema instance for XML Schema read from InputStream. |
Schema |
get(java.lang.String schema)
This will return the instance for the specific XML Schema URL. |
Schema |
get(java.net.URL schemaURL)
This will return the instance for the specific XML Schema URL. |
Schema |
get(java.net.URL schemaURL,
java.net.URL messageURL)
This will return the Schema instance for the specific XML Schema URL. |
java.util.Locale |
getLocale()
Returns the current locale used for parsing and validation. |
java.util.ResourceBundle |
getMessage()
Gets the resource bundle containing default messages. |
java.util.Locale |
getMessageLocale()
Returns the current locale used for loading ResourceBundle containing the default messages. |
Schema |
getUnsafe(java.io.InputStream schemaIn,
java.io.InputStream messageIn)
This is equivalent to get(InputStream, InputStream) except that the returned Schema is unsafe. |
Schema |
getUnsafe(java.lang.String schema)
This will return the instance for the specific XML Schema URL. |
Schema |
getUnsafe(java.net.URL schemaURL)
This will return the instance for the specific XML Schema URL. |
Schema |
getUnsafe(java.net.URL schemaURL,
java.net.URL messageURL)
This is equivalent to get(URL, URL) except that the Schema returned is unsafe. |
java.lang.Object |
parseData(java.lang.String dataType,
java.lang.Object value)
Parses the value to corresponding java object using the same rule used during schema parsing. |
void |
remove(java.lang.String schema)
Removes the specified schema from cache. |
void |
removeAll()
Removes all the schema from cache. |
void |
setLocale(java.util.Locale locale)
Sets the locale used for validation. |
Schema |
Unsafe(java.io.InputStream schemaIn)
This will return the unsafe Schema instance for XML Schema read from InputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SchemaCollection()
public SchemaCollection(java.util.Locale locale)
locale
- the locale for number and date parsing.public SchemaCollection(java.util.TimeZone timezone)
timezone
- the time zone to use.public SchemaCollection(java.util.TimeZone timezone, java.util.Locale locale)
timezone
- the time zone to use.locale
- the locale for number and date parsing.Method Detail |
public Schema get(java.lang.String schema) throws SchemaException
This will return the instance for the specific XML Schema URL. And try to load the ResourceBundle containing error message from the same location of the schema document.
schema
- String
with URL of schema.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema getUnsafe(java.lang.String schema) throws SchemaException
This will return the instance for the specific XML Schema URL. And try to load the ResourceBundle containing error message from the same location of the schema document. This is unsafe because its restriction is exposed.
schema
- String
with URL of schema.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema get(java.net.URL schemaURL) throws SchemaException
This will return the instance for the specific XML Schema URL. And try to load the ResourceBundle containing error message from the same location of the schema document.
schemaURL
- URL
of schema.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema getUnsafe(java.net.URL schemaURL) throws SchemaException
This will return the instance for the specific XML Schema URL. And try to load the ResourceBundle containing error message from the same location of the schema document. This is unsafe because its restriction is exposed.
schemaURL
- URL
of schema.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema get(java.net.URL schemaURL, java.net.URL messageURL) throws SchemaException
This will return the Schema instance for the specific XML Schema URL. If the schema has already parsed, it is returned from cache, otherwise a new instance is created, and then returned.
ResourceBundle can be associated to the schema for error messages. The name of ResourceBundle must be the same as name of schema document, replacing all dots ('.') by underscore ('_') including the file extension.
SchemaCollection will try to load the ResourceBundle according to locale passed to it. If there is no corresponding ResourceBundle, it will try to load from default locale but the data interpretation will keep using the original locale. Therefore, depending on the choosen locale, data interpretation can occur in one locale and error messges in another locale.
schemaURL
- URL
of schema.messageURL
- URL
of ResourceBundle containing error messages.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema getUnsafe(java.net.URL schemaURL, java.net.URL messageURL) throws SchemaException
This is equivalent to get(URL, URL) except that the Schema returned is unsafe.
schemaURL
- URL
of schema.messageURL
- URL
of ResourceBundle containing error messages.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.public Schema get(java.io.InputStream schemaIn) throws SchemaException
This will return the Schema instance for XML Schema read from InputStream.
schemaIn
- InputStream
from where the schema is read.
Schema
- the instance of Schema, ready to use.
SchemaException
- when errors in parsing occur.public Schema Unsafe(java.io.InputStream schemaIn) throws SchemaException
This will return the unsafe Schema instance for XML Schema read from InputStream.
schemaIn
- InputStream
from where the schema is read.
Schema
- the instance of Schema, ready to use.
SchemaException
- when errors in parsing occur.public Schema get(java.io.InputStream schemaIn, java.io.InputStream messageIn) throws SchemaException
This will return the Schema instance for XML Schema read from InputStream. If the schema has already parsed, it is returned from cache, otherwise a new instance is created, and then returned.
ResourceBundle can also be loaded from another InputStream.
schemaIn
- InputStream
from where the schema is read.messageIn
- InputStream
from where the PropertyResourceBundle
is read.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.get(URL schemaURL, URL messageURL)
public Schema getUnsafe(java.io.InputStream schemaIn, java.io.InputStream messageIn) throws SchemaException
This is equivalent to get(InputStream, InputStream) except that the returned Schema is unsafe.
schemaIn
- InputStream
from where the schema is read.messageIn
- InputStream
from where the PropertyResourceBundle
is read.
Schema
- the instance, ready to use.
SchemaException
- when errors in parsing occur.get(URL schemaURL, URL messageURL)
public void remove(java.lang.String schema)
schema
- String
with URL of schema.public void removeAll()
public java.lang.Object parseData(java.lang.String dataType, java.lang.Object value)
dataType
- target type.value
- value to be converted.
public java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
locale
- used for validation.public java.util.ResourceBundle getMessage()
public java.util.Locale getMessageLocale()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |