com.orchestranetworks.schema
Class SchemaLocation

java.lang.Object
  extended bycom.orchestranetworks.schema.SchemaLocation

public abstract class SchemaLocation
extends Object

Identifies a schema location, which can be either based on a URL (standard notation) or based on a EBX.Platform module.

When a location is based on a module, this implies that the schema is packaged in an EBX.Platform module (which is commonly a Web Application). This approach has several benefits:


Method Summary
static SchemaLocation forLocation(String aBaseOrNull, String aURI)
          Returns a reference to a schema that is not packaged inside an EBX.Platform module.
static SchemaLocation forPathInModule(String aPathInModule, String aModuleName)
          Returns a reference to a schema that is packaged inside an EBX.Platform module.
abstract  File getFileOrNull()
          If this location is able to be resolved to a file, returns this file, otherwise returns null.
abstract  InputStream getInputStream()
          Returns a stream for reading the content of the corresponding schema.
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 schemas that are specifically managed by EBX.Platform.
abstract  boolean isURI()
          Returns true if this instance is a URL-based location.
abstract  SchemaLocation resolve(String aURI)
          Given the current instance that serves as the base name, this method returns the most accurate locator that constitutes the real target.
abstract  String toStringInfo(Locale aLocale)
          Returns a information string that identifies the location.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forLocation

public static final SchemaLocation forLocation(String aBaseOrNull,
                                               String aURI)
                                        throws IllegalArgumentException
Returns a reference to a schema that is not packaged inside an EBX.Platform module.

Warning : beyond simple test cases, it is generally recommended to use schemas that are packaged inside EBX.Platform modules (see forPathInModule(String, String)).

The actual location of the schema will be :

Parameters:
aBaseOrNull - used only if aURI is relative
aURI - an absolute or relative URI
Throws:
IllegalArgumentException - if an argument is not a well-formed URI
See Also:
RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax

forPathInModule

public static final SchemaLocation forPathInModule(String aPathInModule,
                                                   String aModuleName)
Returns a reference to a schema that is packaged inside an EBX.Platform module.

Example:

 SchemaLocator sname = SchemaLocator.forPathInModule(
    "/WEB-INF/schemas/main.xsd",
    "sample");
 
where "sample" is the module name.

Parameters:
aPathInModule - path of the schema inside the module (see example above)
aModuleName - identifies the module that contains the schema (the name of a module is defined in the document /WEB-INF/ebx/module.xml, at element /module/name).

getFileOrNull

public abstract File getFileOrNull()
If this location is able to be resolved to a file, returns this file, otherwise returns null.

Generally, a location is able to resolve to a file if this location is URL-based with protocol file://, or if this location is module-based and the application server is able to translate the module location to an actual file.

See Also:
ServletContext.getRealPath(java.lang.String)

getInputStream

public abstract InputStream getInputStream()
                                    throws Exception
Returns a stream for reading the content of the corresponding schema.

Throws:
Exception

getModuleName

public 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. The name of a module is defined in the document /WEB-INF/ebx/module.xml, at element /module/name.


isReserved

public abstract boolean isReserved()
Returns true for schemas that are specifically managed by EBX.Platform.


isPackagedInModule

public abstract boolean isPackagedInModule()
Returns true if this instance is a module-based location.


isURI

public abstract boolean isURI()
Returns true if this instance is a URL-based location.


resolve

public abstract SchemaLocation resolve(String aURI)
                                throws IllegalArgumentException
Given the current instance that serves as the base name, this method returns the most accurate locator that constitutes the real target.

Throws:
IllegalArgumentException - If the given string violates RFC 2396

toStringInfo

public abstract String toStringInfo(Locale aLocale)
Returns a information string that identifies the location.

Parameters:
aLocale - if null, use the default locale (english).


(report a bug)
EBX.Platform 4.5.2 [0601:0004]
Copyright Orchestra Networks 2000-2008. All rights reserved.