org.specrunner.source.core
Class AbstractSourceFactory

java.lang.Object
  extended by org.specrunner.source.core.EncodedImpl
      extended by org.specrunner.source.core.AbstractSourceFactory
All Implemented Interfaces:
Serializable, IEncoded, ISourceFactory, IResetable
Direct Known Subclasses:
SourceFactoryHtml

public abstract class AbstractSourceFactory
extends EncodedImpl
implements ISourceFactory

Abstraction to readers.

Author:
Thiago Santos
See Also:
Serialized Form

Field Summary
protected static ICache<String,nu.xom.Document> cache
          Cache of files.
protected static ICache<String,INamespaceInfo> namespace
          Cache of namespace information.
 
Fields inherited from interface org.specrunner.source.IEncoded
DEFAULT_ENCODING, FEATURE_ENCODING
 
Constructor Summary
AbstractSourceFactory()
           
 
Method Summary
protected  nu.xom.Document addDoctype(nu.xom.Document document)
          Adds the XHTML Doctype to the document if none is specified.
protected  String cleanTarget(String target)
          Clean the target name.
protected abstract  nu.xom.Document fromTarget(URI uri, String target, String encoding)
          Load file from source.
 void initialize()
          Initialize something.
protected  boolean isFile(URI uri, String target)
          Check if a target is file.
 ISource newSource(Object source)
          Creates a source from a String.
 
Methods inherited from class org.specrunner.source.core.EncodedImpl
getEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.specrunner.source.IEncoded
getEncoding
 

Field Detail

cache

protected static ICache<String,nu.xom.Document> cache
Cache of files.


namespace

protected static ICache<String,INamespaceInfo> namespace
Cache of namespace information.

Constructor Detail

AbstractSourceFactory

public AbstractSourceFactory()
Method Detail

initialize

public void initialize()
Description copied from interface: IResetable
Initialize something.

Specified by:
initialize in interface IResetable

newSource

public ISource newSource(Object source)
                  throws SourceException
Description copied from interface: ISourceFactory
Creates a source from a String.

Specified by:
newSource in interface ISourceFactory
Parameters:
source - The source of specification.
Returns:
The source.
Throws:
SourceException - On creation errors.

fromTarget

protected abstract nu.xom.Document fromTarget(URI uri,
                                              String target,
                                              String encoding)
                                       throws SourceException
Load file from source.

Parameters:
uri - The source URI.
target - The source name.
encoding - The encoding.
Returns:
The document.
Throws:
SourceException - On load errors.

isFile

protected boolean isFile(URI uri,
                         String target)
Check if a target is file.

Parameters:
uri - A URI.
target - The target.
Returns:
true, if is file, false, otherwise.

cleanTarget

protected String cleanTarget(String target)
                      throws SourceException
Clean the target name.

Parameters:
target - The target.
Returns:
The target normalized.
Throws:
SourceException - On cleanup errors.

addDoctype

protected nu.xom.Document addDoctype(nu.xom.Document document)
Adds the XHTML Doctype to the document if none is specified.

Parameters:
document - The document.
Returns:
The document itself.


Copyright © 2014. All rights reserved.