public abstract class ModelContext extends Object
Use Cases:
createContext(java.lang.String)
createEntityResolver(java.lang.String)
createMarshaller(java.lang.String)
createResourceResolver(java.lang.String)
createSchema(java.lang.String)
createUnmarshaller(java.lang.String)
findModel(java.lang.String)
findModel(org.jomc.modlet.Model)
processModel(org.jomc.modlet.Model)
validateModel(org.jomc.modlet.Model)
validateModel(java.lang.String, javax.xml.transform.Source)
ModelContextFactory
Modifier and Type | Class and Description |
---|---|
static class |
ModelContext.Listener
Listener interface.
|
Constructor and Description |
---|
ModelContext()
Creates a new
ModelContext instance. |
ModelContext(ClassLoader classLoader)
Creates a new
ModelContext instance taking a class loader. |
Modifier and Type | Method and Description |
---|---|
void |
clearAttribute(String name)
Removes an attribute from the context.
|
abstract javax.xml.bind.JAXBContext |
createContext(String model)
Creates a new JAXB context instance of a given model.
|
abstract javax.xml.bind.JAXBContext |
createContext(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
abstract EntityResolver |
createEntityResolver(String model)
Creates a new SAX entity resolver instance of a given model.
|
abstract EntityResolver |
createEntityResolver(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
abstract javax.xml.bind.Marshaller |
createMarshaller(String model)
Creates a new JAXB marshaller instance of a given model.
|
abstract javax.xml.bind.Marshaller |
createMarshaller(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
static ModelContext |
createModelContext(ClassLoader classLoader)
Deprecated.
As of JOMC 1.2, replaced by method
ModelContextFactory.newModelContext(java.lang.ClassLoader) .
This method will be removed in version 2.0. |
abstract LSResourceResolver |
createResourceResolver(String model)
Creates a new L/S resource resolver instance of a given model.
|
abstract LSResourceResolver |
createResourceResolver(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
abstract Schema |
createSchema(String model)
Creates a new JAXP schema instance of a given model.
|
abstract Schema |
createSchema(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
abstract <T> T |
createServiceObject(Service service,
Class<T> type)
Creates a new service object.
|
abstract javax.xml.bind.Unmarshaller |
createUnmarshaller(String model)
Creates a new JAXB unmarshaller instance of a given model.
|
abstract javax.xml.bind.Unmarshaller |
createUnmarshaller(URI publicId)
Deprecated.
As of JOMC 1.8, removed without replacement. This method will be removed in JOMC 2.0.
|
Class<?> |
findClass(String name)
Searches the context for a class with a given name.
|
abstract Model |
findModel(Model model)
Populates a given
Model instance. |
abstract Model |
findModel(String model)
Creates a new
Model instance. |
abstract Modlets |
findModlets()
Deprecated.
As of JOMC 1.6, replaced by
findModlets(org.jomc.modlet.Modlets) . This method will be
removed in JOMC 2.0. |
abstract Modlets |
findModlets(Modlets modlets)
Searches the context for
Modlets . |
URL |
findResource(String name)
Searches the context for a resource with a given name.
|
Enumeration<URL> |
findResources(String name)
Searches the context for resources with a given name.
|
Object |
getAttribute(String name)
Gets an attribute of the context.
|
Object |
getAttribute(String name,
Object def)
Gets an attribute of the context.
|
Set<String> |
getAttributeNames()
Gets a set holding the names of all attributes of the context.
|
ClassLoader |
getClassLoader()
Gets the class loader of the context.
|
static Level |
getDefaultLogLevel()
Gets the default log level events are logged at.
|
static String |
getDefaultModletSchemaSystemId()
Gets the default
http://jomc.org/modlet namespace schema system id. |
List<ModelContext.Listener> |
getListeners()
Gets the listeners of the context.
|
Level |
getLogLevel()
Gets the log level of the context.
|
static String |
getModelContextClassName()
Deprecated.
As of JOMC 1.2, replaced by class
ModelContextFactory . This method will be removed in version
2.0. |
Modlets |
getModlets()
Gets the
Modlets of the context. |
String |
getModletSchemaSystemId()
Gets the
http://jomc.org/modlet namespace schema system id of the context. |
boolean |
isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the context.
|
void |
log(Level level,
String message,
Throwable throwable)
Notifies all listeners of the context.
|
abstract Model |
processModel(Model model)
Processes a
Model . |
abstract Modlets |
processModlets(Modlets modlets)
Processes a list of
Modlet s. |
Object |
setAttribute(String name,
Object value)
Sets an attribute in the context.
|
static void |
setDefaultLogLevel(Level value)
Sets the default log level events are logged at.
|
static void |
setDefaultModletSchemaSystemId(String value)
Sets the default
http://jomc.org/modlet namespace schema system id. |
void |
setLogLevel(Level value)
Sets the log level of the context.
|
static void |
setModelContextClassName(String value)
Deprecated.
As of JOMC 1.2, replaced by class
ModelContextFactory . This method will be removed in version
2.0. |
void |
setModlets(Modlets value)
Sets the
Modlets of the context. |
void |
setModletSchemaSystemId(String value)
Sets the
http://jomc.org/modlet namespace schema system id of the context. |
abstract ModelValidationReport |
validateModel(Model model)
Validates a given
Model . |
abstract ModelValidationReport |
validateModel(String model,
Source source)
Validates a given model.
|
public ModelContext()
ModelContext
instance.public ModelContext(ClassLoader classLoader)
ModelContext
instance taking a class loader.classLoader
- The class loader of the context.getClassLoader()
public Set<String> getAttributeNames()
clearAttribute(java.lang.String)
,
getAttribute(java.lang.String)
,
getAttribute(java.lang.String, java.lang.Object)
,
setAttribute(java.lang.String, java.lang.Object)
public Object getAttribute(String name)
name
- The name of the attribute to get.name
; null
if no attribute matching name
is
found.NullPointerException
- if name
is null
.getAttribute(java.lang.String, java.lang.Object)
,
setAttribute(java.lang.String, java.lang.Object)
,
clearAttribute(java.lang.String)
public Object getAttribute(String name, Object def)
name
- The name of the attribute to get.def
- The value to return if no attribute matching name
is found.name
; def
if no such attribute is found.NullPointerException
- if name
is null
.getAttribute(java.lang.String)
,
setAttribute(java.lang.String, java.lang.Object)
,
clearAttribute(java.lang.String)
public Object setAttribute(String name, Object value)
name
- The name of the attribute to set.value
- The value of the attribute to set.name
; null
if no such value is found.NullPointerException
- if name
or value
is null
.getAttribute(java.lang.String)
,
getAttribute(java.lang.String, java.lang.Object)
,
clearAttribute(java.lang.String)
public void clearAttribute(String name)
name
- The name of the attribute to remove.NullPointerException
- if name
is null
.getAttribute(java.lang.String)
,
getAttribute(java.lang.String, java.lang.Object)
,
setAttribute(java.lang.String, java.lang.Object)
public ClassLoader getClassLoader()
null
, indicating the bootstrap class loader.findClass(java.lang.String)
,
findResource(java.lang.String)
,
findResources(java.lang.String)
public List<ModelContext.Listener> getListeners()
This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
to the returned list will be present inside the object. This is why there is no set
method for the
listeners property.
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)
public static String getDefaultModletSchemaSystemId()
http://jomc.org/modlet
namespace schema system id.
The default http://jomc.org/modlet
namespace schema system id is controlled by system property
org.jomc.modlet.ModelContext.defaultModletSchemaSystemId
holding a system id URI.
If that property is not set, the http://xml.jomc.org/modlet/jomc-modlet-1.8.xsd
default is
returned.
http://jomc.org/modlet
namespace schema.setDefaultModletSchemaSystemId(java.lang.String)
public static void setDefaultModletSchemaSystemId(String value)
http://jomc.org/modlet
namespace schema system id.value
- The new default http://jomc.org/modlet
namespace schema system id or null
.getDefaultModletSchemaSystemId()
public final String getModletSchemaSystemId()
http://jomc.org/modlet
namespace schema system id of the context.http://jomc.org/modlet
namespace schema system id of the context.getDefaultModletSchemaSystemId()
,
setModletSchemaSystemId(java.lang.String)
public final void setModletSchemaSystemId(String value)
http://jomc.org/modlet
namespace schema system id of the context.value
- The new http://jomc.org/modlet
namespace schema system id or null
.getModletSchemaSystemId()
public static Level getDefaultLogLevel()
The default log level is controlled by system property
org.jomc.modlet.ModelContext.defaultLogLevel
holding the log level to log events at by default.
If that property is not set, the WARNING
default is returned.
getLogLevel()
,
Level.parse(java.lang.String)
public static void setDefaultLogLevel(Level value)
value
- The new default level events are logged at or null
.getDefaultLogLevel()
public final Level getLogLevel()
getDefaultLogLevel()
,
setLogLevel(java.util.logging.Level)
,
isLoggable(java.util.logging.Level)
public final void setLogLevel(Level value)
value
- The new log level of the context or null
.getLogLevel()
,
isLoggable(java.util.logging.Level)
public boolean isLoggable(Level level)
level
- The level to test.true
, if messages at level
are provided to the listeners of the context; false
,
if messages at level
are not provided to the listeners of the context.NullPointerException
- if level
is null
.getLogLevel()
,
setLogLevel(java.util.logging.Level)
public void log(Level level, String message, Throwable throwable)
level
- The level of the event.message
- The message of the event or null
.throwable
- The throwable of the event null
.NullPointerException
- if level
is null
.getListeners()
,
isLoggable(java.util.logging.Level)
public final Modlets getModlets() throws ModelException
Modlets
of the context.
If no Modlets
have been set using the setModlets
method, this method calls the
findModlets
method and the processModlets
method to initialize the Modlets
of the
context.
This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object.
Modlets
of the context.ModelException
- if getting the Modlets
of the context fails.setModlets(org.jomc.modlet.Modlets)
,
findModlets(org.jomc.modlet.Modlets)
,
processModlets(org.jomc.modlet.Modlets)
public final void setModlets(Modlets value)
Modlets
of the context.value
- The new Modlets
of the context or null
.getModlets()
public Class<?> findClass(String name) throws ModelException
name
- The name of the class to search.name
or null
, if no such class is found.NullPointerException
- if name
is null
.ModelException
- if searching fails.getClassLoader()
public URL findResource(String name) throws ModelException
name
- The name of the resource to search.null
, if no such resource is found.NullPointerException
- if name
is null
.ModelException
- if searching fails.getClassLoader()
public Enumeration<URL> findResources(String name) throws ModelException
name
- The name of the resources to search.NullPointerException
- if name
is null
.ModelException
- if searching fails.getClassLoader()
@Deprecated public abstract Modlets findModlets() throws ModelException
findModlets(org.jomc.modlet.Modlets)
. This method will be
removed in JOMC 2.0.Modlets
.Modlets
found in the context or null
.ModelException
- if searching Modlets
fails.META-INF/services/org.jomc.modlet.ModletProvider
,
getModlets()
public abstract Modlets findModlets(Modlets modlets) throws ModelException
Modlets
.modlets
- The Modlets
currently being searched.Modlets
found in the context or null
.NullPointerException
- if modlets
is null
.ModelException
- if searching Modlets
fails.META-INF/services/org.jomc.modlet.ModletProvider
,
getModlets()
public abstract Modlets processModlets(Modlets modlets) throws ModelException
Modlet
s.modlets
- The Modlets
currently being processed.Modlets
or null
.NullPointerException
- if modlets
is null
.ModelException
- if processing Modlets
fails.META-INF/services/org.jomc.modlet.ModletProcessor
,
getModlets()
public abstract Model findModel(String model) throws ModelException
Model
instance.model
- The identifier of the Model
to create.Model
identified by model
.NullPointerException
- if model
is null
.ModelException
- if creating a new Model
instance fails.createServiceObject( service, ModelProvider.class )
,
ModletObject.MODEL_PUBLIC_ID
public abstract Model findModel(Model model) throws ModelException
Model
instance.model
- The Model
to populate.NullPointerException
- if model
is null
.ModelException
- if populating model
fails.createServiceObject( service, ModelProvider.class )
@Deprecated public static String getModelContextClassName()
ModelContextFactory
. This method will be removed in version
2.0.ModelContext
implementation.
The name of the class providing the default ModelContext
implementation returned by method
createModelContext(java.lang.ClassLoader)
is controlled by system property
org.jomc.modlet.ModelContext.className
. If that property is not set, the name of the
DefaultModelContext
class is returned.
ModelContext
implementation.setModelContextClassName(java.lang.String)
@Deprecated public static void setModelContextClassName(String value)
ModelContextFactory
. This method will be removed in version
2.0.ModelContext
implementation.value
- The new name of the class providing the default ModelContext
implementation or null
.getModelContextClassName()
public static ModelContext createModelContext(ClassLoader classLoader) throws ModelException
ModelContextFactory.newModelContext(java.lang.ClassLoader)
.
This method will be removed in version 2.0.ModelContext
instance.classLoader
- The class loader to create a new default ModelContext
instance with or null
,
to create a new context using the platform's bootstrap class loader.ModelContext
instance.ModelException
- if creating a new ModelContext
instance fails.getModelContextClassName()
public abstract <T> T createServiceObject(Service service, Class<T> type) throws ModelException
T
- The type of the service.service
- The service to create a new object of.type
- The class of the type of the service.service
.NullPointerException
- if service
or type
is null
.ModelException
- if creating the service object fails.ModelProvider
,
ModelProcessor
,
ModelValidator
public abstract EntityResolver createEntityResolver(String model) throws ModelException
model
- The identifier of the model to create a new SAX entity resolver of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new SAX entity resolver instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract EntityResolver createEntityResolver(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new SAX entity resolver for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new SAX entity resolver instance fails.ModletObject.PUBLIC_ID
public abstract LSResourceResolver createResourceResolver(String model) throws ModelException
model
- The identifier of the model to create a new L/S resource resolver of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new L/S resource resolver instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract LSResourceResolver createResourceResolver(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new L/S resource resolver for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new L/S resource resolver instance fails.ModletObject.PUBLIC_ID
public abstract Schema createSchema(String model) throws ModelException
model
- The identifier of the model to create a new JAXP schema instance of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new JAXP schema instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract Schema createSchema(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new JAXP schema instance for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new JAXP schema instance fails.ModletObject.PUBLIC_ID
public abstract javax.xml.bind.JAXBContext createContext(String model) throws ModelException
model
- The identifier of the model to create a new JAXB context instance of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new JAXB context instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract javax.xml.bind.JAXBContext createContext(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new JAXB context instance for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new JAXB context instance fails.ModletObject.PUBLIC_ID
public abstract javax.xml.bind.Marshaller createMarshaller(String model) throws ModelException
model
- The identifier of the model to create a new JAXB marshaller instance of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new JAXB marshaller instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract javax.xml.bind.Marshaller createMarshaller(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new JAXB marshaller instance for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new JAXB marshaller instance fails.ModletObject.PUBLIC_ID
public abstract javax.xml.bind.Unmarshaller createUnmarshaller(String model) throws ModelException
model
- The identifier of the model to create a new JAXB unmarshaller instance of.model
.NullPointerException
- if model
is null
.ModelException
- if creating a new JAXB unmarshaller instance fails.ModletObject.MODEL_PUBLIC_ID
@Deprecated public abstract javax.xml.bind.Unmarshaller createUnmarshaller(URI publicId) throws ModelException
publicId
- The public identifier URI to create a new JAXB unmarshaller instance for.publicId
.NullPointerException
- if publicId
is null
.ModelException
- if creating a new JAXB unmarshaller instance fails.ModletObject.PUBLIC_ID
public abstract Model processModel(Model model) throws ModelException
Model
.model
- The Model
to process.Model
.NullPointerException
- if model
is null
.ModelException
- if processing model
fails.createServiceObject( service, ModelProcessor.class )
public abstract ModelValidationReport validateModel(Model model) throws ModelException
Model
.model
- The Model
to validate.NullPointerException
- if model
is null
.ModelException
- if validating the modules fails.createServiceObject( service, ModelValidator.class )
,
ModelValidationReport.isModelValid()
public abstract ModelValidationReport validateModel(String model, Source source) throws ModelException
model
- The identifier of the Model
to use for validating source
.source
- A source providing the model to validate.NullPointerException
- if model
or source
is null
.ModelException
- if validating the model fails.createSchema(java.lang.String)
,
ModelValidationReport.isModelValid()
,
ModletObject.MODEL_PUBLIC_ID
Copyright © 2005–2014 The JOMC Project. All rights reserved.