org.ckkloverdos.source
Class StringSource

java.lang.Object
  extended by org.ckkloverdos.source.SourceSkeleton
      extended by org.ckkloverdos.source.StringSource
All Implemented Interfaces:
ISource

public class StringSource
extends SourceSkeleton

A ISource whose contents come directly from a string. The source is valid iff the underlying string is not null.

Author:
Christos KK Loverdos

Field Summary
 
Fields inherited from class org.ckkloverdos.source.SourceSkeleton
is, name, type, valid
 
Constructor Summary
StringSource(java.lang.String name, SourceType type, java.lang.String theString)
           
StringSource(java.lang.String name, SourceType type, java.lang.StringBuffer theString)
           
 
Method Summary
 java.io.InputStream getInputStream()
          Returns an input stream obtained from the UTF8 representation of the underlying string.
 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.
 
Methods inherited from class org.ckkloverdos.source.SourceSkeleton
getDescription, getName, getType, isText, isValid, setInputStream, setName, setType, setValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringSource

public StringSource(java.lang.String name,
                    SourceType type,
                    java.lang.String theString)

StringSource

public StringSource(java.lang.String name,
                    SourceType type,
                    java.lang.StringBuffer theString)
Method Detail

getReader

public java.io.Reader getReader()
                         throws java.io.UnsupportedEncodingException
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
Overrides:
getReader in class SourceSkeleton
Throws:
java.io.UnsupportedEncodingException

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
Overrides:
getReader in class SourceSkeleton
Throws:
java.io.IOException

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
Overrides:
getString in class SourceSkeleton
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
Overrides:
getString in class SourceSkeleton
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream obtained from the UTF8 representation of the underlying string.

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


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