org.basex.query.value.item
Class ADate

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.ADate
All Implemented Interfaces:
java.lang.Iterable<Item>
Direct Known Subclasses:
Dat, Dtm, GDt, Tim

public abstract class ADate
extends ADateDur

Abstract super class for date items.

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  byte day
          Day (0-30).
protected static byte[] DAYS
          Day per months.
protected static java.lang.String DD
          Pattern for two digits.
static javax.xml.datatype.DatatypeFactory df
          Data factory.
protected  byte hou
          Hour (0-59).
protected  byte min
          Minute (0-59).
protected  byte mon
          Month (0-11).
protected  long yea
          Year.
protected static java.lang.String YEAR
          Year pattern.
protected  short zon
          Timezone in minutes (-14*60-14*60).
protected static java.lang.String ZONE
          Date pattern.
 
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
 
Method Summary
protected  void calc(DTDur dur, boolean p)
          Adds/subtracts the specified dayTime duration.
 long day()
          Returns the days.
static java.math.BigDecimal days(long yea, int mon, int day)
          Returns a day count for the specified years, months and days.
 int diff(Item it, Collation coll, InputInfo ii)
          Returns the difference between the current and the specified item.
static int dpm(long yea, int mon)
          Returns days per month, considering leap years.
 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.
protected static void prefix(TokenBuilder tb, long n, int z)
          Prefixes the specified number of zero digits before a number.
 java.math.BigDecimal sec()
          Returns the seconds (0-59), including the fractional part.
 byte[] string(InputInfo ii)
          Returns a string representation of the value.
abstract  void timeZone(DTDur tz, boolean spec, InputInfo ii)
          Adjusts the timezone.
 javax.xml.datatype.XMLGregorianCalendar toJava()
          Returns a Java representation of the value.
 java.lang.String toString()
           
protected  void tz(DTDur tz, boolean spec, InputInfo ii)
          Adjusts the timezone.
 long yea()
          Returns the years.
 int zon()
          Returns the timezone in minutes.
protected  void zone(TokenBuilder tb)
          Adds the time zone to the specified token builder.
 
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

DD

protected static final java.lang.String DD
Pattern for two digits.

See Also:
Constant Field Values

YEAR

protected static final java.lang.String YEAR
Year pattern.

See Also:
Constant Field Values

ZONE

protected static final java.lang.String ZONE
Date pattern.

See Also:
Constant Field Values

DAYS

protected static final byte[] DAYS
Day per months.


yea

protected long yea
Year.


mon

protected byte mon
Month (0-11). -1: undefined.


day

protected byte day
Day (0-30). -1: undefined.


hou

protected byte hou
Hour (0-59). -1: undefined.


min

protected byte min
Minute (0-59). -1: undefined.


zon

protected short zon
Timezone in minutes (-14*60-14*60). Short.MAX_VALUE: undefined.


df

public static javax.xml.datatype.DatatypeFactory df
Data factory.

Method Detail

calc

protected final void calc(DTDur dur,
                          boolean p)
Adds/subtracts the specified dayTime duration.

Parameters:
dur - duration
p - plus/minus flag

timeZone

public abstract void timeZone(DTDur tz,
                              boolean spec,
                              InputInfo ii)
                       throws QueryException
Adjusts the timezone.

Parameters:
tz - timezone
spec - indicates if zone has been specified (can be null)
ii - input info
Throws:
QueryException - query exception

tz

protected void tz(DTDur tz,
                  boolean spec,
                  InputInfo ii)
           throws QueryException
Adjusts the timezone.

Parameters:
tz - timezone
spec - indicates if zone has been specified (can be null)
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

zon

public final int zon()
Returns the timezone in minutes.

Returns:
time zone

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

zone

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

Parameters:
tb - token builder

prefix

protected static void prefix(TokenBuilder tb,
                             long n,
                             int z)
Prefixes the specified number of zero digits before a number.

Parameters:
tb - token builder
n - number to be printed
z - maximum number of zero digits

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

hash

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

Overrides:
hash in class Item
Parameters:
ii - input info
Returns:
hash code
Throws:
QueryException - if atomization can't be applied (e.g. function item)

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.XMLGregorianCalendar toJava()
Description copied from class: Value
Returns a Java representation of the value.

Specified by:
toJava in class Value
Returns:
Java object

days

public static java.math.BigDecimal days(long yea,
                                        int mon,
                                        int day)
Returns a day count for the specified years, months and days. All values must be specified in their internal representation (undefined values are supported, too). Algorithm is derived from J R Stockton (http://www.merlyn.demon.co.uk/daycount.htm).

Parameters:
yea - year
mon - month
day - days
Returns:
days

dpm

public static int dpm(long yea,
                      int mon)
Returns days per month, considering leap years.

Parameters:
yea - year
mon - month
Returns:
days

toString

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