IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.base
Class TagInputStream

java.lang.Object
  extended bycom.ibm.btt.base.TagInputStream
Direct Known Subclasses:
TagOutputStream

public class TagInputStream
extends java.lang.Object

This class is a Stream able to deal with individual tags and groups of them. It has a Vector with the tags and a table with a pairs-name index to locate them in the Vectors table more quickly.


Field Summary
protected  boolean _isSimpleTag
           
protected  char[] _tagCharArray
           
protected  int _tagLength
           
protected  java.io.BufferedReader bufferedReader
           
protected static int DEFAULT_TAG_SIZE
           
protected static int DEFAULT_TAG_SIZE_INCREMENT
           
 java.io.InputStream inputStream
           
 java.lang.String sgmlFile
           
 Hashtable tagIndexes
           
 
Constructor Summary
TagInputStream()
          This constructor creates a TagInputStream object.
TagInputStream(java.io.BufferedInputStream aIniStream, java.lang.String kindOfFile)
          This constructor creates a TagInputStream object to read from aIniStream.
TagInputStream(java.io.BufferedInputStream aIniStream, java.lang.String kindOfFile, boolean isSelfDefined)
          This constructor creates a TagInputStream object to read from aIniStream.
TagInputStream(java.lang.String fileName, java.lang.String kindOfFile)
          This constructor creates a TagInputStream object to read from the specified file.
TagInputStream(java.net.URL aURL, java.lang.String kindOfFile)
          This constructor creates a TagInputStream object to read from the specified file.
TagInputStream(java.util.zip.ZipInputStream zip, java.lang.String fileName, java.lang.String kindOfFile)
          This constructor creates a TagInputStream object to read from the specified zip file.
 
Method Summary
 void close()
          Closes the stream thereby releasing the file.
 void createComposedTag(Tag aTag, java.lang.String fileTitle, ProgressIndicator pi, boolean isXmlFile)
          Adds the subtags to aTag to create a composed tag.
 void createComposedTag(Tag aTag, java.lang.String fileTitle, ProgressIndicator pi, boolean isXmlFile, Tag.TagStringReader aReader)
          Adds the subtags to aTag to create a composed tag.
 Tag first()
          Returns the first tag in the stream.
 java.util.Date getDateCreationFile()
          Returns the date the XML file corresponding to this TagInputStream was created or last modified.
 Externalizer getExternalizer()
          Returns the Externalizer of this stream.
 java.io.InputStream getInputStream()
          Returns the inputStream.
 java.lang.String getKindOfFile()
          Gets the kind of file to read
 java.lang.String getSgmlFile()
          Returns the name of the XML file that this stream reads.
 java.lang.String getSgmlFileTitle(java.lang.String aSgmlFile)
          Returns the title (name) of the XML file (without its path)
 Tag getTag(int anInt)
          Returns a Tag in a position.
 Hashtable getTagIndexes()
          Returns the positions of the tags in the file (option file) or the tags themselves (option memory).
 Vector getTags()
          Returns the tags.
protected  java.lang.Object[] getTagString(int aPosition)
          Reads a tag in the file starting in the position aPosition.
protected  void getTagString(int aPosition, boolean isXmlFile)
          Reads a tag in the file starting in the position aPosition
 void initialize(java.io.BufferedInputStream aIniStream, java.lang.String kindOfFile)
          Initializes the stream.
 void initialize(java.io.BufferedInputStream aIniStream, java.lang.String kindOfFile, boolean isSelfDefined)
          Initializes the stream.
 void initialize(java.lang.String fileName, java.lang.String kindOfFile)
          Initializes the stream that reads the specified file.
 void initialize(java.net.URL aURL, java.lang.String kindOfFile)
          Initializes the stream reading from the URL.
 void initialize(java.util.zip.ZipInputStream zip, java.lang.String fileName, java.lang.String kindOfFile)
          Initializes the stream that reads the specified zip file.
 boolean isDecorator(Tag aTag)
          Returns true if aTag is a decorator.
 boolean isSimpleTag(Tag aTag)
          Returns true if aTag is a simple tag.
 Tag last()
          Returns the last tag.
 int read()
          Reads a character from the bufferedReader and returns it as an int.
 java.lang.Object readObject(int index)
          Returns the tag (cast to an Object) at the given index.
 Tag readTag(int index)
          Returns the Tag at the specified index.
 void removeTagWithId(java.lang.String tagId)
          Removes the tag with id tagId from this TagInputStream.
 void reset(java.lang.String tagId, Tag newTagState)
          Sets the attributes of the tag with the id tagId with the attributes of the tag passed by parameter.
protected  void setDate(java.lang.String fileName)
          Sets the date the XML file corresponding to this TagInputStream was created.
protected  void setDate(java.net.URLConnection url)
          Sets the date the URL corresponding to this TagInputStream was created.
protected  void setDate(java.util.zip.ZipEntry entry)
          Sets the date the zip file corresponding to this TagInputStream was created.
 void setExternalizer(Externalizer aExternalizer)
          Sets the externalizer.
 void setKindOfFile(java.lang.String aKindOfFile)
          Sets the kind of file to read.
 void setSgmlFile(java.lang.String aFileName)
          Sets the SGML file.
 void setTagIndexes(Hashtable aHashtable)
          Sets the indexes of the tags in the file (option file).
 void setTags(Vector aVector)
          Sets the tags.
 void skip(long aLong)
          This method skips aLong amount of characters in the stream
 Tag tagWithId(java.lang.String aString)
          Returns the tag with the specified ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStream

public java.io.InputStream inputStream

sgmlFile

public java.lang.String sgmlFile

tagIndexes

public Hashtable tagIndexes

DEFAULT_TAG_SIZE

protected static final int DEFAULT_TAG_SIZE
See Also:
Constant Field Values

DEFAULT_TAG_SIZE_INCREMENT

protected static final int DEFAULT_TAG_SIZE_INCREMENT
See Also:
Constant Field Values

bufferedReader

protected java.io.BufferedReader bufferedReader

_tagCharArray

protected char[] _tagCharArray

_tagLength

protected int _tagLength

_isSimpleTag

protected boolean _isSimpleTag
Constructor Detail

TagInputStream

public TagInputStream()
This constructor creates a TagInputStream object.


TagInputStream

public TagInputStream(java.io.BufferedInputStream aIniStream,
                      java.lang.String kindOfFile,
                      boolean isSelfDefined)
               throws java.io.IOException
This constructor creates a TagInputStream object to read from aIniStream.


TagInputStream

public TagInputStream(java.io.BufferedInputStream aIniStream,
                      java.lang.String kindOfFile)
               throws java.io.IOException
This constructor creates a TagInputStream object to read from aIniStream.


TagInputStream

public TagInputStream(java.lang.String fileName,
                      java.lang.String kindOfFile)
               throws java.io.IOException
This constructor creates a TagInputStream object to read from the specified file.

Parameters:
fileName - java.lang.String
kindOfFile - java.lang.String

TagInputStream

public TagInputStream(java.net.URL aURL,
                      java.lang.String kindOfFile)
               throws java.io.IOException
This constructor creates a TagInputStream object to read from the specified file.

Parameters:
aURL - java.net.URL
kindOfFile - java.lang.String

TagInputStream

public TagInputStream(java.util.zip.ZipInputStream zip,
                      java.lang.String fileName,
                      java.lang.String kindOfFile)
               throws java.io.IOException
This constructor creates a TagInputStream object to read from the specified zip file.

Parameters:
zip - ZipInputStream
fileName - java.lang.String
kindOfFile - java.lang.String
Method Detail

close

public void close()
           throws java.io.IOException
Closes the stream thereby releasing the file. This method also releases a great deal of memory

Throws:
java.io.IOException

createComposedTag

public void createComposedTag(Tag aTag,
                              java.lang.String fileTitle,
                              ProgressIndicator pi,
                              boolean isXmlFile)
                       throws java.io.IOException
Adds the subtags to aTag to create a composed tag.

Throws:
java.io.IOException.
java.io.IOException

createComposedTag

public void createComposedTag(Tag aTag,
                              java.lang.String fileTitle,
                              ProgressIndicator pi,
                              boolean isXmlFile,
                              Tag.TagStringReader aReader)
                       throws java.io.IOException
Adds the subtags to aTag to create a composed tag.

Throws:
java.io.IOException.
java.io.IOException

first

public Tag first()
          throws java.io.IOException
Returns the first tag in the stream.

Returns:
Tag
Throws:
java.io.IOException

getDateCreationFile

public java.util.Date getDateCreationFile()
Returns the date the XML file corresponding to this TagInputStream was created or last modified.

Returns:
java.util.Date.

getExternalizer

public Externalizer getExternalizer()
Returns the Externalizer of this stream.

Returns:
Externalizer

getInputStream

public java.io.InputStream getInputStream()
Returns the inputStream.

Returns:
FileInputStream

getKindOfFile

public java.lang.String getKindOfFile()
Gets the kind of file to read

Returns:
java.lang.String

getSgmlFile

public java.lang.String getSgmlFile()
Returns the name of the XML file that this stream reads.

Returns:
java.lang.String

getSgmlFileTitle

public java.lang.String getSgmlFileTitle(java.lang.String aSgmlFile)
Returns the title (name) of the XML file (without its path)

Parameters:
aSgmlFile - java.lang.String
Returns:
java.lang.String the title

getTag

public Tag getTag(int anInt)
           throws java.io.IOException
Returns a Tag in a position.

Parameters:
anInt - int
Returns:
Tag
Throws:
java.io.IOException

getTagIndexes

public Hashtable getTagIndexes()
Returns the positions of the tags in the file (option file) or the tags themselves (option memory).

Returns:
Vector

getTags

public Vector getTags()
Returns the tags.

Returns:
Vector

getTagString

protected java.lang.Object[] getTagString(int aPosition)
                                   throws java.io.IOException
Reads a tag in the file starting in the position aPosition.

Returns:
Object[] - An array containing the tag read and its position (in bytes) in the file
Throws:
java.io.IOException.
java.io.IOException

getTagString

protected void getTagString(int aPosition,
                            boolean isXmlFile)
                     throws java.io.IOException
Reads a tag in the file starting in the position aPosition

Returns:
Object[] an array containing the tag read and its position (in bytes) in the file.
Throws:
java.io.IOException.
java.io.IOException

initialize

public void initialize(java.io.BufferedInputStream aIniStream,
                       java.lang.String kindOfFile)
                throws java.io.IOException
Initializes the stream.

Parameters:
aIniStream - BufferedInputStream
kindOfFile - java.lang.String
Throws:
java.io.IOException.
java.io.IOException

initialize

public void initialize(java.io.BufferedInputStream aIniStream,
                       java.lang.String kindOfFile,
                       boolean isSelfDefined)
                throws java.io.IOException
Initializes the stream.

Parameters:
aIniStream - BufferedInputStream
kindOfFile - java.lang.String
isSelfDefined - boolean
Throws:
java.io.IOException.
java.io.IOException

initialize

public void initialize(java.lang.String fileName,
                       java.lang.String kindOfFile)
                throws java.io.IOException
Initializes the stream that reads the specified file.

Parameters:
fileName - java.lang.String
kindOfFile - java.lang.String
Throws:
java.io.IOException.
java.io.IOException

initialize

public void initialize(java.net.URL aURL,
                       java.lang.String kindOfFile)
                throws java.io.IOException
Initializes the stream reading from the URL.

Parameters:
aURL - java.net.URL
kindOfFile - java.lang.String
Throws:
java.io.IOException.
java.io.IOException

initialize

public void initialize(java.util.zip.ZipInputStream zip,
                       java.lang.String fileName,
                       java.lang.String kindOfFile)
                throws java.io.IOException
Initializes the stream that reads the specified zip file.

Parameters:
zip - java.util.zip.ZipInputStream
fileName - java.lang.String
kindOfFile - java.lang.String
Throws:
java.io.IOException.
java.io.IOException

isDecorator

public boolean isDecorator(Tag aTag)
Returns true if aTag is a decorator.

Parameters:
aTag - com.ibm.btt.base.Tag
Returns:
boolean

isSimpleTag

public boolean isSimpleTag(Tag aTag)
                    throws java.io.IOException
Returns true if aTag is a simple tag. If the file read is the initialization file (.INI), this method looks for the simple data tags in the simpleTags vector. If the file read is another file, this method looks for the simple tags in the settings.

Returns:
boolean - True if the tag is a simple one
Throws:
java.io.IOException.
java.io.IOException

last

public Tag last()
         throws java.io.IOException
Returns the last tag.

Returns:
Tag
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Reads a character from the bufferedReader and returns it as an int.

Throws:
java.io.IOException.
java.io.IOException

readObject

public java.lang.Object readObject(int index)
                            throws java.io.IOException
Returns the tag (cast to an Object) at the given index.

Parameters:
index - int
Returns:
Object
Throws:
java.io.IOException

readTag

public Tag readTag(int index)
Returns the Tag at the specified index. This method can only be used with the memory option where the Tags are stored in memory. As a result, the file does not need to be opened again.

Parameters:
index - int
Returns:
Tag

removeTagWithId

public void removeTagWithId(java.lang.String tagId)
                     throws java.io.IOException
Removes the tag with id tagId from this TagInputStream.

Parameters:
tagId - java.lang.String
Throws:
java.io.IOException

reset

public void reset(java.lang.String tagId,
                  Tag newTagState)
Sets the attributes of the tag with the id tagId with the attributes of the tag passed by parameter. If the tag doesn't exist then it is added.

Parameters:
tagId - java.lang.String - The id of the tag to change
newTagState - com.ibm.btt.base.Tag - The new value for the tag with id tagId

setDate

protected void setDate(java.lang.String fileName)
Sets the date the XML file corresponding to this TagInputStream was created.


setDate

protected void setDate(java.net.URLConnection url)
Sets the date the URL corresponding to this TagInputStream was created.

Parameters:
url - java.net.URLConnection

setDate

protected void setDate(java.util.zip.ZipEntry entry)
Sets the date the zip file corresponding to this TagInputStream was created.

Parameters:
entry - ZipEntry

setExternalizer

public void setExternalizer(Externalizer aExternalizer)
Sets the externalizer.

Parameters:
aExternalizer - Externalizer

setKindOfFile

public void setKindOfFile(java.lang.String aKindOfFile)
Sets the kind of file to read.

Parameters:
aKindOfFile - java.lang.String

setSgmlFile

public void setSgmlFile(java.lang.String aFileName)
Sets the SGML file.

Parameters:
aFileName - java.lang.String

setTagIndexes

public void setTagIndexes(Hashtable aHashtable)
Sets the indexes of the tags in the file (option file). If the memory option is being used, this method stores the Strings of the tags.


setTags

public void setTags(Vector aVector)
Sets the tags.

Parameters:
aVector - Vector

skip

public void skip(long aLong)
          throws java.io.IOException
This method skips aLong amount of characters in the stream

Throws:
java.io.IOException

tagWithId

public Tag tagWithId(java.lang.String aString)
              throws java.io.IOException
Returns the tag with the specified ID.

Parameters:
aString - java.lang.String
Returns:
Tag
Throws:
java.io.IOException.
java.io.IOException

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005