com.objsys.asn1j.runtime
Class Asn1UTCTime

java.lang.Object
  extended by com.objsys.asn1j.runtime.Asn1Type
      extended by com.objsys.asn1j.runtime.Asn1CharString
          extended by com.objsys.asn1j.runtime.Asn18BitCharString
              extended by com.objsys.asn1j.runtime.Asn1Time
                  extended by com.objsys.asn1j.runtime.Asn1UTCTime
All Implemented Interfaces:
Asn1TypeIF, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class Asn1UTCTime
extends Asn1Time

This is a container class for holding the components of an ASN.1 UTC time string value.

See Also:
Serialized Form

Field Summary
static Asn1Tag TAG
          The TAG constant describes the universal tag for this data type (UNIVERSAL 23).
 
Fields inherited from class com.objsys.asn1j.runtime.Asn1Time
Apr, April, Aug, August, day, Dec, December, derRules, diffHour, diffMin, Feb, February, hour, Jan, January, Jul, July, Jun, June, Mar, March, May, minute, month, Nov, November, Oct, October, parsed, secFraction, second, Sep, September, utcFlag, year
 
Fields inherited from class com.objsys.asn1j.runtime.Asn18BitCharString
BITSPERCHAR_A, BITSPERCHAR_U
 
Fields inherited from class com.objsys.asn1j.runtime.Asn1CharString
mStringBuffer, 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
Asn1UTCTime()
          The default constructor creates an empty time string object.
Asn1UTCTime(boolean useDerRules)
          This constructor creates an empty time string object and allows DER encoding rules to be specified.
Asn1UTCTime(java.lang.String data)
          This version of the constructor can be used to set the string value member variable to the given time string.
Asn1UTCTime(java.lang.String data, boolean useDerRules)
          This version of the constructor can be used to set the string value member variable to the given time string and specify DER encoding rules be used to construct the string.
 
Method Summary
 void clear()
          Clears out time string.
protected  boolean compileString()
          Compiles new time string according to X.680 (clause 42) and ISO 8601.
 void decode(Asn1BerDecodeBuffer buffer, boolean explicit, int implicitLength)
          This method decodes an ASN.1 string value including the UNIVERSAL tag value and length if explicit tagging is specified.
 int encode(Asn1BerEncodeBuffer buffer, boolean explicit)
          This method encodes an ASN.1 string type.
 void encode(Asn1BerOutputStream out, boolean explicit)
          This method encodes and writes to the stream an ASN.1 UTC time string value including the UNIVERSAL tag value and length if explicit tagging is specified.
 boolean equals(java.lang.String s)
          This method compares this object with a String value.
 java.lang.String getFraction()
          This method always returns zero for this class.
protected  void init()
           
 void parseString(java.lang.String string)
          This method parses passed time string.
 void setFraction(java.lang.String fraction)
          This method is not supported for UTC time.
 void setTime(java.util.Calendar time)
          This method converts the java.util.Calendar value to time string.
 void setYear(int year)
          This method sets the year component of the time value.
 
Methods inherited from class com.objsys.asn1j.runtime.Asn1Time
charAt, compareTo, decode, decode, decodeXML, encode, encode, encode, encode, encode, encodeXER, encodeXMLData, equals, getDay, getDiff, getDiffHour, getDiffMinute, getHour, getMinute, getMonth, getSecond, getTime, getUTC, getYear, parseInt, parseXmlString, putInteger, putInteger, safeParseString, setDay, setDER, setDiff, setDiff, setDiffHour, setHour, setMinute, setMonth, setSecond, setUTC
 
Methods inherited from class com.objsys.asn1j.runtime.Asn18BitCharString
decode, decode, encode, encode, encode, encode
 
Methods inherited from class com.objsys.asn1j.runtime.Asn1CharString
decode, decode, decode, decodeXER, encode, encode, encode, encode, getAsn1TypeName, getLength, hashCode, toString, validate
 
Methods inherited from class com.objsys.asn1j.runtime.Asn1Type
clone, decode, decode, decode, decode, decode, encode, 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

TAG

public static final Asn1Tag TAG
The TAG constant describes the universal tag for this data type (UNIVERSAL 23).

Constructor Detail

Asn1UTCTime

public Asn1UTCTime()
The default constructor creates an empty time string object.


Asn1UTCTime

public Asn1UTCTime(boolean useDerRules)
This constructor creates an empty time string object and allows DER encoding rules to be specified.

Parameters:
useDerRules - 'true' if time string should be encoded with DER/PER.

Asn1UTCTime

public Asn1UTCTime(java.lang.String data)
This version of the constructor can be used to set the string value member variable to the given time string.

Parameters:
data - Character string containing UTC time value to be set. The format of the string is YYYYMMDDHH[MM](Z|(+|-)HH(MM))

Asn1UTCTime

public Asn1UTCTime(java.lang.String data,
                   boolean useDerRules)
This version of the constructor can be used to set the string value member variable to the given time string and specify DER encoding rules be used to construct the string.

Parameters:
data - Character string containing UTC time value to be set. The format of the string is YYYYMMDDHH[MM](Z|(+|-)HH(MM))
useDerRules - 'true' if time string should be encoded with DER/PER.
Method Detail

init

protected void init()
Overrides:
init in class Asn1Time

equals

public boolean equals(java.lang.String s)
This method compares this object with a String value. Strictly speaking, the contract of equals stipulates identity: a.equals(b) iff b.equals(a). However, it is never the case that a String will equal an Asn1Time object. In this case, then, equals should be taken to mean that the time represented by the string passed in is the same time as the object to which it is compared.

Specified by:
equals in class Asn1Time
Parameters:
s -

decode

public void decode(Asn1BerDecodeBuffer buffer,
                   boolean explicit,
                   int implicitLength)
            throws Asn1Exception,
                   java.io.IOException
This method decodes an ASN.1 string value including the UNIVERSAL tag value and length if explicit tagging is specified.

Specified by:
decode in interface Asn1TypeIF
Overrides:
decode in class Asn1Type
Parameters:
buffer - Decode message buffer object
explicit - Flag indicating element is explicitly tagged
implicitLength - Length of contents if implicit
Throws:
Asn1Exception
java.io.IOException

encode

public int encode(Asn1BerEncodeBuffer buffer,
                  boolean explicit)
           throws Asn1Exception
This method encodes an ASN.1 string type. The UNIVERSAL tag value and length is also encoded if explicit tagging is specified.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
explicit - Flag indicating explicit tagging should be done
Returns:
Length in octets of encoded component
Throws:
Asn1Exception

clear

public void clear()
Clears out time string.

Overrides:
clear in class Asn1Time

setYear

public void setYear(int year)
             throws Asn1Exception
This method sets the year component of the time value. You may pass 'year' parameter either as two last digits of the year (00 - 99) or as full 4 digits (0 - 9999). Note 'getYear' method returns year in full 4 digits format, independently of format of 'year' parameter for 'setYear' method.

Overrides:
setYear in class Asn1Time
Parameters:
year - Year component (full 4 digits).
Throws:
Asn1Exception - Thrown, if operation is failed.

setFraction

public void setFraction(java.lang.String fraction)
                 throws Asn1Exception
This method is not supported for UTC time.

Overrides:
setFraction in class Asn1Time
Parameters:
fraction - Any integer value.
Throws:
Asn1Exception - Always is thrown.

getFraction

public java.lang.String getFraction()
                             throws Asn1Exception
This method always returns zero for this class.

Overrides:
getFraction in class Asn1Time
Returns:
Zero.
Throws:
Asn1Exception - Thrown, if operation is failed.

setTime

public void setTime(java.util.Calendar time)
             throws Asn1Exception
This method converts the java.util.Calendar value to time string. Note that the action of this method may be different for different inherited Asn1Time classes.

Overrides:
setTime in class Asn1Time
Parameters:
time - The calendar time value.
Throws:
Asn1Exception - Thrown, if operation is failed.

parseString

public void parseString(java.lang.String string)
                 throws Asn1Exception
This method parses passed time string.

Specified by:
parseString in class Asn1Time
Parameters:
string - Character string containing UTC time value to be parsed. The format of the string is YYYYMMDDHH[MM](Z|(+|-)HH(MM))
Throws:
Asn1Exception - Thrown if format of string is not correct.

compileString

protected boolean compileString()
                         throws Asn1Exception
Compiles new time string according to X.680 (clause 42) and ISO 8601.

Specified by:
compileString in class Asn1Time
Returns:
true, if succeed, or false code, if error.
Throws:
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1BerOutputStream out,
                   boolean explicit)
            throws Asn1Exception,
                   java.io.IOException
This method encodes and writes to the stream an ASN.1 UTC time string value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
out - BER Output Stream object
explicit - Flag indicating explicit tagging should be done
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Thrown, if operation is failed.