Package com.highdeal.calendar.hci
Class HolidayModel
java.lang.Object
com.highdeal.calendar.hci.HolidayModel
- All Implemented Interfaces:
XMLMapping,XMLMarshallable
This
Java class represents the scheme of a holiday that is contained in
public holidays.XML API for HCI
The XML APIs specify the following XSD fragment:
XSD Fragment
<xs:element name="holiday">
<xs:complexType>
<xs:sequence>
<xs:element name="description" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="lang" type="xs:string" use="required"/>
<xs:attribute name="label" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="code" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="fixedDay" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="month" type="MonthType" use="required"/>
<xs:attribute name="day" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="relativeDay" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="month" type="MonthType" use="required"/>
<xs:attribute name="weekday" type="WeekdayType" use="required"/>
<xs:attribute name="position" type="PositionType" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="easterRelativeDay" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="offset" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="enumeratedDay" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="date" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="value" type="xs:date"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="code" type="xs:string" use="required"/>
</xs:complexType>
</xs:element><xs:simpleType name="MonthType">
<xs:restriction base="xs:string">
<xs:enumeration value="January"/>
<xs:enumeration value="February"/>
<xs:enumeration value="March"/>
<xs:enumeration value="April"/>
<xs:enumeration value="May"/>
<xs:enumeration value="June"/>
<xs:enumeration value="July"/>
<xs:enumeration value="August"/>
<xs:enumeration value="September"/>
<xs:enumeration value="October"/>
<xs:enumeration value="November"/>
<xs:enumeration value="December"/>
</xs:restriction>
</xs:simpleType><xs:simpleType name="WeekdayType">
<xs:restriction base="xs:string">
<xs:enumeration value="Sunday"/>
<xs:enumeration value="Monday"/>
<xs:enumeration value="Tuesday"/>
<xs:enumeration value="Wednesday"/>
<xs:enumeration value="Thursday"/>
<xs:enumeration value="Friday"/>
<xs:enumeration value="Saturday"/>
</xs:restriction>
</xs:simpleType><xs:simpleType name="PositionType">
<xs:restriction base="xs:string">
<xs:enumeration value="last"/>
<xs:enumeration value="first"/>
<xs:enumeration value="second"/>
<xs:enumeration value="third"/>
<xs:enumeration value="fourth"/>
<xs:enumeration value="fifth"/>
</xs:restriction>
</xs:simpleType>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFOR INTERNAL USE ONLY - ThisJava interfaceis implemented by classes that define a day.static final classThisJava classenables to define day which is relative to Easter Sunday.static final classThisJava classenables to define a enumerated day, that is to say a day given by an enumeration of precise date (including year).static final classThisJava classenables to define a fixed day, that is to say a day given by a fixed date, same date each year (such as New Year Day, for instance).static final classThisJava classenables to define a relative day, that is to say a day given by a week day position in a month (e.g. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant used for type ofHolidayModel.EasterRelativeDay.static final intConstant used for type ofHolidayModel.EnumeratedDay.static final int0: Constant used for type ofHolidayModel.FixedDaystatic final String[]An array containing the valid month names, defined as: MONTHS[0] is "January" MONTHS[1] is "February" MONTHS[2] is "March" MONTHS[3] is "April" MONTHS[4] is "May" MONTHS[5] is "June" MONTHS[6] is "July" MONTHS[7] is "August" MONTHS[8] is "September" MONTHS[9] is "October" MONTHS[10] is "November" MONTHS[11] is "December"static final String[]An array containing the valid position names, defined as: POSITIONS[0] is "last" POSITIONS[1] is "first" POSITIONS[2] is "second" POSITIONS[3] is "third" POSITIONS[4] is "fourth" POSITIONS[5] is "fifth"static final intConstant used for type ofHolidayModel.RelativeDay.static final String[]An array containing the valid weekday names, defined as: WEEKDAYS[0] is "Sunday" WEEKDAYS[1] is "Monday" WEEKDAYS[2] is "Tuesday" WEEKDAYS[3] is "Wednesday" WEEKDAYS[4] is "Thursday" WEEKDAYS[5] is "Friday" WEEKDAYS[6] is "Saturday" -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCharacterData(String cData) Adds character data to the content element.voidaddChild(String tagName, XMLMarshallable child) Adds a child to the object, thechildrepresenting the marshallable object which must be added to the element.voidVerifies thisHolidayModelis valid.Class<?>getClass(String nsUri, String tag, XMLAttributes atts) Returns theJava classfor a specifiedXML tagand its attributes in a namespace.getCode()Gets the code of thisHolidayModel.Returns theDayDefinitionof this.getDescription(String language) Gets the description associated with the given language, if exists.Returns all set descriptions, as aPropertieswith languages as key and descriptions as values.Returns the list of the codes of groups to which thisHolidayModelbelongs.booleanTests is this belongs to the given group.voidmarshal(XMLOutputter output) Gives an XML representation of this object, including its children.voidsetAttributes(XMLAttributes atts) Sets the attributes of the XML representation of the element being processed.voidSets the code of thisHolidayModel.voidsetDayDefinition(HolidayModel.DayDefinition dayDefinition) Sets theDayDefinitionof this.voidsetDescription(String language, String label) Sets a description associated with a language.
-
Field Details
-
FIX_TYPE
public static final int FIX_TYPE0: Constant used for type ofHolidayModel.FixedDay- See Also:
-
RELATIVE_TYPE
public static final int RELATIVE_TYPEConstant used for type ofHolidayModel.RelativeDay. Internal use only.- See Also:
-
EASTER_RELATIVE_TYPE
public static final int EASTER_RELATIVE_TYPEConstant used for type ofHolidayModel.EasterRelativeDay. Internal use only.- See Also:
-
ENUM_TYPE
public static final int ENUM_TYPEConstant used for type ofHolidayModel.EnumeratedDay. Internal use only.- See Also:
-
MONTHS
An array containing the valid month names, defined as:- MONTHS[0] is "January"
- MONTHS[1] is "February"
- MONTHS[2] is "March"
- MONTHS[3] is "April"
- MONTHS[4] is "May"
- MONTHS[5] is "June"
- MONTHS[6] is "July"
- MONTHS[7] is "August"
- MONTHS[8] is "September"
- MONTHS[9] is "October"
- MONTHS[10] is "November"
- MONTHS[11] is "December"
-
WEEKDAYS
An array containing the valid weekday names, defined as:- WEEKDAYS[0] is "Sunday"
- WEEKDAYS[1] is "Monday"
- WEEKDAYS[2] is "Tuesday"
- WEEKDAYS[3] is "Wednesday"
- WEEKDAYS[4] is "Thursday"
- WEEKDAYS[5] is "Friday"
- WEEKDAYS[6] is "Saturday"
-
POSITIONS
An array containing the valid position names, defined as:- POSITIONS[0] is "last"
- POSITIONS[1] is "first"
- POSITIONS[2] is "second"
- POSITIONS[3] is "third"
- POSITIONS[4] is "fourth"
- POSITIONS[5] is "fifth"
-
-
Constructor Details
-
HolidayModel
public HolidayModel()Builds a new empty model.
-
-
Method Details
-
getCode
Gets the code of thisHolidayModel.- Returns:
- The code of this
HolidayModel
-
setCode
Sets the code of thisHolidayModel.- Parameters:
code- The code of thisHolidayModel
-
getGroups
Returns the list of the codes of groups to which thisHolidayModelbelongs.- Returns:
- The list of the codes of groups to which this
HolidayModelbelongs
-
setDescription
Sets a description associated with a language.- Parameters:
language- The language of the label, should be given as ISO-639 codelabel- The label associated with the given language
-
getDescription
Gets the description associated with the given language, if exists.- Parameters:
language- The language- Returns:
- The description associated with the given language, if exists,
nullotherwise.
-
getDescriptions
Returns all set descriptions, as aPropertieswith languages as key and descriptions as values.- Returns:
- A
Propertieswith languages as key and descriptions as values
-
getDayDefinition
Returns theDayDefinitionof this.- Returns:
- The
DayDefinitionof this
-
setDayDefinition
Sets theDayDefinitionof this.- Parameters:
dayDefinition- TheDayDefinitionof this
-
isInGroup
Tests is this belongs to the given group.- Parameters:
group- The code of the group to test- Returns:
trueif this belongs to the given group,falseotherwise
-
setAttributes
Description copied from interface:XMLMarshallableSets the attributes of the XML representation of the element being processed.- Specified by:
setAttributesin interfaceXMLMarshallable- Parameters:
atts- TheXML attributesof the current element
-
addChild
Description copied from interface:XMLMarshallableAdds a child to the object, thechildrepresenting the marshallable object which must be added to the element.- Specified by:
addChildin interfaceXMLMarshallable- Parameters:
tagName- The name of tag for the childchild- The child to be added
-
addCharacterData
Description copied from interface:XMLMarshallableAdds character data to the content element.- Specified by:
addCharacterDatain interfaceXMLMarshallable- Parameters:
cData- The character data to be added
-
marshal
Description copied from interface:XMLMarshallableGives an XML representation of this object, including its children.- Specified by:
marshalin interfaceXMLMarshallable- Parameters:
output- TheXML outputto marshal the object into
-
checkValidity
Verifies thisHolidayModelis valid. AnInvalidHolidayExceptionis thrown in the following cases:- the code is
null - a description is set without language
- a description is set with an empty label
- the
DayDafinitionis invalid
- Throws:
InvalidHolidayException- See Also:
- the code is
-
getClass
Description copied from interface:XMLMappingReturns theJava classfor a specifiedXML tagand its attributes in a namespace.- Specified by:
getClassin interfaceXMLMapping- Parameters:
nsUri- The unique resource identifier of the namespace of the XML tagtag- The local part of the XML tagatts- The attributes of the XML tag- Returns:
- A
Java classwith a default constructor
-