com.ibm.ims.db
Class DLIDatabaseView

java.lang.Object
  |
  +--com.ibm.ims.db.DLIDatabaseView

public class DLIDatabaseView
extends java.lang.Object

DLIDatabaseView is a container for segment information in a DL/I database. During static initialization of a DLIDatabaseView subclass, the subclass should create an array of DLISegmentInfo objects. The subclass constructor then provides both the array and the name of the view to the DLIDatabaseView constructor. DLISegmentInfo contains a DLISegment instance and the 0-based offset of the parent instance within the array. DLIDatabaseView stores the array of DLISegmentInfo objects and also creates a Hashtable for fast lookup by segment class name. The following shows code typical of a DLIDatabaseView subclass:

  class MyDatabaseView extends DLIDatabaseView {

     static DLISegmentInfo[] warehouseSegments =  {
         new DLISegmentInfo(new Warehouse(), DLIDatabaseView.ROOT),
         new DLISegmentInfo(new Stock(),     0),
         new DLISegmentInfo(new Stock11(),   1),
         new DLISegmentInfo(new Stock12(),   1),
     };

     static DLISegmentInfo[] districtSegments {
         new DLISegmentInfo(new District(),       DLIDatabaseView.ROOT),
      };

     static DLISegmentInfo[] customerSegments {
         new DLISegmentInfo(new Customer(),       DLIDatabaseView.ROOT),
         new DLISegmentInfo(new CustomerOrder(),  0),
      };

     public MyDatabaseView ( ) {
        super ("PSBNO", "WarehouseDB", "WAREDB", warehouseSegments);
        addDatabase("DistrictDB", "DISTDB", districtSegments);
        addDatabase("CustomerDB", "CUSTDB", customerSegments);
     }
  }
  


Field Summary
static int ROOT
          Used to identify that the root segment in a DLIDatabaseView has no parent.
 
Constructor Summary
protected DLIDatabaseView(java.lang.String dbPCBNameInPSB, DLISegmentInfo[] segments)
          Deprecated. use overloaded constructor with version
protected DLIDatabaseView(java.lang.String version, java.lang.String dbPCBNameInPSB, DLISegmentInfo[] segments)
          Constructs a DLIDatabaseView object from the view name and an array of DLISegmentInfo objects that define the segments contained in the view.
  DLIDatabaseView(java.lang.String psbName, java.lang.String dbPCBNameReference, java.lang.String dbPCBNameInPSB, DLISegmentInfo[] segments)
          Deprecated. use overloaded constructor with version
  DLIDatabaseView(java.lang.String version, java.lang.String psbName, java.lang.String dbPCBNameReference, java.lang.String dbPCBNameInPSB, DLISegmentInfo[] segments)
          Constructs a DLIDatabaseView object from the PSB name and the information for the first database view (PCB) in the view.
 
Method Summary
 void addDatabase(java.lang.String dbPCBNameReference, java.lang.String dbPCBNameInPSB, DLISegmentInfo[] segments)
          Adds another database to the view by providing the reference name for the view, the DB PCB name for that database view, and the array of DLISegmentInfo objects that define the segments contained in the database view.
 java.lang.Object clone()
          Creates and returns a shallow copy of this object.
 DLISegment cloneSegment(java.lang.String dbPCBNameReference, java.lang.String segmentName)
          This method will return a copy of any segment stored in the database view.
 java.lang.String getActualPCBName(java.lang.String dbPCBNameReference)
          This method resolves a PCB alias to the 8 character IMS PCB name.
 java.util.Vector getChildren(java.lang.String dbPCBNameReference, java.lang.String parentNameReference)
          Returns the parent DLISegment object of the specified segment class name.
 DLISegment getParent(java.lang.String dbPCBNameReference, DLISegment segment)
          Returns the parent DLISegment object of the specified segment.
 DLISegment getParent(java.lang.String dbPCBNameReference, java.lang.String segmentNameReference)
          Returns the parent DLISegment object of the specified segment class name.
 java.lang.String getPSBName()
          Returns the PSBName for this database view.
 java.lang.String getVersion()
          Returns the version number that this DLIDatabaseView conforms to.
protected  void setVersion(java.lang.String version)
          This sets the version number that the DLIDatabaseView conforms to.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT

public static final int ROOT
Used to identify that the root segment in a DLIDatabaseView has no parent.
Constructor Detail

DLIDatabaseView

protected DLIDatabaseView(java.lang.String version,
                          java.lang.String dbPCBNameInPSB,
                          DLISegmentInfo[] segments)
                   throws java.lang.RuntimeException
Constructs a DLIDatabaseView object from the view name and an array of DLISegmentInfo objects that define the segments contained in the view.
Parameters:
version - the version of DLIDatabaseView interface coded to.
dbPCBNameInPSB - the name of the database PCB as listed in the PSB
segments - the array of segments contained in the view identifying the segment hierarchy

DLIDatabaseView

public DLIDatabaseView(java.lang.String version,
                       java.lang.String psbName,
                       java.lang.String dbPCBNameReference,
                       java.lang.String dbPCBNameInPSB,
                       DLISegmentInfo[] segments)
                throws java.lang.RuntimeException
Constructs a DLIDatabaseView object from the PSB name and the information for the first database view (PCB) in the view. This includes the database view name, the actual DB PCB name, and the array of DLISegmentInfo objects that define the segments contained in the first database.
Parameters:
version - the version of DLIDatabaseView interface coded to.
psbName - the name of the PSB defining this view
dbPCBNameReference - the name of the first database view. The database view name is a reference for the PCB name that doesn't have the naming restrictions of a PCB name (upper case, maximum length of 8 characters)
dbPCBNameInPSB - the PCB name of the first PCB in the PSB
segments - the array of segments identifying the segment fields and hierarchy of the first database view

DLIDatabaseView

protected DLIDatabaseView(java.lang.String dbPCBNameInPSB,
                          DLISegmentInfo[] segments)
                   throws java.lang.RuntimeException
Deprecated. use overloaded constructor with version

Constructs a DLIDatabaseView object from the view name and an array of DLISegmentInfo objects that define the segments contained in the view.
Parameters:
dbPCBNameInPSB - the name of the database PCB as listed in the PSB
segments - the array of segments contained in the view identifying the segment hierarchy

DLIDatabaseView

public DLIDatabaseView(java.lang.String psbName,
                       java.lang.String dbPCBNameReference,
                       java.lang.String dbPCBNameInPSB,
                       DLISegmentInfo[] segments)
                throws java.lang.RuntimeException
Deprecated. use overloaded constructor with version

Constructs a DLIDatabaseView object from the PSB name and the information for the first database view (PCB) in the view. This includes the database view name, the actual DB PCB name, and the array of DLISegmentInfo objects that define the segments contained in the first database.
Parameters:
version - the version of DLIDatabaseView interface coded to.
psbName - the name of the PSB defining this view
dbPCBNameReference - the name of the first database view. The database view name is a reference for the PCB name that doesn't have the naming restrictions of a PCB name (upper case, maximum length of 8 characters)
dbPCBNameInPSB - the PCB name of the first PCB in the PSB
segments - the array of segments identifying the segment fields and hierarchy of the first database view
Method Detail

addDatabase

public void addDatabase(java.lang.String dbPCBNameReference,
                        java.lang.String dbPCBNameInPSB,
                        DLISegmentInfo[] segments)
                 throws java.lang.RuntimeException
Adds another database to the view by providing the reference name for the view, the DB PCB name for that database view, and the array of DLISegmentInfo objects that define the segments contained in the database view.
Parameters:
dbPCBNameReference - the name of the database view. The database view name is a reference for the PCB name that doesn't have the naming restrictions of a PCB name (upper case, max length of 8 characters)
dbPCBNameInPSB - the PCB name of the first PCB in the PSB
segments - the array of segments identifying the segment fields and hierarchy

getPSBName

public java.lang.String getPSBName()
Returns the PSBName for this database view.
Returns:
String - the PSBName for this database view.

getParent

public DLISegment getParent(java.lang.String dbPCBNameReference,
                            DLISegment segment)
                     throws DLIException
Returns the parent DLISegment object of the specified segment.
Parameters:
dbPCBNameReference - the reference to the actual DB PCB name
segment - the DLISegment instance
Returns:
the parent DLISegment object, or null if either the segment class name does not exist or there is no parent

getParent

public DLISegment getParent(java.lang.String dbPCBNameReference,
                            java.lang.String segmentNameReference)
                     throws DLIException
Returns the parent DLISegment object of the specified segment class name.
Parameters:
dbPCBNameReference - the reference to the actual DB PCB name
segmentNameReference - the reference name of the segment
Returns:
the parent DLISegment object, or null if either the segment class name does not exist or there is no parent

getChildren

public java.util.Vector getChildren(java.lang.String dbPCBNameReference,
                                    java.lang.String parentNameReference)
                             throws DLIException
Returns the parent DLISegment object of the specified segment class name.
Parameters:
dbPCBNameReference - the reference to the actual DB PCB name
parentNameReference - the reference name of the segment, null will return a vector of just the root node
Returns:
Vector of child DLISegments, the Vector will be empty if it has no children

getActualPCBName

public java.lang.String getActualPCBName(java.lang.String dbPCBNameReference)
                                  throws DLIException
This method resolves a PCB alias to the 8 character IMS PCB name.

cloneSegment

public DLISegment cloneSegment(java.lang.String dbPCBNameReference,
                               java.lang.String segmentName)
                        throws DLIException
This method will return a copy of any segment stored in the database view. This is intended for use with applications that are issuing DL/I calls using the methods in the DLIConnection class. Typically, an application would use this method in the following manner:
      DLISegment mySegment = myDBView.cloneSegment("pcbReference", "segmentReference");
      myConnection.getUniqueSegment(mySegment);
  
where pcbReference is the reference name of the database view (PCB) passed in to either the database view constructor or the DLIDatabaseView.addDatabase() method. The segmentReference can be either the reference name or actual name of the segment. It is recommended to use the reference name and the name is the one passed in to the DLISegment constructor via the segmentNameReference parameter.
Parameters:
dbPCBNameReference - the name of the database view. The database view name is a reference for the PCB name that doesn't have the naming restrictions of a PCB name (upper case, max length of 8 characters)
segmentName - either the reference name or actual name of the segment
Returns:
DLISegment a copy of the requested segment
Throws:
DLIException - if the segment does not exist in the database view
See Also:
DLISegment.DLISegment(String, String, DLITypeInfo[], int), DLIDatabaseView(String, String, String, DLISegmentInfo[]), addDatabase(String, String, DLISegmentInfo[])

clone

public java.lang.Object clone()
Creates and returns a shallow copy of this object.
Overrides:
clone in class java.lang.Object
Returns:
DLIDatabaseView A shallow copy of the DLIDatabaseView.

setVersion

protected void setVersion(java.lang.String version)
This sets the version number that the DLIDatabaseView conforms to. It should be set by the subclassed DLIDatabaseView and programmed into that class by the DLIModel Utility number. The version variable of DLIDatabaseViews created prior to the addition of this method will be left null. Set version values (non-null) implies the inclusion of key field information.

getVersion

public java.lang.String getVersion()
Returns the version number that this DLIDatabaseView conforms to. Set version values (non-null) implies the inclusion of key field information.


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