KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

100
Popular Tags