Top Description Fields Constructors Methods
org.bouncycastle.asn1

public abstract Class ASN1NumericString

extends ASN1Primitive
implements ASN1String
Class Inheritance
All Implemented Interfaces
org.bouncycastle.asn1.ASN1String
Known Direct Subclasses
org.bouncycastle.asn1.DERNumericString
Imports
java.io.IOException, org.bouncycastle.util.Arrays, .Strings

NumericString object - this is an ascii string of characters {0,1,2,3,4,5,6,7,8,9, }. ASN.1 NUMERIC-STRING object.

This is an ASCII string of characters {0,1,2,3,4,5,6,7,8,9} + space.

See X.680 section 37.2.

Explicit character set escape sequences are not allowed.

Field Summary

Modifier and TypeField and Description
pack-priv final byte[]
pack-priv static final ASN1UniversalType

Constructor Summary

AccessConstructor and Description
pack-priv
ASN1NumericString(String
the base string to wrap.
string
,
boolean
whether or not to check the string.
validate
)

Constructor with optional validation.

pack-priv
ASN1NumericString(byte[] contents, boolean clone)

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
asn1Equals(ASN1Primitive other)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.

pack-priv static ASN1NumericString
createPrimitive(byte[] contents)

pack-priv final void
encode(ASN1OutputStream out, boolean withTag)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encode.

pack-priv final boolean
encodeConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.

pack-priv final int
public static ASN1NumericString

Returns:

an ASN1NumericString instance, or null
getInstance
(Object
an ASN1NumericString or an object that can be converted into one.
obj
)

Return a Numeric string from the passed in object

public static ASN1NumericString

Returns:

an ASN1NumericString instance, or null.
getInstance
(ASN1TaggedObject
the tagged object holding the object we want
taggedObject
,
boolean
true if the object is meant to be explicitly tagged false otherwise.
explicit
)

Return an Numeric String from a tagged object.

public final byte[]
public final String
getString()

Implements org.bouncycastle.asn1.ASN1String.getString.

Return a Java String representation of this STRING type's content.

public final int
hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.hashCode.

Returns a hash code value for this object.

public static boolean

Returns:

true if numeric, false otherwise.
isNumericString
(String
string to validate.
str
)

Return true if the string can be represented as a NumericString ('0'..'9', ' ')

pack-priv static boolean
isNumericString(byte[] contents)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.bouncycastle.asn1.ASN1Primitive:
encodeToencodeToequalsequalsequalsfromByteArraytoASN1PrimitivetoDERObjecttoDLObject

Field Detail

contentsback to summary
pack-priv final byte[] contents
TYPEback to summary
pack-priv static final ASN1UniversalType TYPE

Constructor Detail

ASN1NumericStringback to summary
pack-priv ASN1NumericString(String string, boolean validate)

Constructor with optional validation.

Parameters
string:String

the base string to wrap.

validate:boolean

whether or not to check the string.

Exceptions
IllegalArgumentException:
if validate is true and the string contains characters that should not be in a NumericString.
ASN1NumericStringback to summary
pack-priv ASN1NumericString(byte[] contents, boolean clone)

Method Detail

asn1Equalsback to summary
pack-priv final boolean asn1Equals(ASN1Primitive other)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Doc from org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.

createPrimitiveback to summary
pack-priv static ASN1NumericString createPrimitive(byte[] contents)
encodeback to summary
pack-priv final void encode(ASN1OutputStream out, boolean withTag) throws IOException

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encode.

encodeConstructedback to summary
pack-priv final boolean encodeConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Doc from org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.

Returns:boolean

true if CONSTRUCTED bit set on object's tag, false otherwise.

encodedLengthback to summary
pack-priv final int encodedLength(boolean withTag)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodedLength.

getInstanceback to summary
public static ASN1NumericString getInstance(Object obj)

Return a Numeric string from the passed in object

Parameters
obj:Object

an ASN1NumericString or an object that can be converted into one.

Returns:ASN1NumericString

an ASN1NumericString instance, or null

Exceptions
IllegalArgumentException:
if the object cannot be converted.
getInstanceback to summary
public static ASN1NumericString getInstance(ASN1TaggedObject taggedObject, boolean explicit)

Return an Numeric String from a tagged object.

Parameters
taggedObject:ASN1TaggedObject

the tagged object holding the object we want

explicit:boolean

true if the object is meant to be explicitly tagged false otherwise.

Returns:ASN1NumericString

an ASN1NumericString instance, or null.

Exceptions
IllegalArgumentException:
if the tagged object cannot be converted.
getOctetsback to summary
public final byte[] getOctets()
getStringback to summary
public final String getString()

Implements org.bouncycastle.asn1.ASN1String.getString.

Doc from org.bouncycastle.asn1.ASN1String.getString.

Return a Java String representation of this STRING type's content.

Returns:String

a Java String representation of this STRING.

hashCodeback to summary
public final int hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

isNumericStringback to summary
public static boolean isNumericString(String str)

Return true if the string can be represented as a NumericString ('0'..'9', ' ')

Parameters
str:String

string to validate.

Returns:boolean

true if numeric, false otherwise.

isNumericStringback to summary
pack-priv static boolean isNumericString(byte[] contents)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object