KickJava   Java API By Example, From Geeks To Geeks.

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


1 /******************************************************************
2  * File: XSDDayType.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: XSDDayType.java,v 1.3 2005/02/21 12:02:21 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 gDay, 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:21 $
22  */

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

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

95
Popular Tags