tauZaman
v0.1

tauzaman.calendar
Class Calendar

java.lang.Object
  |
  +--tauzaman.calendar.Calendar

public class Calendar
extends java.lang.Object

Calendar class represents a Calendar, which defines the time values of interest to user, usually over a specific segment of the physical time-line. Calendar keeps Granularity/additional FieldName(s) information and provides Calendar dependent functions for time-stamp/temporal constant conversions.

Calendars can be formed given Calendar specification files' URL s, which are fetched as String and formed by CalendricSystem from Calendric System specification files. For example;

  URL url = new URL("http://www.eecs.wsu.edu/burgun/calendars/Gregorian/GregV1.cal");
  Calendar calendar = new Calendar(url);
 

Also Calendars are kept in a database called CalendarRepository.

See Also:
CalendarRepository, CalendricSystem, ClassLoaderMethodCaller
Status:
Design complete, implementation not started

Constructor Summary
Calendar(java.net.URL url)
          Constructs a Calendar object from a given Calendar Specification url in a Calendric System Specification file.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if URL of this Calendar is equal to given Calendar.
 Granule fieldsToGranule(Fields fields)
           Forms and returns a Granule, which contains a Granularity, given Fields object, which is formed by Input by parsing a temporal constant input string.
 Granularity[] getGranularities()
          Returns Granularities of this Calendar.
 Granularity getGranularityByLocalName(java.lang.String localName)
          Returns Granularity of this Calendar given its local name.
 Mapping[] getMappings()
          Returns Mappings of this Calendar.
 Granularity getUnderlyingGranularity()
          Returns underlying Granularity of this Calendar.
 java.net.URL getUrl()
          Returns the URL, which is also Primary Key in CalendarRepository, of this Calendar.
 boolean granuleToFields(Granule granule, Fields fields)
           Forms and returns a Fields, which is unpacked version of a timestamp parsed into each Field.
 java.lang.String toString()
          Returns string representation of this Calendar.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Calendar

public Calendar(java.net.URL url)
         throws CalendarFormationException
Constructs a Calendar object from a given Calendar Specification url in a Calendric System Specification file.

Parameters:
url - URL of Calendar Specification file.
Throws:
CalendarFormationException - If any problem happens while parsing the file; Any problem related to xml parsing, any bad information fetched from parsed file, such as, a bad URL or a URL that causes problems with dynamic loading.
Method Detail

getGranularityByLocalName

public Granularity getGranularityByLocalName(java.lang.String localName)
Returns Granularity of this Calendar given its local name.

Parameters:
localName - String local name of a Granularity
Returns:
Granularity of this Calendar given its local name. Returns null if no such Granularity exists.

getUrl

public java.net.URL getUrl()
Returns the URL, which is also Primary Key in CalendarRepository, of this Calendar.

Returns:
URL of this Calendar

equals

public boolean equals(java.lang.Object obj)
Returns true if URL of this Calendar is equal to given Calendar.

Overrides:
equals in class java.lang.Object
Returns:
boolean true if this Calendar equals to given Calendar

fieldsToGranule

public Granule fieldsToGranule(Fields fields)
                        throws CalendarServiceException

Forms and returns a Granule, which contains a Granularity, given Fields object, which is formed by Input by parsing a temporal constant input string. This is a regular Calendar function, which means every Calendar is required to implement it.

This method calls actual implementation, which is loaded dynamically from given URL in Calendar Specification file.

Parameters:
fields - temporal constant input string, which is parsed into its Fields
Returns:
a Granule formed given Fields object
Throws:
CalendarServiceException - if any problem occurs when performing this dynamically loaded method, this also includes problems with dynamic loading exceptions.
See Also:
Fields, Field, Granule, Property

granuleToFields

public boolean granuleToFields(Granule granule,
                               Fields fields)
                        throws CalendarServiceException

Forms and returns a Fields, which is unpacked version of a timestamp parsed into each Field. This is a regular Calendar function, which means every Calendar is required to implement it.

This method calls actual implementation, which is loaded dynamically from given URL in Calendar Specification file.

Throws:
CalendarServiceException - if any problem occurs when performing this dynamically loaded method, this also includes problems with dynamic loading exceptions.
See Also:
Fields, Field, Granule, Property

getGranularities

public Granularity[] getGranularities()
Returns Granularities of this Calendar.

Returns:
an array of Granularities

getMappings

public Mapping[] getMappings()
Returns Mappings of this Calendar.

Returns:
an array of Mappings

getUnderlyingGranularity

public Granularity getUnderlyingGranularity()
Returns underlying Granularity of this Calendar.

Returns:
underlying Granularity

toString

public java.lang.String toString()
Returns string representation of this Calendar.

Overrides:
toString in class java.lang.Object
Returns:
String representation of a URL

tauZaman
v0.1

Submit a bug or feature

tauZaman is an open-source, publicly avaliable project