org.obe.xpdl.model.misc
Class Duration

java.lang.Object
  extended byorg.obe.util.AbstractBean
      extended byorg.obe.xpdl.model.misc.Duration
All Implemented Interfaces:
java.beans.beancontext.BeanContextChild, java.io.Serializable

public final class Duration
extends AbstractBean

See Also:
Serialized Form

Constructor Summary
Duration()
          Default public no-args constructor to keep Castor happy.
Duration(int value, DurationUnit unit)
          Construct a new Duration.
Duration(java.lang.String duration)
          Construct a new Duration.
 
Method Summary
 java.lang.String getDuration()
          Returns the duration as a string.
 long getDurationInMilliseconds(DurationUnit defaultUnit)
          Get the duration represented as millseconds.
 DurationUnit getUnit()
          Return this duration's unit.
 DurationUnit getUnit(DurationUnit defaultUnit)
          Get the duration's unit.
 int getValue()
          The duration value.
 void setDuration(java.lang.String duration)
          Sets the duration as a string.
 void setUnit(DurationUnit unit)
           
 void setValue(int value)
           
 java.lang.String toString()
          Return a String representation of the Duration.
static Duration valueOf(java.lang.String duration)
          Parse the duration string into a Duration object.
 
Methods inherited from class org.obe.util.AbstractBean
add, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clear, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, get, get, getBeanContext, getListModel, hasChangeListeners, hasVetoListeners, remove, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, set, set, setBeanContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Duration

public Duration()
Default public no-args constructor to keep Castor happy.


Duration

public Duration(int value,
                DurationUnit unit)
Construct a new Duration. A value of 0 signals an unlimited duration. The duration unit may be null to specify that the default should be used. The default is determined at runtime.

Parameters:
value - The duration value
unit - The unit of measurement

Duration

public Duration(java.lang.String duration)
         throws java.lang.NumberFormatException
Construct a new Duration.

Parameters:
duration - The duration value
Throws:
java.lang.NumberFormatException
Method Detail

getDuration

public java.lang.String getDuration()
Returns the duration as a string.

Returns:
The duration string.

setDuration

public void setDuration(java.lang.String duration)
Sets the duration as a string.

Parameters:
duration - The duration string.

getValue

public int getValue()
The duration value.

Returns:
The duration value

setValue

public void setValue(int value)

getUnit

public DurationUnit getUnit()
Return this duration's unit. This method may return null if the unit is not specified.

Returns:
The duration unit or null

setUnit

public void setUnit(DurationUnit unit)

getUnit

public DurationUnit getUnit(DurationUnit defaultUnit)
Get the duration's unit. The specified default duration unit is used if this duration has no specified duration unit.

Parameters:
defaultUnit - The default unit if no unit specified
Returns:
The duration unit

getDurationInMilliseconds

public long getDurationInMilliseconds(DurationUnit defaultUnit)
Get the duration represented as millseconds. The specified default duration unit is used this duration has no specified duration unit.

Parameters:
defaultUnit - The default unit if no unit specified
Returns:
The number of milliseconds for this duration

toString

public java.lang.String toString()
Return a String representation of the Duration.

Returns:
A string

valueOf

public static Duration valueOf(java.lang.String duration)
                        throws java.lang.NumberFormatException
Parse the duration string into a Duration object.

Parameters:
duration - The duration string.
Returns:
The Duration object.
Throws:
java.lang.NumberFormatException


SourceForge.net Logo OBE-1.0 Copyright (c) 2002-2006 Adrian Price. All Rights Reserved.