|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.exln.stylus.io.StylusFileFactory
Defines a factory API that enables applications to read and write
data streams using any custom file system which implements the
StylusFile interface.
To use this class:
registerScheme(String, String))
have these requirements:
StylusFile sf =
StylusFileFactory.getFactory().createStylusFile(String url);
The resulting StylusFile object can be used to access the specified url using one of
the built-in protocols listed above. See StylusFile and createStylusFile.
If you have implemented a custom file system and wish to use this class to access it,
you must register your custom file system as follows, before calling createStylusFile:
StylusFileFactory.getFactory().registerScheme(String scheme, String className);
For more details, see registerScheme.
| Method Summary | |
StylusFile |
createStylusFile(String url)
Create a StylusFile object for file access through a custom file system. |
StylusFile |
createStylusFile(String url,
InputStream is)
Create a StylusFile object for file access through a custom file system. |
static StylusFileFactory |
getFactory()
Get the singleton StylusFileFactory. |
void |
registerScheme(String scheme,
String className)
Register a scheme name and its associated StylusFile class name. |
Source |
resolve(String URI,
String URIBase)
Resolve a URI and return a Source which can
be used to read data from the URI. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static StylusFileFactory getFactory()
StylusFileFactory. If the factory does not yet exist,
it will be created and initialized.
public StylusFile createStylusFile(String url)
throws IOException
StylusFile object for file access through a custom file system.
The parameter String url is parsed to get the scheme prefix. The scheme is
used to select a custom file system which can access files via that protocol.
The scheme should either be a built-in scheme or should have been registered
with registerScheme.
The scheme:// prefix is then removed from the url and the rest is passed as
the String parameter to the constructor for that
StylusFile
class for the selected custom file system.
The StylusFile object returned by createStylusFile can be used to:
StylusFile.getInputStream() or StylusFile.copyToFile(String)StylusFile.getOutputStream() or StylusFile.copyToFile(String)StylusFile.
StylusFile object for the class which was registered to the scheme.
IOException - in any of the following conditions:registerScheme StylusFile
public StylusFile createStylusFile(String url,
InputStream is)
throws IOException
StylusFile object for file access through a custom file system.
This method differs from createStylusFile(String) in that it invokes a
2 argument constructor (String, InputStream). This is useful if the
StylusFile object being created is an adapter or converter which
will read input from the InputStream. The application will normally get the
result of the conversion by calling getInputStream() and reading the converted
data from that stream.
The parameter String url is parsed to get the scheme prefix. The scheme is
used to select a custom file system which can access files via that protocol.
The scheme should either be a built-in scheme or should have been registered
with registerScheme.
The scheme:// prefix is then removed from the url and the rest is passed as
the String parameter to the constructor for that
StylusFile
class for the selected custom file system.
The StylusFile object returned by createStylusFile can be used to:
StylusFile.getInputStream() or StylusFile.copyToFile(String)StylusFile.
StylusFile object for the class which was registered to the scheme.
IOException - in any of the following conditions:registerScheme StylusFile
public void registerScheme(String scheme,
String className)
throws IllegalArgumentException
StylusFile class name.
The method StylusFileFactory.createStylusFile examines the scheme: part of its URL
parameter to know which class to instantiate. StylusFileFactory has
a built-in association from the
scheme: to the class name to be instantiated. This built-in list is:
registerScheme method.
StylusFile) and wish to use that class through the StylusFileFactory API, you must register
the association between a scheme: and your class name.
You do this by calling the registerScheme method. You must call it exactly once for each
scheme you wish to register.
scheme - The scheme you wish to register.className - The name of the class which implements StylusFile and which
should be instantiated when a URL with the registered scheme is passed to the
createStylusFile method.
IllegalArgumentException - if
public Source resolve(String URI,
String URIBase)
throws TransformerException
Source which can
be used to read data from the URI. The Source returned by this method
is a StreamSource. To get the data, cast it as a StreamSource and call
getInputStream().
resolve in interface URIResolverURI - The URI to be resolved.URIBase - The base URI in effect when the URI was encountered.
TransformerException - If the URI is malformed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||