|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ipdr.common.IPDRDocWriter
public class IPDRDocWriter
This class serializes an IPDRDoc to an OutputStream according to the compact encoding specification and XML format.
Typical usage involves specifying the header information in the IPDRDoc when the Writer is constructed and then providing individual usage events, "ipdr's" to be recorded.
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 java.util.HashMap |
descriptorLookup_
A HashMap keyed by the CompositeType object, which stores the DesciptorId (if any) associated with this type. |
int |
docType_
The type of the document (XDR/XML). |
protected IPDRStreamElement |
elt_
Cached wrapper for IPDR Stream Element. |
static java.util.ArrayList |
errorList_
List to store the non-fatal processing errors. |
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 serialized in this stream. |
java.lang.String |
ipdrVersion_
String containing IPDR Version. |
protected XDRMarshaller |
ostreamXDR_
The output stream the IPDRDoc in XDR is being written to. |
protected XMLMarshaller |
ostreamXML_
The output stream the IPDRDoc in XML is being written to. |
Schema |
schema_
Object of Schema class. |
protected int |
state_
The current state of the DocWriter. |
static int |
UNWRITEABLE
Int to represent the DocWriter's state when its unwriteable. |
static int |
WRITEABLE
Int to represent the DocWriter's state when its writeable. |
static int |
XDR
Int to represent the document type for XDR. |
static int |
XML
Int to represent the document type for XML. |
Constructor Summary | |
---|---|
IPDRDocWriter(java.io.OutputStream ostream,
int docType)
Constructor. |
Method Summary | |
---|---|
protected int |
createDescriptor(CompositeType type)
Create a descriptor for given Type and register it in the lookup table for later use. |
int |
getDescriptorCount()
Method to get the number of Descriptors written so far. |
int |
getIpdrCount()
Method to get the number of usage events written so far. |
int |
getState()
Method to get the state of this Writer (WRITEABLE / UNWRITEABLE). |
protected int |
mapOpenTypeToAttributeType(OpenType type)
Method to get the AttributeType, given the OpenType. |
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. |
void |
writeEnd(long endTime)
Mark the end of this IPDR stream, creating an IPDRDocEnd element in the compact IPDRDoc. |
void |
writeHeader(java.lang.String ipdrRecorderInfo,
long startTime,
java.lang.String defaultNSURI,
NameSpaceInfo[] otherNameSpaces,
java.lang.String[] schemaNameSpaces,
java.lang.String[] serviceDefURIs,
byte[] docId)
Writes the header information to the Output Stream. |
void |
writeIPDR(CompositeData cData)
Add an IPDR event into the IPDRDoc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected XDRMarshaller ostreamXDR_
protected XMLMarshaller ostreamXML_
protected int state_
public int docType_
public static java.util.ArrayList errorList_
protected int ipdrCount_
protected int descriptorCount_
protected java.util.HashMap descriptorLookup_
protected IPDRStreamElement elt_
public Schema schema_
public java.lang.String ipdrVersion_
public static final int UNWRITEABLE
public static final int WRITEABLE
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 IPDRDocWriter(java.io.OutputStream ostream, int docType) throws IPDRException, java.io.IOException
ostream
- The output stream to write the IPDR data todocType
- The docuemnt type (XML / XDR) (0=XML / 1=XDR)
java.io.IOException
- when an exception occurs while writing
IPDRException
- when a IPDR functionality related exception occursMethod Detail |
---|
public void setSchema(Schema s) throws IPDRException, java.io.IOException
s
- Object of Schema class
java.io.IOException
- when an exception occurs while writing
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 writeHeader(java.lang.String ipdrRecorderInfo, long startTime, java.lang.String defaultNSURI, NameSpaceInfo[] otherNameSpaces, java.lang.String[] schemaNameSpaces, java.lang.String[] serviceDefURIs, byte[] docId) throws java.io.IOException, IPDRException
ipdrRecorderInfo
- Identification information for the producer
of this document. Typcially URI, or blank.startTime
- The number of seconds since the Epoch
(00:00:00 UTC, January 1, 1970).defaultNSURI
- Identifies the default Namespace associated
with this record. Those attribute names
which are unqualified will be assumed to be
from this namespace.otherNameSpaces
- Identifies additional namespaces from which
attributes are derived. This list may be
empty.schemaNameSpaces
- Identifies additional namespaces corresponding to
serviceDefURIs from which
attributes are derived. This list may be
empty.serviceDefURIs
- Identifies the set of service definitions
from which the records are produced.docId
- The UUID associated with this document.
java.io.IOException
- when an exception occurs while writing
IPDRException
- when a IPDR functionality related exception occurspublic void writeIPDR(CompositeData cData) throws java.io.IOException, BadCompositeException, IPDRException, org.xml.sax.SAXException
cData
- Composite Data object containing the IPDR to write
java.io.IOException
- when an exception occurs while writing
BadCompositeException
- when an exception occurs while
generating the Composite Type
IPDRException
- when a IPDR functionality related exception occurs
org.xml.sax.SAXException
- when an exception occurs while parsing the scehmapublic void writeEnd(long endTime) throws java.io.IOException, IPDRException
endTime
- The end time of the document in milliseconds
java.io.IOException
- when an exception occurs while writing
IPDRException
public int getState()
public int getDescriptorCount()
public int getIpdrCount()
protected int createDescriptor(CompositeType type) throws java.io.IOException, BadCompositeException, IPDRException
type
- The Composite Type to create the Descriptor from
java.io.IOException
- when an exception occurs while writing
BadCompositeException
- when an exception occurs while
generating the Composite Type
IPDRException
protected int mapOpenTypeToAttributeType(OpenType type) throws BadCompositeException
type
- The Open Type
BadCompositeException
- when the TypeCode is not recognised
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |