public abstract class SchemaLocation extends Object
When a location is based on an EBX® module, this implies that the data model is packaged inside the specified module (which is commonly a web application). This approach has several benefits:
EBX® defines specific URNs to identify a data model location. The following table describe all supported URNs.
URN | Description |
---|---|
urn:ebx:publication: |
Identifies an embedded data model, where
is the name of a
publication that was created by publishing an embedded data model in the data model assistant.
|
urn:ebx:module: |
Identifies a packaged data model inside a module, where is
the name
of the module containing the data model and is the path of
the data model
inside the module.
|
As the above URNs are specific to EBX®, they will not be able to be resolved by external tools. Thus, when using an external editor to edit any XML Schema Documents that contain these URNs, the editor may report errors. To workaround this issue, you can manually substitute the physical locations of the targeted XML Schema documents for the URNs during editing of the XML Schema document using an external editor.
Modifier and Type | Method and Description |
---|---|
static SchemaLocation |
forLocation(String aBaseOrNull,
String aURI)
Returns a reference to an embedded data model (not packaged inside an EBX® module).
|
abstract String |
format()
Returns a string representation of the location of this data model.
|
static SchemaLocation |
forPathInModule(String aPathInModule,
String aModuleName)
Returns a reference to a data model that is packaged inside an EBX® module.
|
abstract File |
getFileOrNull()
If this location resolves to a file, returns that file, otherwise
returns
null . |
abstract InputStream |
getInputStream()
Deprecated.
This method has been replaced by
getInputStream(Repository) . |
abstract InputStream |
getInputStream(Repository aRepository)
Returns a stream for reading the content of the corresponding data model.
|
abstract String |
getModuleName()
Returns the name of the module that contains the resource or, if
this instance is URI based, returns the default module name.
|
abstract boolean |
isPackagedInModule()
Returns
true if this instance is a module-based location. |
abstract boolean |
isReserved()
Returns
true for data models that are managed by
EBX®. |
abstract boolean |
isURI()
Returns
true if this instance is a URL-based location. |
static SchemaLocation |
parse(String aURN)
Returns a
SchemaLocation based on the string specified. |
abstract SchemaLocation |
resolve(String aURI)
Returns the most accurate locator constituting the real target
with this current instance as the base name.
|
abstract String |
toStringInfo(Locale aLocale)
Returns a string that identifies this location.
|
public static final SchemaLocation forLocation(String aBaseOrNull, String aURI) throws IllegalArgumentException
Warning: Beyond simple test cases, it is generally recommended to use data models
that are packaged inside EBX® modules (see forPathInModule(String, String)
).
The location of the data model is determined as follows:
aURI
is absolute, the location is aURI
.aURI
is relative, it uses aBaseOrNull
as the base URI for
resolving the location. If aBaseOrNull
is null
, it uses the
current user directory, as defined by File
, as the base URI.aBaseOrNull
- used only if aURI
is relativeaURI
- an absolute or relative URIIllegalArgumentException
- if an argument is not a well-formed URIpublic static final SchemaLocation forPathInModule(String aPathInModule, String aModuleName)
SchemaLocation dataModelLocation = SchemaLocation.forPathInModule( "/WEB-INF/schemas/main.xsd", "sample");where "sample" is the module name.
aPathInModule
- path of the data model inside the module (see example above).
The path must be specified according to the rules detailed in
ServletContext.getResource(String)
).aModuleName
- identifies the module that contains the data model (the
name of a module is defined in the document /WEB-INF/ebx/module.xml
,
by the element /module/name
).public abstract File getFileOrNull()
null
.
Generally, a location is able to resolve to a file if this location is URL-based
with the protocol file:
, or if this location is module-based and
the application server is able to translate the module location to an actual file.
public abstract InputStream getInputStream() throws Exception
getInputStream(Repository)
.repository
directory, since those
must be resolved in the context of a repository.Exception
public abstract InputStream getInputStream(Repository aRepository) throws Exception
repository
directory .Exception
public abstract String getModuleName()
/WEB-INF/ebx/module.xml
,
by the element /module/name
.IllegalStateException
- if this method is called on an embedded
data model. Embedded data models must be resolved in the context of
a repository.public abstract boolean isReserved()
true
for data models that are managed by
EBX®.public abstract boolean isPackagedInModule()
true
if this instance is a module-based location.public abstract boolean isURI()
true
if this instance is a URL-based location.public abstract SchemaLocation resolve(String aURI) throws IllegalArgumentException
IllegalArgumentException
- If the given string violates RFC 2396public abstract String format()
parse(String)
,
SchemaLocation
public static final SchemaLocation parse(String aURN)
SchemaLocation
based on the string specified.
The specified string must have been generated by format()
.
IllegalArgumentException
- if the specified URN does not
correspond to a supported EBX® URN or if the specified
URN correspond to a relative path.format()