org.basex.query.value.item
Class Dur

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.value.Value
              extended by org.basex.query.value.item.Item
                  extended by org.basex.query.value.item.ADateDur
                      extended by org.basex.query.value.item.Dur
All Implemented Interfaces:
java.lang.Iterable<Item>
Direct Known Subclasses:
DTDur, YMDur

public class Dur
extends ADateDur

Duration item (xs:duration).

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
protected static java.lang.String DP
          Pattern for one or more digits.
 
Fields inherited from class org.basex.query.value.item.ADateDur
BD100, BD1000, BD146097, BD1461, BD153, BD2, BD3600, BD365, BD36524, BD36525, BD366, BD4, BD5, BD60, BDMAXLONG, DAYSECONDS, sec
 
Fields inherited from class org.basex.query.value.item.Item
score, UNDEF
 
Fields inherited from class org.basex.query.value.Value
type
 
Constructor Summary
Dur(byte[] v, InputInfo ii)
          Constructor.
Dur(Dur d)
          Constructor.
 
Method Summary
protected  void date(TokenBuilder tb)
          Adds the date to the specified token builder.
 long day()
          Returns the days.
protected  void dayTime(byte[] vl, java.util.regex.Matcher mt, int p, InputInfo ii)
          Initializes the dayTime component.
 int diff(Item it, Collation coll, InputInfo ii)
          Returns the difference between the current and the specified item.
 boolean eq(Item it, Collation coll, InputInfo ii)
          Checks the items for equality.
 int hash(InputInfo ii)
          Returns a hash code for this value.
 long hou()
          Returns the hours (0-23).
 long min()
          Returns the minutes (0-59).
 long mon()
          Returns the months.
 java.math.BigDecimal sec()
          Returns the seconds (0-59), including the fractional part.
 byte[] string(InputInfo ii)
          Returns a string representation of the value.
protected  void time(TokenBuilder tb)
          Adds the time to the specified token builder.
 javax.xml.datatype.Duration toJava()
          Returns a Java representation of the value.
 java.lang.String toString()
           
 long yea()
          Returns the years.
protected  void yearMonth(byte[] vl, java.util.regex.Matcher mt, InputInfo ii)
          Initializes the yearMonth component.
 
Methods inherited from class org.basex.query.value.item.ADateDur
dateErr, toDecimal, toLong
 
Methods inherited from class org.basex.query.value.item.Item
bool, castErr, comparable, dbl, dec, description, ebv, equiv, flt, homogeneous, input, isItem, item, itemAt, iter, iterable, itr, materialize, plan, score, score, size, test, type, typeId, writeTo, xdmInfo
 
Methods inherited from class org.basex.query.value.Value
accept, cache, checkUp, compile, copy, count, data, exprSize, has, inline, isValue, iter, iterator, removable, serialize, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isEmpty, isFunction, isVacuous, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, info, planAttr, planElem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DP

protected static final java.lang.String DP
Pattern for one or more digits.

See Also:
Constant Field Values
Constructor Detail

Dur

public Dur(byte[] v,
           InputInfo ii)
    throws QueryException
Constructor.

Parameters:
v - value
ii - input info
Throws:
QueryException - query exception

Dur

public Dur(Dur d)
Constructor.

Parameters:
d - duration
Method Detail

yearMonth

protected void yearMonth(byte[] vl,
                         java.util.regex.Matcher mt,
                         InputInfo ii)
                  throws QueryException
Initializes the yearMonth component.

Parameters:
vl - value
mt - matcher
ii - input info
Throws:
QueryException - query exception

dayTime

protected void dayTime(byte[] vl,
                       java.util.regex.Matcher mt,
                       int p,
                       InputInfo ii)
                throws QueryException
Initializes the dayTime component.

Parameters:
vl - value
mt - matcher
p - first matching position
ii - input info
Throws:
QueryException - query exception

yea

public final long yea()
Description copied from class: ADateDur
Returns the years.

Specified by:
yea in class ADateDur
Returns:
year

mon

public final long mon()
Description copied from class: ADateDur
Returns the months.

Specified by:
mon in class ADateDur
Returns:
year

day

public final long day()
Description copied from class: ADateDur
Returns the days.

Specified by:
day in class ADateDur
Returns:
day

hou

public final long hou()
Description copied from class: ADateDur
Returns the hours (0-23).

Specified by:
hou in class ADateDur
Returns:
day

min

public final long min()
Description copied from class: ADateDur
Returns the minutes (0-59).

Specified by:
min in class ADateDur
Returns:
day

sec

public final java.math.BigDecimal sec()
Description copied from class: ADateDur
Returns the seconds (0-59), including the fractional part.

Specified by:
sec in class ADateDur
Returns:
day

string

public byte[] string(InputInfo ii)
Description copied from class: Item
Returns a string representation of the value.

Specified by:
string in class Item
Parameters:
ii - input info, use null if none is available
Returns:
string value

date

protected final void date(TokenBuilder tb)
Adds the date to the specified token builder.

Parameters:
tb - token builder

time

protected final void time(TokenBuilder tb)
Adds the time to the specified token builder.

Parameters:
tb - token builder

eq

public final boolean eq(Item it,
                        Collation coll,
                        InputInfo ii)
                 throws QueryException
Description copied from class: Item
Checks the items for equality.

Specified by:
eq in class Item
Parameters:
it - item to be compared
coll - collation
ii - input info
Returns:
result of check
Throws:
QueryException - query exception

diff

public int diff(Item it,
                Collation coll,
                InputInfo ii)
         throws QueryException
Description copied from class: Item
Returns the difference between the current and the specified item.

Overrides:
diff in class Item
Parameters:
it - item to be compared
coll - query context
ii - input info
Returns:
difference
Throws:
QueryException - query exception

toJava

public final javax.xml.datatype.Duration toJava()
Description copied from class: Value
Returns a Java representation of the value.

Specified by:
toJava in class Value
Returns:
Java object

hash

public final int hash(InputInfo ii)
Description copied from class: Value
Returns a hash code for this value.

Overrides:
hash in class Item
Parameters:
ii - input info
Returns:
hash code

toString

public final java.lang.String toString()
Specified by:
toString in class ExprInfo