com.ibm.ims.db
Class DLISegment

java.lang.Object
  |
  +--com.ibm.ims.base.DLIBaseSegment
        |
        +--com.ibm.ims.db.DLISegment
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class DLISegment
extends DLIBaseSegment

DLISegment is the base class for objects representing segments in a DL/I database. These DLISegment subclasses provide the mapping between the data in the segment and access functions on the class. To provide the mapping, the subclasses must register their DLITypeInfo with this class by providing it as the argument to the constructor. By doing so, the DLISegment class knows the layout of each segment in the database and can access as well as update each of the fields within a segment. Note that when creating the DLITypeInfo objects to register with a DLISegment the offsets are 1-based. In the example below, the first paramter is an alias for the key and search fields. This alias would then be used throughout the application when referring to the key or search field. The key and search fields are given as the last paramter and must be defined exactly as they are defined in the DBD source file. The reason for this is that in the DBD source the field names are limited to 8 characters, whereas the alias has no such limitations. The following shows code typical of a DLISegment subclass:

  class MySegment extends DLISegment {

		static DLITypeInfo[] typeInfo = { 
 			new DLITypeInfo("FieldAlias1",	DLITypeInfo.CHAR,     1,  6, "Field1"),
			new DLITypeInfo("FieldAlias2",	DLITypeInfo.INTEGER,  7,  4, "Field2"),
			new DLITypeInfo("FieldAlias3",	DLITypeInfo.BIGINT,   11, 8, "Field3"),
		};
         
 		public MySegment() {
 			super ("SegmentReference", "SEGNAME", typeInfo, 18);
 		}
  }    
  

See Also:
DLITypeInfo, Serialized Form

Fields inherited from class com.ibm.ims.base.DLIBaseSegment
ioArea, ioAreaLength, ioAreaOffset
 
Constructor Summary
protected DLISegment(java.lang.String segmentNameInDBD, DLITypeInfo[] typeInfo, int length)
          Constructs a DL/I Segment object.
  DLISegment(java.lang.String segmentNameReference, java.lang.String segmentNameInDBD, DLITypeInfo[] typeInfo, int length)
          Constructs a DL/I Segment object.
 
Method Summary
 void clearWarnings()
          Clears the warning chain for this DLISegment.
 byte[] getIOArea()
          Provides package-level access to DLIBaseSegment.ioArea.
 int getIOAreaLength()
          Provides package-level access to DLIBaseSegment.ioAreaLength.
 int getIOAreaOffset()
          Provides package-level access to DLIBaseSegment.ioAreaOffset.
 byte[] getSegmentKey()
          Returns the key of the current Segment.
 java.lang.String getSegmentNameReference()
           
 DLIWarning getWarnings()
          The first warning reported by calls on this DLISegment is returned.
 void setIOArea(byte[] ioArea)
          Sets the IO area of this segment
 void setIOAreaOffset(int ioAreaOffset)
          Provides package-level access to DLIBaseSegment.ioAreaOffset.
 
Methods inherited from class com.ibm.ims.base.DLIBaseSegment
clone, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getBytes, getDate, getDate, getDefaultEncoding, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getOffset, getSegmentName, getShort, getShort, getString, getString, getTime, getTime, getTimestamp, getTimestamp, getTypeInfo, getTypeInfo, getTypeInfo, setBigDecimal, setBigDecimal, setBoolean, setBoolean, setByte, setByte, setBytes, setBytes, setBytes, setDate, setDate, setDefaultEncoding, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setShort, setShort, setString, setString, setTime, setTime, setTimestamp, setTimestamp
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DLISegment

protected DLISegment(java.lang.String segmentNameInDBD,
                     DLITypeInfo[] typeInfo,
                     int length)
Constructs a DL/I Segment object. By providing an array of DLITypeInfo objects as an argument, this class knows the layout of the segment and can access as well as update each field within the segment. When using JDBC to access the segments in a database, the name of the segment (table) in the query must exactly match the name of the DLISegment subclass. For example, if the name of the class is MySegment, then a query will look as follows: SELECT MySegment.field1 FROM MySegment
Parameters:
segmentNameInDBD - the name of the segment in the database as defined in the DBD
typeInfo - an array of DLITypeInfo objects, which tells this class the layout of the segment
length - the length of the I/O area of the segment

DLISegment

public DLISegment(java.lang.String segmentNameReference,
                  java.lang.String segmentNameInDBD,
                  DLITypeInfo[] typeInfo,
                  int length)
Constructs a DL/I Segment object. By providing an array of DLITypeInfo objects as an argument, this class knows the layout of the segment and can access as well as update each field within the segment. When using JDBC to access the segments in a database, the name of the segment (table) in the query matches the first parameter in the constructor, which is the reference name for the segment. For example, if the segmentNameReference parameter was segmentA then a query will look as follows: SELECT segmentA.field1 FROM segmentA
Parameters:
segmentNameReference - the alias for the actual name of the segment that does not have the naming restrictions of segment names in a DBD (upper case, maximum length of 8 characters)
segmentNameInDBD - the name of the segment in the database as defined in the DBD
typeInfo - an array of DLITypeInfo objects, which tells this class the layout of the segment
length - the length of the I/O area of the segment
Method Detail

clearWarnings

public void clearWarnings()
Clears the warning chain for this DLISegment. After this call getWarnings returns null until a new warning is reported for this DLISegment.
Overrides:
clearWarnings in class DLIBaseSegment

getIOArea

public final byte[] getIOArea()
Provides package-level access to DLIBaseSegment.ioArea.

getIOAreaLength

public final int getIOAreaLength()
Provides package-level access to DLIBaseSegment.ioAreaLength.

getIOAreaOffset

public final int getIOAreaOffset()
Provides package-level access to DLIBaseSegment.ioAreaOffset.

getWarnings

public DLIWarning getWarnings()
The first warning reported by calls on this DLISegment is returned. Subsequent warnings will be chained to this DLIWarning. The warning chain is automatically cleared each time a new segment is read from the database. Note: This warning chain only covers warnings caused by DLISegment methods.
Overrides:
getWarnings in class DLIBaseSegment
Returns:
the first DLIWarning or null

setIOArea

public final void setIOArea(byte[] ioArea)
Sets the IO area of this segment

setIOAreaOffset

public final void setIOAreaOffset(int ioAreaOffset)
Provides package-level access to DLIBaseSegment.ioAreaOffset.

getSegmentNameReference

public final java.lang.String getSegmentNameReference()

getSegmentKey

public byte[] getSegmentKey()
                     throws DLIException
Returns the key of the current Segment. May be composed of multiple key fields.


(C) International Business Machines Corporation 2004. All rights reserved.