org.specrunner.source.core
Class SourceImpl

java.lang.Object
  extended by org.specrunner.source.core.SourceImpl
All Implemented Interfaces:
IEncoded, ISource

public class SourceImpl
extends Object
implements ISource

The default implementation.

Author:
Thiago Santos

Field Summary
protected  nu.xom.Document document
          The document.
protected  ISourceFactory factory
          The source factory used to create it.
protected  File file
          The source as file.
protected  IDocumentLoader loader
          A document loader.
protected  IResourceManager manager
          The resource manager.
protected  INamespaceInfo namespaceInfo
          The namespace info.
protected  INamespaceLoader nsloader
          A namespace loader.
protected  String string
          The source as String.
protected  URI uri
          The source as URI.
 
Fields inherited from interface org.specrunner.source.IEncoded
DEFAULT_ENCODING, FEATURE_ENCODING
 
Constructor Summary
SourceImpl(String encoding, String string, ISourceFactory factory, IDocumentLoader loader, INamespaceLoader nsloader)
          Creates a source instance.
 
Method Summary
 boolean equals(Object obj)
           
 nu.xom.Document getDocument()
          The specification document.
 String getEncoding()
          Return the encoding.
 ISourceFactory getFactory()
          The source factory.
 File getFile()
          The source reference as a java.io.File instance.
 IResourceManager getManager()
          A resource manager.
 INamespaceInfo getNamespaceInfo()
          Get meta-information associated to namespace.
 List<nu.xom.Element> getScenarios()
          The specification scenarios.
 String getString()
          The source reference as String.
 URI getURI()
          The source reference as a java.net.URI instance.
 int hashCode()
           
 String relative(ISource other)
          Returns the reference as a relative String.
 ISource resolve(ISource other)
          The relative source resolved.
protected  List<nu.xom.Element> toElements(nu.xom.Nodes ns)
          Convert to a sequence of elements.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

string

protected String string
The source as String.


file

protected File file
The source as file.


uri

protected URI uri
The source as URI.


factory

protected ISourceFactory factory
The source factory used to create it.


manager

protected IResourceManager manager
The resource manager.


loader

protected IDocumentLoader loader
A document loader.


document

protected nu.xom.Document document
The document.


nsloader

protected INamespaceLoader nsloader
A namespace loader.


namespaceInfo

protected INamespaceInfo namespaceInfo
The namespace info.

Constructor Detail

SourceImpl

public SourceImpl(String encoding,
                  String string,
                  ISourceFactory factory,
                  IDocumentLoader loader,
                  INamespaceLoader nsloader)
Creates a source instance.

Parameters:
encoding - The source encoding.
string - The source reference.
factory - The factory.
loader - The document loader.
nsloader - The namespace information loader.
Method Detail

getEncoding

public String getEncoding()
Description copied from interface: IEncoded
Return the encoding.

Specified by:
getEncoding in interface IEncoded
Returns:
The encoding charset.

getString

public String getString()
Description copied from interface: ISource
The source reference as String.

Specified by:
getString in interface ISource
Returns:
The source as String.

getFile

public File getFile()
Description copied from interface: ISource
The source reference as a java.io.File instance.

Specified by:
getFile in interface ISource
Returns:
A file, if possible, otherwise null, if a File representation do not exist.

getURI

public URI getURI()
Description copied from interface: ISource
The source reference as a java.net.URI instance.

Specified by:
getURI in interface ISource
Returns:
A uri, if possible, otherwise null, if a URI representation do not exist.

getFactory

public ISourceFactory getFactory()
Description copied from interface: ISource
The source factory.

Specified by:
getFactory in interface ISource
Returns:
The source factory used to create the source.

resolve

public ISource resolve(ISource other)
                throws SourceException
Description copied from interface: ISource
The relative source resolved.

Specified by:
resolve in interface ISource
Parameters:
other - The reference to be opened.
Returns:
The relative reference.
Throws:
SourceException - On creation errors.

relative

public String relative(ISource other)
Description copied from interface: ISource
Returns the reference as a relative String.

Specified by:
relative in interface ISource
Parameters:
other - The reference to be compared.
Returns:
The relative reference as String.

getManager

public IResourceManager getManager()
Description copied from interface: ISource
A resource manager. Responsible for handling JavaScripts, CSS, etc, related to the specification.

Specified by:
getManager in interface ISource
Returns:
The resource reference.

getDocument

public nu.xom.Document getDocument()
                            throws SourceException
Description copied from interface: ISource
The specification document.

Specified by:
getDocument in interface ISource
Returns:
The specification as document.
Throws:
SourceException - On creation error.

getNamespaceInfo

public INamespaceInfo getNamespaceInfo()
                                throws SourceException
Description copied from interface: ISource
Get meta-information associated to namespace.

Specified by:
getNamespaceInfo in interface ISource
Returns:
The info object.
Throws:
SourceException - On namespace info reading.

getScenarios

public List<nu.xom.Element> getScenarios()
                                  throws SourceException
Description copied from interface: ISource
The specification scenarios.

Specified by:
getScenarios in interface ISource
Returns:
The specification as document.
Throws:
SourceException - On creation error.

toElements

protected List<nu.xom.Element> toElements(nu.xom.Nodes ns)
Convert to a sequence of elements.

Parameters:
ns - Nodes.
Returns:
A list of elements.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.