tauZaman
v0.1

tauzaman.calendricsystem
Class CalendricSystem

java.lang.Object
  |
  +--tauzaman.calendricsystem.CalendricSystem

public class CalendricSystem
extends java.lang.Object

CalendricSystem class represents a Calendric System, which contains Calendars' Epochs and provides an entrance point to all Epoch and Calendar services.

See Also:
Calendar, PropertyManager
Status:
still being designed (granularity lattice), implementation started

Field Summary
private  java.util.Hashtable calendarNamesToCalendars
          Keeps Calendar names as its keys and Calendars as values.
private  Calendar[] calendars
          List of handle(s) of Calendar(s) that this calendric system contains, in the order of default input order, which is defined in Calendar Specification file.
private  java.util.Hashtable calendarUrlsToCalendarNames
          Keeps Calendar urls as its keys and Calendar names as values.
private  CalendarRepository cr
          a handle to unique CalendarRepository of, CalendricSystemRepository, indirectly this TauZamanSystem
(package private)  Granularity defaultGranularity
          Default Granularity of this CalendricSystem.
private  GranularityLattice lattice
          jkm
private  Mapping[] mappings
          Granularity mappings belong to this CalendricSystem.
(package private)  java.lang.String token
          Default regular expression for useful information in inputs.
private  java.net.URL url
          Url of the this CalendricSystem, which is enforced to be unique in database
 
Constructor Summary
CalendricSystem(CalendarRepository cr, java.net.URL url)
          Constructs a CalendricSystem object; Forms a CalendricSystem by parsing url.
 
Method Summary
 Granule castDeterminantInstant(Granule granule, Granularity toGranularity)
           
 void clearCaches()
           
private  void formCalendricSystem()
          Initializes this CalendricSystem's states by parsing file that its url points.
private  Granularity formGranularity(java.lang.String localName, java.lang.String calendarName)
          Returns a Granularity produced from global identity of mapping elements.
 Calendar[] getAllCalendars()
          Returns all Calendars in this CalendricSystem.
 Calendar getCalendar(java.lang.String calendarName)
           
 Granularity getDefaultGranularity()
          Returns default Granularity of this CalendricSystem.
 java.lang.String getDefaultRegex()
          Returns default regular expression for this CalendricSystem
 GranularityLattice getGranularityLattice()
           
 Mapping[] getMappings()
          Returns Mappings of this CalendricSystem.
 Calendar[] getOrderedCalendars(Property overrideInputOrderProperty)
          Returns an array of ordered list of Calendars for converting a temporal data type to corresponding output string.
 java.net.URL getUrl()
          Returns url of this CalendricSystem's specification file.
 boolean isCoarser(Granularity g1, Granularity g2)
           
 boolean isEquivalent(Granularity g1, Granularity g2)
           
 boolean isFiner(Granularity g1, Granularity g2)
           
 boolean isIncomparable(Granularity g1, Granularity g2)
           
 java.lang.String toString()
          Returns url of this CalendricSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

url

private java.net.URL url
Url of the this CalendricSystem, which is enforced to be unique in database


calendars

private Calendar[] calendars
List of handle(s) of Calendar(s) that this calendric system contains, in the order of default input order, which is defined in Calendar Specification file.

See Also:
Calendar

calendarNamesToCalendars

private java.util.Hashtable calendarNamesToCalendars
Keeps Calendar names as its keys and Calendars as values.


calendarUrlsToCalendarNames

private java.util.Hashtable calendarUrlsToCalendarNames
Keeps Calendar urls as its keys and Calendar names as values.


mappings

private Mapping[] mappings
Granularity mappings belong to this CalendricSystem.


token

java.lang.String token
Default regular expression for useful information in inputs.


defaultGranularity

Granularity defaultGranularity
Default Granularity of this CalendricSystem.


cr

private CalendarRepository cr
a handle to unique CalendarRepository of, CalendricSystemRepository, indirectly this TauZamanSystem


lattice

private GranularityLattice lattice
jkm

Constructor Detail

CalendricSystem

public CalendricSystem(CalendarRepository cr,
                       java.net.URL url)
                throws CalendricSystemFormationException
Constructs a CalendricSystem object; Forms a CalendricSystem by parsing url.

Parameters:
cr - CalendarRepository, which this CalendricSystem will use to load Calendars
Throws:
CalendricSystemFormationException - if any error occurs while forming CalendricSystem from given URL
Method Detail

getUrl

public java.net.URL getUrl()
Returns url of this CalendricSystem's specification file.

Returns:
URL url of this CalendricSystem

getAllCalendars

public Calendar[] getAllCalendars()
Returns all Calendars in this CalendricSystem.

Returns:
array of Calendars

getDefaultRegex

public java.lang.String getDefaultRegex()
Returns default regular expression for this CalendricSystem


formCalendricSystem

private void formCalendricSystem()
                          throws CalendricSystemFormationException
Initializes this CalendricSystem's states by parsing file that its url points.

Throws:
CalendricSystemFormationException - if any error occurs while forming CalendricSystem from given URL

getMappings

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

Returns:
an array of Mappings

formGranularity

private Granularity formGranularity(java.lang.String localName,
                                    java.lang.String calendarName)
                             throws CalendricSystemFormationException
Returns a Granularity produced from global identity of mapping elements. It also checks validity of mapping names.

Parameters:
localName - String name of Granularity given as in CalendricSystem spec file
calendarName - String name of Calendar given as in CalendricSystem spec file
Returns:
Granularity
Throws:
CalendricSystemFormationException - if any abnormal condition occurs when forming Granularity

getDefaultGranularity

public Granularity getDefaultGranularity()
Returns default Granularity of this CalendricSystem.

Returns:
Granularity, which is the default Granularity

getOrderedCalendars

public Calendar[] getOrderedCalendars(Property overrideInputOrderProperty)
                               throws CalendricSystemServiceException
Returns an array of ordered list of Calendars for converting a temporal data type to corresponding output string.

Parameters:
overrideInputOrderProperty - Property that will be used when forming an ordered input calendar list
Returns:
array of ordered Calendars
Throws:
CalendricSystemServiceException - if any problem occurs when forming an ordered Calendar list

toString

public java.lang.String toString()
Returns url of this CalendricSystem.

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

getGranularityLattice

public GranularityLattice getGranularityLattice()

getCalendar

public Calendar getCalendar(java.lang.String calendarName)

castDeterminantInstant

public Granule castDeterminantInstant(Granule granule,
                                      Granularity toGranularity)
                               throws CalendricSystemServiceException
CalendricSystemServiceException

isCoarser

public boolean isCoarser(Granularity g1,
                         Granularity g2)
                  throws CalendricSystemServiceException
CalendricSystemServiceException

isEquivalent

public boolean isEquivalent(Granularity g1,
                            Granularity g2)
                     throws CalendricSystemServiceException
CalendricSystemServiceException

isFiner

public boolean isFiner(Granularity g1,
                       Granularity g2)
                throws CalendricSystemServiceException
CalendricSystemServiceException

isIncomparable

public boolean isIncomparable(Granularity g1,
                              Granularity g2)
                       throws CalendricSystemServiceException
CalendricSystemServiceException

clearCaches

public void clearCaches()

tauZaman
v0.1

Submit a bug or feature

tauZaman is an open-source, publicly avaliable project