com.marklogic.xdbc
Class XDBCDuration

java.lang.Object
  extended bycom.marklogic.xdbc.XDBCDuration

public class XDBCDuration
extends Object

A duration represents an XQuery duration primitive type.


Field Summary
static int XDBC_DURATION_NEGATIVE
          Indicates a negative duration.
static int XDBC_DURATION_POSITIVE
          Indicates a positive duration.
 
Constructor Summary
XDBCDuration()
          Constructor for an empty duration object.
XDBCDuration(int sign, int years, int months, int days, int hours, int minutes, int seconds, double subseconds)
          Constructor for a duration object which takes each individual value part and returns an duration object with the valuess set.
XDBCDuration(String duration)
          Constructor for a duration object which takes a duration string and parses it into the object representation.
 
Method Summary
 boolean equals(XDBCDuration duration)
          Compares this XDBCDuration object to the specified object.
 int getDays()
          Returns the days value of this duration.
 int getHours()
          Returns the hours value of this duration.
 int getMinutes()
          Returns the minutes value of this duration.
 int getMonths()
          Returns the months value of this duration.
 int getSeconds()
          Returns the seconds value of this duration.
 int getSign()
          Returns the sign of this duration, either positive or negative.
 double getSubSeconds()
          Returns the fractional portion of the seconds value of this duration as a Java double.
 int getYears()
          Returns the years value of this duration.
 void setDays(int days)
          Sets the days value of this duration.
 void setHours(int hours)
          Sets the hours value of this duration.
 void setMinutes(int minutes)
          Sets the minutes value of this duration.
 void setMonths(int months)
          Sets the months value of this duration.
 void setSeconds(int seconds)
          Sets the seconds value of this duration.
 void setSign(int sign)
          Sets the sign of this duration, either positive or negative.
 void setSubSeconds(double subseconds)
          Sets the fractional portion of the seconds value of this duration as a Java double.
 void setYears(int years)
          Sets the years value of this duration.
 String toString()
          Formats this duration object as a String in the format prescribed in the W3C description of XML datatypes for a duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XDBC_DURATION_POSITIVE

public static final int XDBC_DURATION_POSITIVE
Indicates a positive duration.

See Also:
Constant Field Values

XDBC_DURATION_NEGATIVE

public static final int XDBC_DURATION_NEGATIVE
Indicates a negative duration.

See Also:
Constant Field Values
Constructor Detail

XDBCDuration

public XDBCDuration()
Constructor for an empty duration object.


XDBCDuration

public XDBCDuration(String duration)
Constructor for a duration object which takes a duration string and parses it into the object representation.


XDBCDuration

public XDBCDuration(int sign,
                    int years,
                    int months,
                    int days,
                    int hours,
                    int minutes,
                    int seconds,
                    double subseconds)
Constructor for a duration object which takes each individual value part and returns an duration object with the valuess set.

Method Detail

getSign

public int getSign()
Returns the sign of this duration, either positive or negative.

Returns:
XDBC_DURATION_POSITIVE if the duration is a positive value, or XDBC_DURATION_NEGATIVE if the duration is a negative value.

getYears

public int getYears()
Returns the years value of this duration.

Returns:
the years value.

getMonths

public int getMonths()
Returns the months value of this duration.

Returns:
the months value.

getDays

public int getDays()
Returns the days value of this duration.

Returns:
the int days value.

getHours

public int getHours()
Returns the hours value of this duration.

Returns:
the int hours value.

getMinutes

public int getMinutes()
Returns the minutes value of this duration.

Returns:
the int minutes value.

getSeconds

public int getSeconds()
Returns the seconds value of this duration.

Returns:
the int seconds value.

getSubSeconds

public double getSubSeconds()
Returns the fractional portion of the seconds value of this duration as a Java double.

Returns:
the double representation of the fractional seconds.

setSign

public void setSign(int sign)
Sets the sign of this duration, either positive or negative.

Parameters:
sign - XDBC_DURATION_POSITIVE if the duration is a positive value, or XDBC_DURATION_NEGATIVE if the duration is a negative value.

setYears

public void setYears(int years)
Sets the years value of this duration.

Parameters:
years - the integer years value.

setMonths

public void setMonths(int months)
Sets the months value of this duration.

Parameters:
months - the integer months value.

setDays

public void setDays(int days)
Sets the days value of this duration.

Parameters:
days - the integer days value.

setHours

public void setHours(int hours)
Sets the hours value of this duration.

Parameters:
hours - the integer hours value.

setMinutes

public void setMinutes(int minutes)
Sets the minutes value of this duration.

Parameters:
minutes - the integer minutes value.

setSeconds

public void setSeconds(int seconds)
Sets the seconds value of this duration.

Parameters:
seconds - the integer seconds value.

setSubSeconds

public void setSubSeconds(double subseconds)
Sets the fractional portion of the seconds value of this duration as a Java double.

Parameters:
subseconds - the double representation of the fractional seconds.

equals

public boolean equals(XDBCDuration duration)
Compares this XDBCDuration object to the specified object. The result is true if and only if the argument is not null and the sign, year, month, day, hours, minutes, seconds and subseconds values have the same value as this object.

Parameters:
duration - the XDBCDuration object to compare
Returns:
true if the objects have the same duration value, false otherwise.

toString

public String toString()
Formats this duration object as a String in the format prescribed in the W3C description of XML datatypes for a duration. Example: -P2Y4M5DT3H5M42.057S Represents a duration of minus 2 years, 4 months, 5 days, 3 hours, 5 minutes, and 42.057 seconds.

Returns:
the String representation of the duration value.
See Also: