Asn1Time Class Reference

Inheritance diagram for Asn1Time:
Asn18BitCharString Asn1CharString Asn1Type Asn1TypeIF Asn1GeneralizedTime Asn1UTCTime

List of all members.

Public Member Functions

 Asn1Time (System.String data, short typeCode, bool useDerRules)
 Asn1Time (short typeCode, bool useDerRules)
virtual void Clear ()
virtual int CompareTo (System.Object other)
override void Decode (Asn1PerDecodeBuffer buffer)
override void DecodeXML (System.String buffer, System.String attrs)
override void Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix)
override void Encode (Asn1PerOutputStream outs)
virtual void Encode (Asn1BerOutputStream outs, bool explicitTagging, Asn1Tag tag)
override void Encode (Asn1PerEncodeBuffer buffer)
void EncodeXER (Asn1XmlEncoder buffer, String elemName, String nsPrefix)
virtual void EncodeXMLData (Asn1XmlXerEncoder buffer)
override bool Equals (System.Object value)
virtual int GetDiff ()
override int GetHashCode ()
virtual System.DateTime GetTime ()
abstract void ParseString (System.String data)
virtual void ParseXmlString (System.String data)
virtual void SetDiff (int inMinutes)
virtual void SetDiff (int dhour, int dminute)
virtual void SetTime (System.DateTime time)

Static Public Member Functions

static void PutInteger (System.Text.StringBuilder data, int width, int value)

Public Attributes

const int Apr = 4
const int April = 4
const int Aug = 8
const int August = 8
const int Dec = 12
const int December = 12
const int Feb = 2
const int February = 2
const int Jan = 1
const int January = 1
const int Jul = 7
const int July = 7
const int Jun = 6
const int June = 6
const int Mar = 3
const int March = 3
const int May = 5
const int Nov = 11
const int November = 11
const int Oct = 10
const int October = 10
const int Sep = 9
const int September = 9

Protected Member Functions

abstract internal bool CompileString ()
internal override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength, Asn1Tag tag)
internal override int Encode (Asn1BerEncodeBuffer buffer, bool explicitTagging, Asn1Tag tag)
virtual internal void Init ()
virtual internal void PutInteger (int width, int value)
virtual internal void SafeParseString ()

Static Protected Member Functions

static internal char CharAt (System.String s, int index)
static internal int ParseInt (System.String str, IntHolder off, int len)

Protected Attributes

internal int day
internal bool derRules
internal int diffHour
internal int diffMin
internal int hour
internal int minute
internal int month
internal bool parsed
internal string secFraction
internal int second
internal bool utcFlag
internal int year

Properties

virtual bool [set]
virtual int Day [get, set]
virtual int DiffHour [get, set]
virtual int DiffMinute [get]
virtual string Fraction [get, set]
virtual int Hour [get, set]
virtual int Minute [get, set]
virtual int Month [get, set]
virtual int Second [get, set]
virtual bool UTC [get, set]
virtual int Year [get, set]

Detailed Description

This is a base class for holding the components of an ASN.1 generalized and universal times string value.


Constructor & Destructor Documentation

Asn1Time ( short  typeCode,
bool  useDerRules 
)

This constructor creates an empty time string object.

Parameters:
typeCode Integer constant from Asn1Type class (Asn1Type.GeneralTime or Asn1Type.UTCTime).
useDerRules 'true' if time string should be encoded with DER/PER.
See also:
<seealso cref=Asn1Type.GeneralTime GeneralTime code
<seealso cref=Asn1Type.UTCTime UTCTime code
Asn1Time ( System.String  data,
short  typeCode,
bool  useDerRules 
)

This constructor creates a time string from String value.

Parameters:
data String representation of time value
typeCode Integer constant from Asn1Type class (Asn1Type.GeneralTime or Asn1Type.UTCTime).
useDerRules 'true' if time string should be encoded with DER/PER.
See also:
<seealso cref=Asn1Type.GeneralTime GeneralTime code
<seealso cref=Asn1Type.UTCTime UTCTime code

Member Function Documentation

static internal char CharAt ( System.String  s,
int  index 
) [static, protected]

Returns the character at the specified index in the specified string. If index is out of bounds, then '\u0000' character will be returned.

Parameters:
s String value
index Index of Character in the string
Returns:
Character at the specified index. or '\u0000'.
virtual void Clear (  )  [virtual]

This method clears time string. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Reimplemented in Asn1UTCTime.

virtual int CompareTo ( System.Object  other  )  [virtual]

This method compares this object with Asn1Time class instance or with System.DateTime instance. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
other the Object to be compared.
Returns:
The difference in Ticks with the specified object.

Reimplemented in Asn1GeneralizedTime, and Asn1UTCTime.

abstract internal bool CompileString (  )  [protected, pure virtual]

Compiles new time string accoring X.680 (clauses 41, 42) and ISO 8601.

Returns:
true, if succeed, or false code, if error.

Implemented in Asn1GeneralizedTime, and Asn1UTCTime.

override void Decode ( Asn1PerDecodeBuffer  buffer  )  [virtual]

This method is the base implementation of the standard Packed Encoding Rules (PER) Decode method. It throws an exception because it should never be invoked by compiler generated code.

Parameters:
buffer PER Encode message buffer object

Reimplemented from Asn18BitCharString.

internal override void Decode ( Asn1BerDecodeBuffer  buffer,
bool  explicitTagging,
int  implicitLength,
Asn1Tag  tag 
) [protected, virtual]

This method decodes an ASN.1 Time value including the UNIVERSAL tag value and length if explicit tagging is specified. It is a protected method that can only be accessed by objects subclassed from this type.

Parameters:
buffer Decode message buffer object
explicitTagging Flag indicating element is explicitly tagged
implicitLength Length of contents if implicit
tag Universal tag to apply

Reimplemented from Asn1CharString.

override void DecodeXML ( System.String  buffer,
System.String  attrs 
)

This method decodes ASN.1 Time type, using the XML schema encoding rules(asn2xsd).

Parameters:
buffer String containing data to be decoded
attrs Attributes string from element tag

Reimplemented from Asn1CharString.

override void Encode ( Asn1XmlEncoder  buffer,
System.String  elemName,
System.String  nsPrefix 
) [virtual]

This method encodes ASN.1 time into xsd:dateTime format with element and namespace prefix tag according to the XML Encoding as specified in the XML schema standard(asn2xsd). This is for use with Obj-Sys XML encoding rules.

Parameters:
buffer Encode message buffer object
elemName XML element name used to wrap string
nsPrefix XML element namespace value

Reimplemented from Asn1CharString.

override void Encode ( Asn1PerOutputStream  outs  )  [virtual]

This method encodes and writes to stream an ASN.1 time string value using the standard Packed Encoding Rules (PER) encode method.

Also throws any exception thrown by the Asn1PerOutputStream.

Parameters:
outs PER Output Stream object
Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented from Asn18BitCharString.

virtual void Encode ( Asn1BerOutputStream  outs,
bool  explicitTagging,
Asn1Tag  tag 
) [virtual]

This method encodes and writes to the stream an ASN.1 time string value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Throws, Exception thrown by C# System.IO.Stream for I/O error

Parameters:
outs BER Output Stream object
explicitTagging Flag indicating explicit tagging should be done
tag Universal tag to apply
Exceptions:
Asn1Exception Thrown, if operation is failed.
override void Encode ( Asn1PerEncodeBuffer  buffer  )  [virtual]

This method is the base implementation of the standard Packed Encoding Rules (PER) encode method. It throws an exception because it should never be invoked by compiler generated code.

Parameters:
buffer PER Encode message buffer object

Reimplemented from Asn18BitCharString.

internal override int Encode ( Asn1BerEncodeBuffer  buffer,
bool  explicitTagging,
Asn1Tag  tag 
) [protected, virtual]

This method encodes ASN.1 time string type. The UNIVERSAL tag value and length is also encoded if explicit tagging is specified (the universal identifier must be provided by the caller).

Parameters:
buffer Encode message buffer object
explicitTagging Flag indicating explicit tagging should be done
tag Universal tag to apply
Returns:
Length in octets of encoded component

Reimplemented from Asn1CharString.

void EncodeXER ( Asn1XmlEncoder  buffer,
String  elemName,
String  nsPrefix 
)

This method encodes this ASN.1 time according to XER encoding rules. It is used by generated code when compiling for extended-XER.

Parameters:
buffer Encode message buffer object

<param name="elemName> XML element name used to wrap string

<param name="nsPrefix> Element namespace prefix value

virtual void EncodeXMLData ( Asn1XmlXerEncoder  buffer  )  [virtual]

This method encodes this ASN.1 time string into xsd:dateTime format.

XML dateTime format is YYYY-MM-DDTHH:MM:SS[.SSSS][(Z|(+|-) HH:MM)]

Parameters:
buffer String buffer to hold the converted xml time string
Exceptions:
Asn1Exception any exception exist in Asn.1 Generalized Time string
override bool Equals ( System.Object  value  ) 

This method compares this object with Asn1Time class instance or with Calendar instance. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
value The Object to compare with the current Object. Object should be instance of Asn1Time or System.DateTime.
Returns:
true if the specified Object is equal to the current Object; otherwise, false.

Reimplemented from Asn1CharString.

virtual int GetDiff (  )  [virtual]

This method returns the difference between the time zone of the object and Coordinated Universal Time (UTC), in minutes. The UTC time is the sum of the local time and positive or negative time difference. Note that the return value may differentiate for different inherited Asn1Time classes.

Returns:
The negative or positive difference, in minutes, between the time zone of the object and UTC time (-12*60..+12*60) is returned if the operation is successful.
Exceptions:
Asn1Exception Thrown, if operation is failed.
override int GetHashCode (  ) 

Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

Returns:
A hash code for the current Object.

Reimplemented from Asn1CharString.

virtual System.DateTime GetTime (  )  [virtual]

This method converts the time string to the System.DateTime value. If time represented as UTC time plus or minus difference time, then the result System.DateTime will ignore zone offset, as it doesn't support it. Note that the return value may differentiate for different inherited Asn1Time classes.

Returns:
The System.DateTime value.
virtual internal void Init (  )  [protected, virtual]

This method initializes the Asn1Time class member variables.

Reimplemented in Asn1UTCTime.

static internal int ParseInt ( System.String  str,
IntHolder  off,
int  len 
) [static, protected]

Parses integer value from String.

Parameters:
str string is containing integer to be parsed.
off The offset in array at which to begin parse.
len number of digits to be parsed.
Returns:
Parsed integer value.
abstract void ParseString ( System.String  data  )  [pure virtual]

This method parses passed time string. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
data String representation of Time to be parsed.
Exceptions:
Asn1Exception Thrown, if operation is failed.

Implemented in Asn1GeneralizedTime, and Asn1UTCTime.

virtual void ParseXmlString ( System.String  data  )  [virtual]

This method parses the given time string value. String must be in XML schema dateTime format. It will throw and exception if the string is not in the valid time format.

Parameters:
data The time string value to be parsed.
Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual internal void PutInteger ( int  width,
int  value 
) [protected, virtual]

Puts integer in string buffer

Parameters:
width number of digits
value value to be put
static void PutInteger ( System.Text.StringBuilder  data,
int  width,
int  value 
) [static]

Puts integer in string buffer

Parameters:
data destination buffer
width number of digits in integer value
value integer value to be added
virtual internal void SafeParseString (  )  [protected, virtual]

This method internally calls the ParseString method for this class. But will not throwing any exception, if error in string format.

virtual void SetDiff ( int  inMinutes  )  [virtual]

This method sets the difference between the time zone of the object and Coordinated Universal Time (UTC), in minutes. The UTC time is the sum of the local time and positive or negative time difference. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
inMinutes The negative or positive difference, in minutes, between the time zone of the object and UTC time (-12*60..+12*60).
Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual void SetDiff ( int  dhour,
int  dminute 
) [virtual]

This method sets the hour and minute components of the difference between the time zone of the object and Coordinated Universal Time (UTC). The UTC time is the sum of the local time and positive or negative time difference. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
dhour The negative or positive hour component of the difference between the time zone of the object and UTC time (-12..+12).
dminute The negative or positive minute component of the difference between the time zone of the object and UTC time (-59..+59).
Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual void SetTime ( System.DateTime  time  )  [virtual]

This method converts the System.DateTime value to time string. Note that the action of this method may differentiate for different inherited Asn1Time classes.

Parameters:
time The System.DateTime time value.
Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented in Asn1UTCTime.


Member Data Documentation

const int Apr = 4

Constant to represent April month

const int April = 4

Constant to represent April month

const int Aug = 8

Constant to represent August month

const int August = 8

Constant to represent August month

internal int day [protected]

Day of month component. Legal interval is 1..31.

const int Dec = 12

Constant to represent December month

const int December = 12

Constant to represent December month

internal bool derRules [protected]

Indicates DER is used (or CER/PER).

internal int diffHour [protected]

Zone offset's hour component. Legal interval is -12..+12.

internal int diffMin [protected]

Zone offset's minute component. Legal interval is -59..+59.

const int Feb = 2

Constant to represent February month

const int February = 2

Constant to represent February month

internal int hour [protected]

Hour component. Legal interval is 0..23.

const int Jan = 1

Constant to represent January month

const int January = 1

Constant to represent January month

const int Jul = 7

Constant to represent July month

const int July = 7

Constant to represent July month

const int Jun = 6

Constant to represent June month

const int June = 6

Constant to represent June month

const int Mar = 3

Constant to represent March month

const int March = 3

Constant to represent March month

const int May = 5

Constant to represent May month

internal int minute [protected]

Minute component. Legal interval is 0..59.

internal int month [protected]

Month component. Legal interval is 1..12.

const int Nov = 11

Constant to represent November month

const int November = 11

Constant to represent November month

const int Oct = 10

Constant to represent October month

const int October = 10

Constant to represent October month

internal bool parsed [protected]

Indicates string parsed or not.

internal string secFraction [protected]

Second's fraction component. Legal interval is 0..INF.

internal int second [protected]

Second component. Legal interval is 0..59.

const int Sep = 9

Constant to represent September month

const int September = 9

Constant to represent September month

internal bool utcFlag [protected]

Indicates UTC flag ('Z') set or not.

internal int year [protected]

Year component. Legal interval is 0..9999.


Property Documentation

virtual bool [set]

Sets the 'use DER' flag which enforces the DER rules when time strings are constructed or parsed.

Value: true for DER rule; otherwise false

virtual int Day [get, set]

Gets or Sets the day of month number component of the time value. The number of the first day in month is 1, the number of the last day may be in interval from 28 to 31. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Day of month component (1..31)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int DiffHour [get, set]

Gets or Sets the hour component of the difference between the time zone of the object and Coordinated Universal Time (UTC). The UTC time is the sum of the local time and positive or negative time difference. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: The negative or positive hour component of the difference between the time zone of the object and UTC time (-12..+12)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int DiffMinute [get]

Gets or Sets the minute component of the difference between the time zone of the object and Coordinated Universal Time (UTC). The UTC time is the sum of the local time and positive or negative time difference. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: The negative or positive minute component of the difference between the time zone of the object and UTC time (-59..+59)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual string Fraction [get, set]

Gets or Sets the second's decimal fraction component of the time value. Second's decimal fraction is represented by one digit from 0 to 9. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Second's decimal fraction component (0..9)

Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented in Asn1UTCTime.

virtual int Hour [get, set]

Gets or Sets the hour component of the time value. As the ISO 8601 is based on the 24-hour timekeeping system, two digits represent hours from 00 to 23. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Hour component (0..23)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int Minute [get, set]

Gets or Sets the minute component of the time value. Minutes are represented by two digits from 00 to 59. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Minute component (0..59)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int Month [get, set]

Gets or Sets the month number component of the time value. The number of January is 1, February - 2, December - 12. You may use enumerating values for months decoding: Asn1Time.January, Asn1Time.February, etc. Also you can use short aliases for months: Asn1Time.Jan, Asn1Time.Feb, etc. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Month component (1..12)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int Second [get, set]

Gets or Sets the second component of the time value. Seconds are represented by two digits from 00 to 59. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Second component (0..59)

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual bool UTC [get, set]

Gets or Sets the UTC flag state. If the UTC flag is true, then the time is an UTC time and symbol 'Z' is added at the end of time string. Otherwise, it is a local time.

Value: UTC flag state.

Exceptions:
Asn1Exception Thrown, if operation is failed.
virtual int Year [get, set]

Gets or Sets the year component of the time value. Note that the behaviour value may differentiate for different inherited Asn1Time classes.

Value: Year component (full 4 digits).

Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented in Asn1UTCTime.