Primer for working with DataDir objects
ORG.oclc.ber.DataDir objects are used to store data into a directory structure. Each DataDir object can have children and/or siblings.
If a DataDir object has children, the method dir.child()
will return the first of them. To access subsequent children, if there are any, the method dir.next()
must be called on the object returned from dir.child()
.
It's important to note that the DataDir structure is recursive. dir.child()
returns a DataDir object, as does dir.next()
.
Figure 1
In Figure 1, the arrows labeled 'A' represent invocations of the child()
method and the arrows labeled 'B' represent invocations of the next()
method. Invoking the next()
method on object 1 will return null
, likewise if child()
is invoked on object 1.5.
The method form()
will allow you to determine whether or not a DataDir object has any children. If it returns ASN1.CONSTRUCTED, then it has children. If it returns ASN1.PRIMITIVE, then it does not. These values are located in the class ORG.oclc.ber.ASN1.
DataDir objects whose form is equal to ASN1.CONSTRUCTED do not have any data associated with them directly. DataDir objects whose form is equal to ASN1.PRIMITIVE do have data associated with them. The data in these objects can be accessed through these methods.
-
getInt()
-
getLong()
-
getString()
-
getUTFString()
Finally, the field ID of each DataDir object can be accessed through the public member, fldid.