KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

88
Popular Tags