- java.lang.Object
-
- org.snmp4j.smi.AbstractVariable
-
- org.snmp4j.smi.UnsignedInteger32
-
- org.snmp4j.smi.TimeTicks
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<Variable>
,BERSerializable
,AssignableFromLong
,AssignableFromString
,Variable
public class TimeTicks extends UnsignedInteger32
TheTimeTicks
class represents the time in 1/100 seconds since some epoch (which should be have been defined in the corresponding MIB specification).- Version:
- 1.7
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static int[]
FORMAT_FACTORS
private static java.lang.String
FORMAT_PATTERN
private static long
serialVersionUID
-
Fields inherited from class org.snmp4j.smi.UnsignedInteger32
value
-
Fields inherited from class org.snmp4j.smi.AbstractVariable
SMISYNTAXES_PROPERTIES
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Clones this variable.void
decodeBER(BERInputStream inputStream)
Decodes aVariable
from anBERInputStream
.void
encodeBER(java.io.OutputStream os)
Encodes aVariable
to anOutputStream
.void
fromMilliseconds(long millis)
Sets the timeticks value by milliseconds.int
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.void
setValue(java.lang.String value)
Sets the value of this TimeTicks instance from a string.long
toMilliseconds()
Returns the timeticks value as milliseconds (instead 1/100 seconds).java.lang.String
toString()
Returns string with the value of thisTimeTicks
object as "[days,]hh:mm:ss.hh".java.lang.String
toString(java.lang.String pattern)
Formats the content of thisTimeTicks
object according to a suppliedMessageFormat
pattern.-
Methods inherited from class org.snmp4j.smi.UnsignedInteger32
compareTo, equals, fromSubIndex, getBERLength, getBERLengthFromValue, getValue, hashCode, setValue, toInt, toLong, toSubIndex
-
Methods inherited from class org.snmp4j.smi.AbstractVariable
createFromBER, createFromSyntax, equal, getBERPayloadLength, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
FORMAT_PATTERN
private static final java.lang.String FORMAT_PATTERN
- See Also:
- Constant Field Values
-
FORMAT_FACTORS
private static final int[] FORMAT_FACTORS
-
-
Constructor Detail
-
TimeTicks
public TimeTicks()
-
TimeTicks
public TimeTicks(TimeTicks other)
Copy constructor.- Parameters:
other
- a TimeTicks instance.- Since:
- 1.7
-
TimeTicks
public TimeTicks(long value)
-
-
Method Detail
-
clone
public java.lang.Object clone()
Description copied from interface:Variable
Clones this variable. Cloning can be used by the SNMP4J API to better support concurrency by creating a clone for internal processing. The content of this object is independent to the content of the clone. Thus, changes to the clone will have no effect to this object.- Specified by:
clone
in interfaceVariable
- Overrides:
clone
in classUnsignedInteger32
- Returns:
- a new instance of this
Variable
with the same value.
-
getSyntax
public int getSyntax()
Description copied from class:AbstractVariable
Gets the ASN.1 syntax identifier value of this SNMP variable.- Specified by:
getSyntax
in interfaceVariable
- Overrides:
getSyntax
in classUnsignedInteger32
- Returns:
- an integer value less than 128 for regular SMI objects and a value greater or equal than 128 for exception values like noSuchObject, noSuchInstance, and endOfMibView.
-
encodeBER
public void encodeBER(java.io.OutputStream os) throws java.io.IOException
Description copied from class:AbstractVariable
Encodes aVariable
to anOutputStream
.- Specified by:
encodeBER
in interfaceBERSerializable
- Overrides:
encodeBER
in classUnsignedInteger32
- Parameters:
os
- anOutputStream
.- Throws:
java.io.IOException
- if an error occurs while writing to the stream.
-
decodeBER
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
Description copied from class:AbstractVariable
Decodes aVariable
from anBERInputStream
.- Specified by:
decodeBER
in interfaceBERSerializable
- Overrides:
decodeBER
in classUnsignedInteger32
- Parameters:
inputStream
- anBERInputStream
containing a BER encoded byte stream.- Throws:
java.io.IOException
- if the stream could not be decoded by using BER rules.
-
toString
public java.lang.String toString()
Returns string with the value of thisTimeTicks
object as "[days,]hh:mm:ss.hh".- Specified by:
toString
in interfaceVariable
- Overrides:
toString
in classUnsignedInteger32
- Returns:
- a
String
representation of this object.
-
setValue
public final void setValue(java.lang.String value)
Sets the value of this TimeTicks instance from a string.- Specified by:
setValue
in interfaceAssignableFromString
- Overrides:
setValue
in classUnsignedInteger32
- Parameters:
value
- a string representation of this value, which is (a) is either an unsigned number or (b) matches the formatFORMAT_PATTERN
.- Since:
- 2.1.2
-
toString
public java.lang.String toString(java.lang.String pattern)
Formats the content of thisTimeTicks
object according to a suppliedMessageFormat
pattern.- Parameters:
pattern
- aMessageFormat
pattern that takes up to five parameters which are: days, hours, minutes, seconds, and 1/100 seconds.- Returns:
- the formatted string representation.
-
toMilliseconds
public long toMilliseconds()
Returns the timeticks value as milliseconds (instead 1/100 seconds).- Returns:
getValue()*10
.- Since:
- 1.7
-
fromMilliseconds
public void fromMilliseconds(long millis)
Sets the timeticks value by milliseconds.- Parameters:
millis
- sets the value assetValue(millis/10)
.- Since:
- 1.7
-
-