KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > datatypes > RDFDatatype


1 /******************************************************************
2  * File: Datatype.java
3  * Created by: Dave Reynolds
4  * Created on: 07-Dec-02
5  *
6  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: RDFDatatype.java,v 1.6 2005/02/21 12:01:51 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.datatypes;
11
12 import com.hp.hpl.jena.graph.impl.LiteralLabel;
13
14 /**
15  * Interface on a datatype representation. An instance of this
16  * interface is needed to convert typed literals between lexical
17  * and value forms.
18  *
19  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
20  * @version $Revision: 1.6 $ on $Date: 2005/02/21 12:01:51 $
21  */

22 public interface RDFDatatype {
23
24     /**
25      * Return the URI which is the label for this datatype
26      */

27     public String JavaDoc getURI();
28     
29     /**
30      * Convert a value of this datatype out
31      * to lexical form.
32      */

33     public String JavaDoc unparse(Object JavaDoc value);
34     
35     /**
36      * Parse a lexical form of this datatype to a value
37      * @throws DatatypeFormatException if the lexical form is not legal
38      */

39     public Object JavaDoc parse(String JavaDoc lexicalForm) throws DatatypeFormatException;
40     
41     /**
42      * Test whether the given string is a legal lexical form
43      * of this datatype.
44      */

45     public boolean isValid(String JavaDoc lexicalForm);
46     
47     /**
48      * Test whether the given object is a legal value form
49      * of this datatype.
50      */

51     public boolean isValidValue(Object JavaDoc valueForm);
52     
53     /**
54      * Test whether the given LiteralLabel is a valid instance
55      * of this datatype. This takes into accound typing information
56      * as well as lexical form - for example an xsd:string is
57      * never considered valid as an xsd:integer (even if it is
58      * lexically legal like "1").
59      */

60     public boolean isValidLiteral(LiteralLabel lit);
61     
62     /**
63      * Compares two instances of values of the given datatype.
64      * This defaults to just testing equality of the java value
65      * representation but datatypes can override this. We pass the
66      * entire LiteralLabel to allow the equality function to take
67      * the xml:lang tag and the datatype itself into account.
68      */

69     public boolean isEqual(LiteralLabel value1, LiteralLabel value2);
70     
71     /**
72      * If this datatype is used as the cannonical representation
73      * for a particular java datatype then return that java type,
74      * otherwise returns null.
75      */

76     public Class JavaDoc getJavaClass();
77     
78     /**
79      * Returns an object giving more details on the datatype.
80      * This is type system dependent. In the case of XSD types
81      * this will be an instance of
82      * <code>org.apache.xerces.impl.xs.dv.XSSimpleType</code>.
83      */

84     public Object JavaDoc extendedTypeDefinition();
85     
86 }
87
88 /*
89     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
90     All rights reserved.
91
92     Redistribution and use in source and binary forms, with or without
93     modification, are permitted provided that the following conditions
94     are met:
95
96     1. Redistributions of source code must retain the above copyright
97        notice, this list of conditions and the following disclaimer.
98
99     2. Redistributions in binary form must reproduce the above copyright
100        notice, this list of conditions and the following disclaimer in the
101        documentation and/or other materials provided with the distribution.
102
103     3. The name of the author may not be used to endorse or promote products
104        derived from this software without specific prior written permission.
105
106     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
107     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
108     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
109     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
110     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
111     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
112     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
113     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
115     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116 */

117
118
Popular Tags