Version: 1.1.1

org.biomoby.shared.data
Class MobyDataDateTime

java.lang.Object
  extended by org.biomoby.shared.MobyData
      extended by org.biomoby.shared.MobyPrimaryData
          extended by org.biomoby.shared.MobyPrimaryDataSimple
              extended by org.biomoby.shared.data.MobyDataObject
                  extended by org.biomoby.shared.data.MobyDataDateTime
All Implemented Interfaces:
Cloneable, Comparable, MobyDataInstance

public class MobyDataDateTime
extends MobyDataObject

A class representing a MOBY DateTime, which is a primitive in MOBY. This is a useful utility class that parses and outputs dates and times in proper ISO 8601 format as required by the MOBY object description. For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime Because getObject() will return a mutable GregorianCalendar, you can use its methods to modify the underlying date of this MOBY object. Since it is a Gregorian calendar, if you are representing dates before September 14th, 1752, I guarantee nothing.

Author:
Paul Gordon

Field Summary
 
Fields inherited from interface org.biomoby.shared.data.MobyDataInstance
CENTRAL_XML_MODE, SERVICE_XML_MODE
 
Constructor Summary
MobyDataDateTime(Element element)
          Construct the object using a DOM fragment.
MobyDataDateTime(Element element, Registry registry)
           
MobyDataDateTime(GregorianCalendar cal)
           
MobyDataDateTime(String stringISO8601)
           
MobyDataDateTime(String articleName, GregorianCalendar cal)
           
MobyDataDateTime(String articleName, GregorianCalendar cal, Registry registry)
           
MobyDataDateTime(String articleName, String stringISO8601)
          Constructor to build a MOBY DateTime object using the W3C profile of an ISO 8601 formatted input string.
MobyDataDateTime(String articleName, String stringISO8601, Registry registry)
           
 
Method Summary
 MobyDataDateTime clone()
          Simply calls new constructor with object's existing data type, name and value.
 Object getObject()
          Gives access to the Java object instance underlying the MobyData instance.
static String getString(GregorianCalendar cvalue)
          A utility (static) method converting a GregorianCalendar object to an ISO 8601 string.
 String getValue()
          A lexical (prefereably human readable) representation of the underlying object value (not including the namespace and ID).
static GregorianCalendar parseISO8601(String dateTime)
          For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime This method is based on org.w3.util.DateParser v. 1.4 by Benoît Mahé (bmahe@w3.org)
 String toString()
          Return an ISO 8601 string representing the date/time represented by this Calendar.
 String toXML()
          This class sanitizes strings of XML escape characters such as the ampersand (&) and the less-than sign (<).
 
Methods inherited from class org.biomoby.shared.data.MobyDataObject
addCrossReference, addCrossReferences, addCrossReferences, addProvisionInfo, compareTo, createInstanceFromDOM, createInstanceFromDOM, createInstanceFromString, createInstanceFromString, createInstanceFromXML, equals, getCrossReferences, getId, getName, getPrimaryNamespace, getProvisionInfo, getTextContents, getXmlMode, hasCrossReferences, setId, setName, setPrimaryNamespace, setProvisionInfo, setXmlMode
 
Methods inherited from class org.biomoby.shared.MobyPrimaryDataSimple
addNamespace, format, getDataType, getNamespaces, removeNamespace, removeNamespace, setDataType, setNamespaces
 
Methods inherited from class org.biomoby.shared.MobyPrimaryData
isPrimary
 
Methods inherited from class org.biomoby.shared.MobyData
getId, getName, getUserData, setUserData
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biomoby.shared.data.MobyDataInstance
getName, getUserData, setUserData
 

Constructor Detail

MobyDataDateTime

public MobyDataDateTime(Element element)
                 throws IllegalArgumentException
Construct the object using a DOM fragment.

Throws:
IllegalArgumentException - if the element is not a DateTime tag, or the text children of the element do not encode a valid ISO8601 date/time

MobyDataDateTime

public MobyDataDateTime(Element element,
                        Registry registry)
                 throws IllegalArgumentException
Throws:
IllegalArgumentException

MobyDataDateTime

public MobyDataDateTime(String articleName,
                        String stringISO8601)
                 throws IllegalArgumentException
Constructor to build a MOBY DateTime object using the W3C profile of an ISO 8601 formatted input string.

Parameters:
stringISO8601 - if null, the current local date and time is used
Throws:
IllegalArgumentException

MobyDataDateTime

public MobyDataDateTime(String articleName,
                        String stringISO8601,
                        Registry registry)
                 throws IllegalArgumentException
Throws:
IllegalArgumentException

MobyDataDateTime

public MobyDataDateTime(String stringISO8601)

MobyDataDateTime

public MobyDataDateTime(String articleName,
                        GregorianCalendar cal)

MobyDataDateTime

public MobyDataDateTime(String articleName,
                        GregorianCalendar cal,
                        Registry registry)

MobyDataDateTime

public MobyDataDateTime(GregorianCalendar cal)
Method Detail

parseISO8601

public static GregorianCalendar parseISO8601(String dateTime)
                                      throws IllegalArgumentException
For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime This method is based on org.w3.util.DateParser v. 1.4 by Benoît Mahé (bmahe@w3.org)

Parameters:
dateTime - if null, the current local date and time is used, otherwise a valid ISO 8601 string
Throws:
IllegalArgumentException

getObject

public Object getObject()
Description copied from class: MobyDataObject
Gives access to the Java object instance underlying the MobyData instance. For example, to change a MOBY String object, call ((StringBuffer) (data.getObject()).append("extra text to add to the end") In the case of a base Moby Object, there really is no underlying Java equivalent to return, so a java.lang.Object is returned for completeness's sake. possibly useful for notification events and pointer equivalency testing in derived classes such as MobyDataServiceAssocInstance?

Specified by:
getObject in interface MobyDataInstance
Overrides:
getObject in class MobyDataObject
Returns:
a GregorianCalendar

toString

public String toString()
Return an ISO 8601 string representing the date/time represented by this Calendar.

Overrides:
toString in class MobyDataObject
Returns:
the raw XML representation of the object

getString

public static String getString(GregorianCalendar cvalue)
A utility (static) method converting a GregorianCalendar object to an ISO 8601 string. ISO 8601 date manipulation in Java 1.2 based on code by Simon Brooke <simon@jasmine.org.uk>. Does not yet deal with fractions of seconds.


clone

public MobyDataDateTime clone()
Description copied from class: MobyDataObject
Simply calls new constructor with object's existing data type, name and value. Subclasses should override this method if more datafields need to be copied for an accurate clone of the Moby Data Instance (i.e. anything but a base object). The subclasses should ensure that they also return a MobyDataObject.

Overrides:
clone in class MobyDataObject
Returns:
an object of class MobyDataObject

getValue

public String getValue()
Description copied from class: MobyDataObject
A lexical (prefereably human readable) representation of the underlying object value (not including the namespace and ID). This value is used in sorting, and potentially for user interface elements such as tool tips and comment fields. For base objects, there is no underlying value (just a namespace and id), so the result is always a constant string "[Object]".

Overrides:
getValue in class MobyDataObject

toXML

public String toXML()
This class sanitizes strings of XML escape characters such as the ampersand (&) and the less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", or '&#x26;' style character references. We will assume that is this case you've probably already written the string as XML. WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped CDATA sections!

Specified by:
toXML in interface MobyDataInstance
Overrides:
toXML in class MobyDataObject
Returns:
the MOBY XML representation of the data instance

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010