public class Asn1OpenType extends Asn1OctetString
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, PER, or OER,
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.
Modifier and Type | Class and Description |
---|---|
class |
Asn1OpenType.SaxHandler |
Modifier and Type | Field and Description |
---|---|
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 |
OER |
static int |
PER |
static int |
UNKNOWN |
static int |
XER |
TAG, value
BIT_STRING, BMPString, BOOLEAN, DATE, DATE_TIME, DURATION, ENUMERATED, EOC, EXTERNAL, GeneralString, GeneralTime, GraphicString, IA5String, INTEGER, mNonParameterizedTypeName, 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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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(Asn1OerDecodeBuffer buffer)
This method decodes an ASN.1 open type value using the Octet Encoding
Rules (OER).
|
void |
decode(Asn1PerDecodeBuffer buffer)
This method decodes an ASN.1 open type value using the packed
encoding rules (PER).
|
void |
decode72(Asn1JsonDecodeBuffer buffer)
Decode ASN.1 open type value from JSON following rules created by
Obj-Sys before X.697.
|
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(Asn1OerEncodeBuffer buffer)
This method encodes an ASN.1 open type value using the Octet
Encoding Rules (OER).
|
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 |
encode72(Asn1JsonOutputStream outstream)
Encode to JSON folllowing rules created by Obj-Sys before X.697.
|
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.
|
compareTo, decode, decode, decode, decode, decodeAsBase64, decodeAsHex, decodeContent, decodeRemainingBits, decodeXER, decodeXML, encode, encode, encode, encode, encode, encodeAsBase64, encodeAsHex, encodeAttribute, encodeBase64Binary, encodeContent, equals, equals, equals, getLength, getMderLength, hashCode, skip, skip, toInputStream
_setKey, _setLicLocation, clone, decode, decode, decode, decode, decode, decode, decode, decode, decode, encode, encode, encode, encodeAsOpenType, equals, getNonParameterizedTypeName, getTypeName, indent, indent, isOpenType, matchTag, matchTag, pdiag, print, print, print, setNonParameterizedTypeName, setOpenType
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
public static final int OER
protected transient int mLength
protected transient Asn1EncodeBuffer mEncodeBuffer
protected int dataEncoding
protected static final java.lang.String EDATAMSG
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.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 implicitAsn1Exception
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 taggedAsn1Exception
public void decode(Asn1PerDecodeBuffer buffer) throws Asn1Exception, java.io.IOException
decode
in interface Asn1TypeIF
decode
in class Asn1OctetString
buffer
- Decode message buffer objectAsn1Exception
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 objectAsn1Exception
java.io.IOException
public void decode(Asn1OerDecodeBuffer buffer) throws java.io.IOException
decode
in class Asn1OctetString
java.io.IOException
public void encode(Asn1OerEncodeBuffer buffer) throws Asn1Exception, java.io.IOException
encode
in class Asn1OctetString
buffer
- Encode message buffer objectjava.io.IOException
- for I/O exceptionAsn1Exception
public void encodeAsExtension(Asn1XmlEncoder buffer) throws java.io.IOException, Asn1Exception
buffer
- Encode message buffer objectjava.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
- Ignoredjava.io.IOException
- Any exception thrown by the underlying stream.Asn1Exception
- Thrown, if operation is failed.public void encode(Asn1XmlEncoder buffer) throws java.io.IOException, Asn1Exception
buffer
- Encode message buffer objectjava.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
- Ignoredjava.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 objectjava.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 decode72(Asn1JsonDecodeBuffer buffer) throws java.io.IOException
buffer
- java.io.IOException
public void decode(Asn1JsonDecodeBuffer buffer) throws java.io.IOException
decode
in class Asn1OctetString
buffer
- java.io.IOException
public void encode72(Asn1JsonOutputStream outstream) throws java.io.IOException
outstream
- java.io.IOException
public void encode(Asn1JsonOutputStream outstream) throws java.io.IOException
Asn1OctetString
encode
in class Asn1OctetString
outstream
- The stream to encode to.java.io.IOException
- for I/O exceptionpublic 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 donejava.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 objectjava.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.