|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ipdr.common.IPDRDocReader
public class IPDRDocReader
This class deserializes an IPDRDoc from an InputStream according to the compact encoding specification and XML format.
Typical usage involves passing an Input stream, reading the header information, and then extracting individual usage events.
The format of the usage events follows the convention defined for OpenMBeans in the Java Management Extension framework: http://java.sun.com/products/JavaManagement. In particular OpenMBeans are described in Chapter X.
The OpenMBean model defines a java data interchange structure called CompositeData. This structure allows an arbitrary data structure to be manipulated by components which have no a priori knowledge of the object structure.
Field Summary | |
---|---|
protected int |
descriptorCount_
The number of different descriptorRecords created. |
protected CompositeType[] |
descriptorList_
The currently encountered descriptors. |
protected IPDRDocEnd |
docEnd_
The document end object, after it is read. |
int |
docType_
The type of the document (XDR/XML). |
protected IPDRHeader |
header_
The header of the document, after it is read. |
static int |
INITIAL_DESCRIPTOR_LIST_SIZE
The initial descriptor list size. |
static java.lang.String |
IPDR_VERSION_3_0
String to represent the IPDR Version for IPDR v3.0 |
static java.lang.String |
IPDR_VERSION_3_1
String to represent the IPDR Version for IPDR v3.1 |
static java.lang.String |
IPDR_VERSION_3_5
String to represent the IPDR Version for IPDR v3.5 |
protected int |
ipdrCount_
The count of IPDR's which have been deserialized from this stream. |
java.lang.String |
ipdrVersion_
String containing IPDR Version. |
XDRUnMarshaller |
istreamXDR_
The input stream the IPDRDoc in XDR is being read from. |
XMLUnMarshaller |
istreamXML_
The input stream the IPDRDoc in XML is being read from. |
static int |
READABLE
Int to represent the DocReader's state when its Readable. |
Schema |
schema_
Object of Schema class. |
protected int |
state_
The current state of the DocReader. |
static int |
UNREADABLE
Int to represent the DocReader's state when its Unreadable. |
static int |
XDR
Int to represent the document type for XDR. |
static int |
XML
Int to represent the document type for XML. |
Constructor Summary | |
---|---|
IPDRDocReader(java.io.InputStream istream,
int docType)
Creates an object to deserialize the stream. |
Method Summary | |
---|---|
protected void |
addDescriptor(RecordDescriptor desc)
Add the descriptor that was read to the lookup table for future use. |
int |
getDescriptorCount()
Method to get the number of descriptors encountered so far. |
IPDRDocEnd |
getDocEnd()
Method to get the end of document structure. |
IPDRHeader |
getHeader()
Method to get the header of the document. |
int |
getIpdrCount()
Method to get the number of usage events encountered so far. |
int |
getState()
Method to get the state of this Reader (READABLE / UNREADABLE). |
protected SimpleType |
mapAttributeToOpenType(AttributeDescriptor desc)
Method to get the OpenType, given the AttributeDescriptor. |
void |
readHeader()
This method is called separately by calling application and it reads header information. |
CompositeData |
readIPDR()
Read an IPDR event from the Input Stream. |
protected void |
readXDRDocEnd(IPDRDocEnd docEnd)
Mark the end of this IPDR stream, creating an IPDRDocEnd element in the compact IPDRDoc. |
IPDRDocEnd |
readXMLDocEnd()
Mark the end of the doc. |
void |
setSchema(Schema s)
This optional method is called by to do validation against schema for a particular IPDRDoc. |
void |
setVersion(java.lang.String ver)
This optional method is called when the user chooses not to validation against schema. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public XDRUnMarshaller istreamXDR_
public XMLUnMarshaller istreamXML_
protected int state_
public int docType_
protected int ipdrCount_
protected int descriptorCount_
public static final int INITIAL_DESCRIPTOR_LIST_SIZE
protected CompositeType[] descriptorList_
Other assignment policies may be used, but will be less efficient from a storage perspective. In particular the array size will be proporational to max(descriptorId) + 1.
The initial table is set to a size of 10 to avoid resizing.
protected IPDRHeader header_
protected IPDRDocEnd docEnd_
public Schema schema_
public java.lang.String ipdrVersion_
public static final int UNREADABLE
public static final int READABLE
public static final int XDR
public static final int XML
public static final java.lang.String IPDR_VERSION_3_0
public static final java.lang.String IPDR_VERSION_3_1
public static final java.lang.String IPDR_VERSION_3_5
Constructor Detail |
---|
public IPDRDocReader(java.io.InputStream istream, int docType) throws java.io.IOException, IPDRException
This object will manage the descriptors transparently so the user only sees a stream of usage events through the readIPDR method.
istream
- The Input StreamdocType
- The docuemnt type (XML / XDR) (0=XML / 1=XDR)
java.io.IOException
- when an exception occurs while reading
IPDRException
- when a IPDR functionality related exception occursMethod Detail |
---|
public void setSchema(Schema s) throws java.io.IOException, IPDRException
s
- Object of Schema class
java.io.IOException
- when an exception occurs while reading
IPDRException
- when a IPDR functionality related exception occurspublic void setVersion(java.lang.String ver) throws IPDRException
ver
- IPDR Version
IPDRException
- when a IPDR functionality related exception occurspublic void readHeader() throws java.io.IOException, IPDRException
java.io.IOException
IPDRException
public CompositeData readIPDR() throws java.io.IOException, BadCompositeException, IPDRException
A null value will be returned when the document end is encountered. Subsequent reads after this will receive an exception.
java.io.IOException
- when an exception occurs while reading
BadCompositeException
- when an exception occurs while
constructing Composite Type / Data
IPDRException
- when a IPDR functionality related exception occurspublic int getState()
public int getDescriptorCount()
public int getIpdrCount()
public IPDRHeader getHeader()
public IPDRDocEnd getDocEnd()
protected void readXDRDocEnd(IPDRDocEnd docEnd) throws IPDRException
docEnd
- The DocEnd object
IPDRException
- when a IPDR functionality related exception occurspublic IPDRDocEnd readXMLDocEnd() throws java.io.IOException, IPDRException
java.io.IOException
- when an exception occurs while reading
IPDRException
- when a IPDR functionality related exception occursprotected void addDescriptor(RecordDescriptor desc) throws BadCompositeException, IPDRException
desc
- The descriptor that was read
BadCompositeException
- when an exception occurs while
constructing Composite Type / Data
IPDRException
- when a IPDR functionality related exception occursprotected SimpleType mapAttributeToOpenType(AttributeDescriptor desc) throws BadCompositeException
desc
- The Attribute Descriptor.
BadCompositeException
- when the TypeCode is not recognised
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |