org.ckkloverdos.source
Class SourceSkeleton

java.lang.Object
  extended by org.ckkloverdos.source.SourceSkeleton
All Implemented Interfaces:
ISource
Direct Known Subclasses:
FileSource, InputStreamSource, RcSource, StringSource

public abstract class SourceSkeleton
extends java.lang.Object
implements ISource

Basic, InputStream- based implementation of ISource, intended to be subclassed.

Author:
Christos KK Loverdos

Field Summary
protected  java.io.InputStream is
           
protected  java.lang.String name
           
protected  SourceType type
           
protected  boolean valid
           
 
Constructor Summary
protected SourceSkeleton()
           
protected SourceSkeleton(java.lang.String name, SourceType type, java.io.InputStream is)
           
 
Method Summary
 java.lang.String getDescription()
          Return the description of this source.
 java.io.InputStream getInputStream()
          Get an input stream for this source.
 java.lang.String getName()
          Return the name of this source.
 java.io.Reader getReader()
          Get a reader for the contents of this source.
 java.io.Reader getReader(java.lang.String encoding)
          Get a reader for the contents of this source.
 java.lang.String getString()
          Get a string from the contents of this source.
 java.lang.String getString(java.lang.String encoding)
          Get a string from the contents of this source.
 SourceType getType()
          Return the type of this source.
 boolean isText()
          Return true if the type of this source is text.
 boolean isValid()
          Return true iff any of the ISource.getInputStream(), ISource.getString(), ISource.getReader() methods will return a non-null object.
protected  void setInputStream(java.io.InputStream is)
           
protected  void setName(java.lang.String name)
           
protected  void setType(SourceType type)
           
protected  void setValid(boolean valid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

type

protected SourceType type

is

protected java.io.InputStream is

valid

protected boolean valid
Constructor Detail

SourceSkeleton

protected SourceSkeleton()

SourceSkeleton

protected SourceSkeleton(java.lang.String name,
                         SourceType type,
                         java.io.InputStream is)
Method Detail

isValid

public boolean isValid()
Description copied from interface: ISource
Return true iff any of the ISource.getInputStream(), ISource.getString(), ISource.getReader() methods will return a non-null object.

Specified by:
isValid in interface ISource

getName

public java.lang.String getName()
Description copied from interface: ISource
Return the name of this source.

Specified by:
getName in interface ISource

getDescription

public java.lang.String getDescription()
Description copied from interface: ISource
Return the description of this source.

Specified by:
getDescription in interface ISource

getType

public SourceType getType()
Description copied from interface: ISource
Return the type of this source.

Specified by:
getType in interface ISource

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: ISource
Get an input stream for this source.

Specified by:
getInputStream in interface ISource
Throws:
java.io.IOException

isText

public boolean isText()
Description copied from interface: ISource
Return true if the type of this source is text.

Specified by:
isText in interface ISource
Returns:
true iff getType().isText() returns true.

getString

public java.lang.String getString()
                           throws java.io.IOException
Description copied from interface: ISource
Get a string from the contents of this source. The contents are interpeted using the default StringUtil.UTF8 encoding.

Specified by:
getString in interface ISource
Throws:
java.io.IOException

getReader

public java.io.Reader getReader()
                         throws java.io.IOException
Description copied from interface: ISource
Get a reader for the contents of this source. The contents are interpeted using the default StringUtil.UTF8 encoding.

Specified by:
getReader in interface ISource
Throws:
java.io.IOException

getString

public java.lang.String getString(java.lang.String encoding)
                           throws java.io.IOException
Description copied from interface: ISource
Get a string from the contents of this source. The contents are interpeted using the provided encoding.

Specified by:
getString in interface ISource
Throws:
java.io.IOException

getReader

public java.io.Reader getReader(java.lang.String encoding)
                         throws java.io.IOException
Description copied from interface: ISource
Get a reader for the contents of this source. The contents are interpeted using the provided encoding.

Specified by:
getReader in interface ISource
Throws:
java.io.IOException

setValid

protected void setValid(boolean valid)

setInputStream

protected void setInputStream(java.io.InputStream is)

setName

protected void setName(java.lang.String name)

setType

protected void setType(SourceType type)


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.