com.hdcookbook.grin.io.binary
Class GrinDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.DataInputStream
              extended by com.hdcookbook.grin.io.binary.GrinDataInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class GrinDataInputStream
extends java.io.DataInputStream

GrinDataInputStream is a convenience DataInputStream subclass that can handle certain Objects and Object arrays, including null. This class is used by the GrinBinaryReader to read in information about the show nodes.

See also GrinDataOutputStream in the JavaSE tools.

See Also:
GrinBinaryReader

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Method Summary
 boolean isNull()
          Checks whether the Object reading is is null or not.
 java.awt.Color readColor()
          Reads in and constructs a Color instance.
 Command[] readCommands()
          Reads in information about Commands and reconstructs an array of Commands from it.
 Feature readFeatureReference()
          Reads in a reference of a feature and returns an instance of the feature.
 Feature[] readFeaturesArrayReference()
          Reads in refereces of Features and returns an array of Features corresponding to the references.
 int[] readIntArray()
          Reads in and constructs an array of integer.
 RCHandler readRCHandlerReference()
          Reads in a reference of an RCHandler and returns an instance of the RCHandler.
 RCHandler[] readRCHandlersArrayReference()
          Reads in refereces of RCHandler and returns an array of the RCHandler.
 java.awt.Rectangle readRectangle()
          Reads in and constructs a Rectangle instance.
 java.awt.Rectangle[] readRectangleArray()
          Reads in and constructs an array of Rectangle.
 Segment readSegmentReference()
          Reads in a reference of a segment and returns an instance of the segment.
 int[] readSharedIntArray()
          Reads in an reference to an integer array.
 java.awt.Rectangle readSharedRectangle()
           
 java.awt.Rectangle[] readSharedRectangleArray()
           
 java.lang.String readString()
          Reads in and constructs a String instance.
 java.lang.String[] readStringArray()
          Reads in and constructs an array of Strings.
 void readSuperClassData(Command command)
          Reads in information common to all Command types.
 void readSuperClassData(Feature feature)
          Reads in information common to all Feature types.
 void readSuperClassData(RCHandler handler)
          Reads in information common to all RChandler types.
 void readSuperClassData(Segment segment)
          Reads in information common to all Segment types.
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readColor

public java.awt.Color readColor()
                         throws java.io.IOException
Reads in and constructs a Color instance.

Returns:
A Color instance reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readRectangle

public java.awt.Rectangle readRectangle()
                                 throws java.io.IOException
Reads in and constructs a Rectangle instance.

Returns:
A Rectangle instance reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readRectangleArray

public java.awt.Rectangle[] readRectangleArray()
                                        throws java.io.IOException
Reads in and constructs an array of Rectangle.

Returns:
An array of Rectangles reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readIntArray

public int[] readIntArray()
                   throws java.io.IOException
Reads in and constructs an array of integer.

Returns:
An array of integers reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readSharedIntArray

public int[] readSharedIntArray()
                         throws java.io.IOException
Reads in an reference to an integer array.

Returns:
An array of integers reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readSharedRectangleArray

public java.awt.Rectangle[] readSharedRectangleArray()
                                              throws java.io.IOException
Throws:
java.io.IOException

readSharedRectangle

public java.awt.Rectangle readSharedRectangle()
                                       throws java.io.IOException
Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads in and constructs a String instance.

Returns:
A String instance reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readStringArray

public java.lang.String[] readStringArray()
                                   throws java.io.IOException
Reads in and constructs an array of Strings.

Returns:
An array of Strings reconstructed from the input stream.
Throws:
java.io.IOException - if IO error occurs.

readFeatureReference

public Feature readFeatureReference()
                             throws java.io.IOException
Reads in a reference of a feature and returns an instance of the feature.

Returns:
A feature that is referenced from, or null if no such feature exists in the GrinBinaryReader that this input stream is working with.
Throws:
java.io.IOException

readSegmentReference

public Segment readSegmentReference()
                             throws java.io.IOException
Reads in a reference of a segment and returns an instance of the segment.

Returns:
a Segument that is referenced from, or null if no such segment exists in the GrinBinaryReader that this input stream is working with.
Throws:
java.io.IOException

readRCHandlerReference

public RCHandler readRCHandlerReference()
                                 throws java.io.IOException
Reads in a reference of an RCHandler and returns an instance of the RCHandler.

Returns:
a RCHandler that is referenced from, or null if no such RCHandler exists in the GrinBinaryReader that this input stream is working with.
Throws:
java.io.IOException

readFeaturesArrayReference

public Feature[] readFeaturesArrayReference()
                                     throws java.io.IOException
Reads in refereces of Features and returns an array of Features corresponding to the references.

Returns:
an array of Features that is referenced from.
Throws:
java.io.IOException

readRCHandlersArrayReference

public RCHandler[] readRCHandlersArrayReference()
                                         throws java.io.IOException
Reads in refereces of RCHandler and returns an array of the RCHandler.

Returns:
an array of RCHandler that is referenced from.
Throws:
java.io.IOException

readCommands

public Command[] readCommands()
                       throws java.io.IOException
Reads in information about Commands and reconstructs an array of Commands from it.

Returns:
an array of Commands reconstructed from this stream.
Throws:
java.io.IOException

isNull

public boolean isNull()
               throws java.io.IOException
Checks whether the Object reading is is null or not. When writing custom object, one can do:
 public void readInstanceData(GrinDataInputStream in) {
    .....
    MyObject myObject = null;
    if (!in.isNull()) {
       // proceed with populating data in "myObject"
    }
    ....
 }
 

See also GrinDataOutputStream's writeNull and writeNonNull methods in the JavaSE tools.

Returns:
boolean whether the object is null.
Throws:
java.io.IOException

readSuperClassData

public void readSuperClassData(Feature feature)
                        throws java.io.IOException
Reads in information common to all Feature types. This method reads in following information.

See also GrinDataOutputStream's writeSuperClassData(Feature) method in the JavaSE tools.

Parameters:
feature - the feature type of populate base data with.
Throws:
java.io.IOException

readSuperClassData

public void readSuperClassData(RCHandler handler)
                        throws java.io.IOException
Reads in information common to all RChandler types. This method reads in following information.

See also GrinDataOutputStream's writeSuperClassData(RCHandler) method in the JavaSE tools.

Parameters:
handler - RCHandler instance to populate data.
Throws:
java.io.IOException

readSuperClassData

public void readSuperClassData(Segment segment)
                        throws java.io.IOException
Reads in information common to all Segment types. This method reads in following information.

See also GrinDataOutputStream's writeSuperClassData(Segment) method in the JavaSE tools.

Parameters:
segment - RCHandler instance to populate data.
Throws:
java.io.IOException

readSuperClassData

public void readSuperClassData(Command command)
Reads in information common to all Command types. There is no shared data for Command class currently.

See also GrinDataOutputStream's writeSuperClassData(Command) method in the JavaSE tools.

Parameters:
command - Command instance to populate data.
Throws:
java.io.IOException