|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.objsys.asn1j.runtime.Asn1Type com.objsys.asn1j.runtime.Asn1OctetString com.objsys.asn1j.runtime.Asn1OpenType
public class Asn1OpenType
This is a container class for holding an ASN.1 open type value.
Where the data is internally stored and how it is interpreted is controlled by a "dataEncoding" field. You can specify the data encoding when creating the object. It will also be set when decoding. The following explains the possible data encodings:
value
is used to hold byte data. It is interpreted
as the encoding of the actual value according to some unknown encoding
rules (BER, PER, XER, JSON, or some other).
value
is used to hold byte data. It is interpreted
as the encoding of the actual value according to BER or PER, respectively.
value
is used to hold byte data. It is interpreted as the
the encoding of the actual value in XML (whether X.693 or Obj-Sys rules),
where the XML characters are encoded to bytes using the UTF-8 character
encoding. Note especially that the data encoding indicates the encoding rules used to encode the actual value. That result is typically encoded as part of some larger encoding. The data encoding does NOT indicate the rules used for that larger encoding. For example, using an xmlhstring representation, XER and JSON will encode an open type that was previously encoded using any arbitrary encoding rules. When decoding such data, the data encoding will be UNKNOWN, not XER nor JSON.
Nested Class Summary | |
---|---|
class |
Asn1OpenType.SaxHandler
|
Field Summary | |
---|---|
static int |
BER
|
protected int |
dataEncoding
Specifies the nature of the data held by this object. |
protected static java.lang.String |
EDATAMSG
|
static int |
JSON
|
protected Asn1EncodeBuffer |
mEncodeBuffer
|
protected int |
mLength
|
static int |
PER
|
static int |
UNKNOWN
|
static int |
XER
|
Fields inherited from class com.objsys.asn1j.runtime.Asn1OctetString |
---|
TAG, value |
Fields inherited from class com.objsys.asn1j.runtime.Asn1Type |
---|
BIT_STRING, BMPString, BOOLEAN, DATE, DATE_TIME, DURATION, ENUMERATED, EOC, EXTERNAL, GeneralString, GeneralTime, GraphicString, IA5String, INTEGER, mAsn1TypeName, NULL, NumericString, OBJECT_IDENTIFIER, ObjectDescriptor, OCTET_STRING, OID_IRI, OpenType, PrintableString, REAL, RELATIVE_OID_IRI, RelativeOID, SEQUENCE, SET, T61String, TeletexString, TIME, TIME_OF_DAY, UniversalString, UTCTime, UTF8String, VideotexString, VisibleString |
Constructor Summary | |
---|---|
Asn1OpenType()
This constructor creates an empty type that can be used in a decode method call to receive an encoded value. |
|
Asn1OpenType(Asn1EncodeBuffer buffer)
This constructor initializes an open type using an encoded component. |
|
Asn1OpenType(byte[] data)
This constructor initializes an open type from the given byte array. |
|
Asn1OpenType(byte[] data,
int encoding)
This constructor initializes an open type from the given byte array. |
|
Asn1OpenType(byte[] data,
int offset,
int nbytes)
This constructor initializes the open type from a portion of the given byte array. |
|
Asn1OpenType(byte[] data,
int offset,
int nbytes,
int encoding)
This constructor initializes the open type from a portion of the given byte array. |
|
Asn1OpenType(char[] data,
int encoding)
Create Asn1OpenType on the given character data. |
|
Asn1OpenType(int length)
Deprecated. |
|
Asn1OpenType(java.lang.String data,
int encoding)
Convenience constructor. |
Method Summary | |
---|---|
void |
decode(Asn1BerDecodeBuffer buffer,
boolean explicit,
int implicitLength)
This method decodes an ASN.1 open type value. |
void |
decode(Asn1JsonDecodeBuffer buffer)
Decode ASN.1 open type value from JSON. |
void |
decode(Asn1PerDecodeBuffer buffer)
This method decodes an ASN.1 open type value using the packed encoding rules (PER). |
void |
decodeExtension(Asn1JsonDecodeBuffer buffer,
java.lang.String name)
Decode an extension from JSON. |
int |
encode(Asn1BerEncodeBuffer buffer,
boolean explicit)
This method encodes an ASN.1 open type value. |
void |
encode(Asn1BerOutputStream out,
boolean explicit)
This method encodes and writes to the stream an ASN.1 open type value including the UNIVERSAL tag value and length if explicit tagging is specified. |
void |
encode(Asn1JsonOutputStream outstream)
Encode this octet string to JSON. |
void |
encode(Asn1PerEncodeBuffer buffer)
This method encodes an ASN.1 open type value using the Packed Encoding Rules (PER). |
void |
encode(Asn1PerOutputStream out)
This method encodes an ASN.1 open type value using the Packed Encoding Rules (PER). |
void |
encode(Asn1XerEncoder buffer)
This method encodes an ASN.1 open type value using the XML Encoding Rules (XER). |
void |
encode(Asn1XerEncoder buffer,
java.lang.String elemName)
This method encodes an ASN.1 open type value using the XML Encoding Rules (XER). |
void |
encode(Asn1XmlEncoder buffer)
This method encodes an ASN.1 open type value using the XML Encoding as specified in the XML schema standard(asn2xsd). |
void |
encode(Asn1XmlEncoder buffer,
java.lang.String elemName,
java.lang.String nsPrefix)
This method encodes an ASN.1 open type value using the XML Encoding as specified in the XML schema standard(asn2xsd). |
void |
encodeAsExtension(Asn1JsonOutputStream outstream)
This method encodes an extension element to JSON. |
void |
encodeAsExtension(Asn1XerEncoder buffer)
This method encodes an extension element to XML. |
void |
encodeAsExtension(Asn1XmlEncoder buffer)
This method encodes an extension element to XML. |
java.lang.String |
getAsn1TypeName()
This method returns "Opaque Open Type" as the ASN.1 type name. |
char[] |
getCharData()
Returns the character data for the open type. |
int |
getDataEncoding()
Return the data encoding of the data. |
Asn1XerSaxHandler |
getSaxHandler()
Get a SAX handler for this object. |
Asn1XerSaxHandler |
getSaxHandler(boolean captureOuterElem)
Get a SAX handler for this object. |
void |
setBinaryData(byte[] data,
int encoding)
Sets the binary data for the open type and assigns the data encoding to the given encoding. |
void |
setCharData(char[] data,
int encoding)
Sets the character data for the open type and assigns the data encoding to the given encoding. |
void |
setCharData(java.lang.String data,
int encoding)
Convenience method; same as setCharData(value.toCharArray(), encoding) |
java.lang.String |
toString()
This method will return a string representation of the open type value. |
Methods inherited from class com.objsys.asn1j.runtime.Asn1OctetString |
---|
compareTo, decode, decode, decode, decodeXER, decodeXML, encode, encode, encode, encode, encode, encodeAttribute, encodeBase64Binary, equals, equals, getLength, getMderLength, hashCode, toInputStream |
Methods inherited from class com.objsys.asn1j.runtime.Asn1Type |
---|
clone, decode, decode, decode, decode, decode, encode, equals, getTypeName, indent, isOpenType, matchTag, matchTag, pdiag, print, setKey, setOpenType |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int UNKNOWN
public static final int BER
public static final int PER
public static final int XER
public static final int JSON
protected transient int mLength
protected transient Asn1EncodeBuffer mEncodeBuffer
protected int dataEncoding
protected static final java.lang.String EDATAMSG
Constructor Detail |
---|
public Asn1OpenType()
public Asn1OpenType(byte[] data)
data
- Byte array containing a previously encoded value.public Asn1OpenType(byte[] data, int encoding)
data
- Byte array containing a previously encoded value.encoding
- The encoding that describes the meaning of data.
Any of the encodings other than JSON.public Asn1OpenType(byte[] data, int offset, int nbytes)
data
- Byte array containing a previously encoded value.offset
- Starting offset in data from which to copy bytesnbytes
- Number of bytes to copy from target arraypublic Asn1OpenType(byte[] data, int offset, int nbytes, int encoding)
data
- Byte array containing a previously encoded value.offset
- Starting offset in data from which to copy bytesnbytes
- Number of bytes to copy from target arrayencoding
- The encoding that describes the meaning of data.
Any of the encodings other than JSON.public Asn1OpenType(Asn1EncodeBuffer buffer)
buffer
- Reference to encode buffer into which
component type was encoded.public Asn1OpenType(int length)
length
- Length of the pre-encoded component. This must
be the last item in the type and already exist
in the encode buffer.public Asn1OpenType(java.lang.String data, int encoding)
public Asn1OpenType(char[] data, int encoding)
data
- The character data array.encoding
- The encoding. Either XER or JSON.
If JSON, data is taken to be the JSON encoding of the actual value.
The array is not copied, so beware using it after passing it here.
The value
field will be assigned null.
If XER, data is taken to be the XER encoding of the actual value.
The value
field will be assigned the UTF-8 character encoding
of the given characters.Method Detail |
---|
public java.lang.String getAsn1TypeName()
getAsn1TypeName
in class Asn1OctetString
public char[] getCharData()
java.lang.RuntimeException
- if data encoding indicates there is no char
data.public void setBinaryData(byte[] data, int encoding)
data
- The binary data that make up an encoding of the actual
value.encoding
- Identifies the encoding rules for which data is an
encoding. This can be any of the encodings except JSON.public void setCharData(java.lang.String data, int encoding)
public void setCharData(char[] data, int encoding)
data
- The character data that make up an encoding of the actual
value.encoding
- Permissible values are JSON and XER.
If XER, the given data will be converted to bytes using UTF-8 and
held in the value
field.
If JSON, the given data will be held as-is. The array will not be
copied. The value
field will be assigned null.public int getDataEncoding()
public void decode(Asn1BerDecodeBuffer buffer, boolean explicit, int implicitLength) throws Asn1Exception, java.io.IOException
decode
in interface Asn1TypeIF
decode
in class Asn1OctetString
buffer
- Decode message buffer objectexplicit
- Flag indicating element is explicitly taggedimplicitLength
- Length of contents if implicit
Asn1Exception
java.io.IOException
public int encode(Asn1BerEncodeBuffer buffer, boolean explicit) throws Asn1Exception
encode
in interface Asn1TypeIF
encode
in class Asn1OctetString
buffer
- Encode message buffer objectexplicit
- Flag indicating element is explicitly tagged
Asn1Exception
public void decode(Asn1PerDecodeBuffer buffer) throws Asn1Exception, java.io.IOException
decode
in interface Asn1TypeIF
decode
in class Asn1OctetString
buffer
- Decode message buffer object
Asn1Exception
java.io.IOException
public void encode(Asn1PerEncodeBuffer buffer) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1OctetString
buffer
- Encode message buffer object
Asn1Exception
java.io.IOException
public void encodeAsExtension(Asn1XmlEncoder buffer) throws java.io.IOException, Asn1Exception
buffer
- Encode message buffer object
java.io.IOException
Asn1Exception
public void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix) throws java.io.IOException, Asn1Exception
encode
in class Asn1OctetString
buffer
- Encode message buffer objectelemName
- IgnorednsPrefix
- Ignored
java.io.IOException
Asn1Exception
public void encode(Asn1XmlEncoder buffer) throws java.io.IOException, Asn1Exception
buffer
- Encode message buffer object
java.io.IOException
Asn1Exception
public void encode(Asn1XerEncoder buffer, java.lang.String elemName) throws java.io.IOException, Asn1Exception
encode
in interface Asn1TypeIF
encode
in class Asn1OctetString
buffer
- Encode message buffer objectelemName
- Ignored
java.io.IOException
- Any exception thrown by the underlying stream.
Asn1Exception
- Thrown, if operation is failed.public void encodeAsExtension(Asn1XerEncoder buffer) throws java.io.IOException, Asn1Exception
java.io.IOException
Asn1Exception
public void encode(Asn1XerEncoder buffer) throws java.io.IOException, Asn1Exception
encode
in interface Asn1TypeIF
encode
in class Asn1Type
buffer
- Encode message buffer object
java.io.IOException
- Any exception thrown by the underlying stream.
Asn1Exception
- Thrown, if operation is failed.public void decodeExtension(Asn1JsonDecodeBuffer buffer, java.lang.String name) throws java.io.IOException
java.io.IOException
public void encodeAsExtension(Asn1JsonOutputStream outstream) throws java.io.IOException
java.io.IOException
public void decode(Asn1JsonDecodeBuffer buffer) throws java.io.IOException
decode
in class Asn1OctetString
buffer
-
java.io.IOException
public void encode(Asn1JsonOutputStream outstream) throws java.io.IOException
Asn1OctetString
encode
in class Asn1OctetString
java.io.IOException
public java.lang.String toString()
toString
in class Asn1OctetString
public void encode(Asn1BerOutputStream out, boolean explicit) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1OctetString
out
- BER Output Stream objectexplicit
- Flag indicating explicit tagging should be done
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Thrown, if operation is failed.public void encode(Asn1PerOutputStream out) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1OctetString
out
- PER Output Stream object
java.io.IOException
- Any exception thrown by the Asn1PerOutputStream.
Asn1Exception
- Thrown, if operation is failed.public Asn1XerSaxHandler getSaxHandler()
public Asn1XerSaxHandler getSaxHandler(boolean captureOuterElem)
captureOuterElem
- Pass true if the outer element start and end
tags (if present) should be captured. The outer element is the
element for which startElement is called when the level is the
start level. Note that this parameter is ignored if you have
previously invoked one of the getSaxHandler methods on this object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |