|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dante.util.framework.AbstractFactory
de.dante.extex.scanner.stream.TokenStreamFactory
This is the factory to provide an instance of a
TokenStream
.
Like any good factory it is controlled by its configuration.
Mainly the configuration needs to specify which class to use for the TokenStream. The name of the class is given as the argument class as shown below.
<Scanner class="the.pack.age.TheClass"/>
The class given must implement the interface
TokenStream
. In addition
an appropriate constructor is required:
public TheClass(Configuration config, Reader reader, Boolean isFile, final String theSource) throws IOException
If the Token stream is fed from a file then the additional parameter buffersize is taken into account. This parameter is optional. Its usage can look as follows:
<Scanner class="the.pack.age.TheClass" buffersize="0"/>The value given is a number. If this number is positive then it is interpreted as the size of the buffer for the file reading operation. If it is 0 or empty then no buffer will be used. If it is negative, then the default buffer size will be used.
In addition to the class for the Token stream the reader class can be specified for the case that reading from a file is requested. In this case the mapping from bytes to characters according to an encoding. The name is given as the parameter reader as shown below:
<Scanner class="the.pack.age.TheClass" reader="another.pack.age.TheReaderClass"/>
Note that the attribute reader is optional. If none is given or the value is the empty string then java.io.InputStreamReader is used instead.
Observer
s can be registered for
several events:
Constructor Summary | |
TokenStreamFactory(Configuration theConfiguration,
java.lang.String tag)
Creates a new object. |
Method Summary | |
ResourceFinder |
getResourceFinder()
Returns the file finder. |
TokenStream |
newInstance(java.lang.CharSequence line)
Provide a new instance of a token stream reading from a string. |
TokenStream |
newInstance(java.io.Reader reader)
Provide a new instance of a token stream reading from a Reader. |
TokenStream |
newInstance(java.lang.String name,
java.lang.String type,
java.lang.String encoding)
Provide a new instance of a token stream reading from a file or other resource. |
void |
register(StreamDecorator decorator)
Register a input stream decorator to be applied for each token stream originated at a resource. |
void |
registerObserver(OpenFileObserver observer)
Register an expand observer for later use. |
void |
registerObserver(OpenReaderObserver observer)
Register an open reader observer for later use. |
void |
registerObserver(OpenStringObserver observer)
Register an expand observer for later use. |
void |
setOptions(TokenStreamOptions options)
Setter for options. |
void |
setResourceFinder(ResourceFinder finder)
Setter for the file finder. |
Methods inherited from class de.dante.util.framework.AbstractFactory |
configure, configure, createInstance, createInstance, createInstance, createInstanceForConfiguration, createInstanceForConfiguration, createInstanceForConfiguration, enableLogging, enableLogging, getConfiguration, getLogger, reconnect, selectConfiguration |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TokenStreamFactory(Configuration theConfiguration, java.lang.String tag) throws ConfigurationException
theConfiguration
- the configuration to usetag
- the tag name of the sub-configuration to use
ConfigurationException
- in case of an error in the configurationMethod Detail |
public ResourceFinder getResourceFinder()
public TokenStream newInstance(java.lang.CharSequence line) throws ConfigurationException
line
- the line of input to read from
ConfigurationException
- in case of an error in the configurationpublic TokenStream newInstance(java.io.Reader reader) throws ConfigurationException
reader
- the reader to get new characters from
ConfigurationException
- in case of an error in the configurationpublic TokenStream newInstance(java.lang.String name, java.lang.String type, java.lang.String encoding) throws ConfigurationException
name
- the name of the file to be readtype
- the type of the file to be readencoding
- the name of the encoding to use
null
if the resource could not
be located
ConfigurationException
- in case of an error in the configurationpublic void register(StreamDecorator decorator)
decorator
- the additional decoratorpublic void registerObserver(OpenFileObserver observer)
OpenFileObservable
registerObserver
in interface OpenFileObservable
observer
- the observer to be registeredOpenFileObservable.registerObserver(
de.dante.extex.scanner.stream.observer.file.OpenFileObserver)
public void registerObserver(OpenReaderObserver observer)
OpenReaderObservable
registerObserver
in interface OpenReaderObservable
observer
- the observer to be registeredOpenReaderObservable.registerObserver(
de.dante.extex.scanner.stream.observer.reader.OpenReaderObserver)
public void registerObserver(OpenStringObserver observer)
OpenStringObservable
registerObserver
in interface OpenStringObservable
observer
- the observer to be registeredOpenStringObservable.registerObserver(
de.dante.extex.scanner.stream.observer.string.OpenStringObserver)
public void setOptions(TokenStreamOptions options)
options
- the options to set.public void setResourceFinder(ResourceFinder finder)
finder
- the new file finder
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |