KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > datatypes > xsd > impl > XSDMonthDayType


1 /******************************************************************
2  * File: XSDMonthDayType.java
3  * Created by: Dave Reynolds
4  * Created on: 04-Dec-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * All rights reserved.
8  * [See end of file]
9  * $Id: XSDMonthDayType.java,v 1.3 2005/02/21 12:02:24 andy_seaborne Exp $
10  *****************************************************************/

11 package com.hp.hpl.jena.datatypes.xsd.impl;
12
13 import com.hp.hpl.jena.datatypes.xsd.AbstractDateTime;
14 import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
15
16 /**
17  * Type processor for gMonthDay, most of the machinery is in the
18  * base XSDAbstractDateTimeType class.
19  *
20  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
21  * @version $Revision: 1.3 $ on $Date: 2005/02/21 12:02:24 $
22  */

23 public class XSDMonthDayType extends XSDAbstractDateTimeType {
24
25     /**
26      * Constructor
27      */

28     public XSDMonthDayType(String JavaDoc typename) {
29         super(typename);
30     }
31
32     //size without time zone: --MM-DD
33
private final static int MONTHDAY_SIZE = 7;
34
35     /**
36      * Parse a validated date. This is invoked from
37      * XSDDatatype.convertValidatedDataValue rather then from a local
38      * parse method to make the implementation of XSDGenericType easier.
39      */

40     public Object JavaDoc parseValidated(String JavaDoc str) {
41         int len = str.length();
42         int[] date = new int[TOTAL_SIZE];
43         int[] timeZone = new int[2];
44
45         //initialize
46
date[CY]=YEAR;
47
48         date[M]=parseInt(str, 2, 4);
49         int start=5;
50
51         date[D]=parseInt(str, start, start+2);
52
53         if ( MONTHDAY_SIZE<len ) {
54             int sign = findUTCSign(str, MONTHDAY_SIZE, len);
55             getTimeZone(str, date, sign, len, timeZone);
56         }
57
58         if ( date[utc]!=0 && date[utc]!='Z' ) {
59             AbstractDateTime.normalize(date, timeZone);
60         }
61
62         return new XSDDateTime(date, MONTH_MASK | DAY_MASK);
63     }
64     
65 }
66
67
68
69 /*
70     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
71     All rights reserved.
72
73     Redistribution and use in source and binary forms, with or without
74     modification, are permitted provided that the following conditions
75     are met:
76
77     1. Redistributions of source code must retain the above copyright
78        notice, this list of conditions and the following disclaimer.
79
80     2. Redistributions in binary form must reproduce the above copyright
81        notice, this list of conditions and the following disclaimer in the
82        documentation and/or other materials provided with the distribution.
83
84     3. The name of the author may not be used to endorse or promote products
85        derived from this software without specific prior written permission.
86
87     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
88     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
89     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
90     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
91     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
92     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
93     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
94     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
95     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
96     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
97 */

98
Popular Tags