KickJava   Java API By Example, From Geeks To Geeks.

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


1 /******************************************************************
2  * File: XSDDateType.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: XSDDateType.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 date, 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 XSDDateType extends XSDAbstractDateTimeType {
24
25     /**
26      * Constructor
27      */

28     public XSDDateType(String JavaDoc typename) {
29         super(typename);
30     }
31
32     /**
33      * Parse a validated date. This is invoked from
34      * XSDDatatype.convertValidatedDataValue rather then from a local
35      * parse method to make the implementation of XSDGenericType easier.
36      */

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

83
Popular Tags