KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > Node_Literal


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: Node_Literal.java,v 1.12 2005/02/21 11:51:56 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.graph;
8
9 import com.hp.hpl.jena.graph.impl.*;
10 import com.hp.hpl.jena.shared.*;
11
12 /**
13     An RDF node holding a literal value. Literals may have datatypes.
14     @author kers
15 */

16 public class Node_Literal extends Node_Concrete
17 {
18     /* package */ Node_Literal( Object JavaDoc label )
19         { super( label ); }
20
21     public LiteralLabel getLiteral()
22         { return (LiteralLabel) label; }
23          
24     public String JavaDoc toString( PrefixMapping pm, boolean quoting )
25         { return ((LiteralLabel) label).toString( quoting ); }
26         
27     public boolean isLiteral()
28         { return true; }
29         
30     public Object JavaDoc visitWith( NodeVisitor v )
31         { return v.visitLiteral( this, getLiteral() ); }
32         
33     public boolean equals( Object JavaDoc other )
34         { return other instanceof Node_Literal && label.equals( ((Node_Literal) other).label ); }
35         
36     /**
37      * Test that two nodes are semantically equivalent.
38      * In some cases this may be the sames as equals, in others
39      * equals is stricter. For example, two xsd:int literals with
40      * the same value but different language tag are semantically
41      * equivalent but distinguished by the java equality function
42      * in order to support round tripping.
43      * <p>Default implementation is to use equals, subclasses should
44      * override this.</p>
45      */

46     public boolean sameValueAs(Object JavaDoc o) {
47         return o instanceof Node_Literal
48               && ((LiteralLabel)label).sameValueAs( ((Node_Literal) o).getLiteral() );
49     }
50     
51     public boolean matches( Node x )
52         { return sameValueAs( x ); }
53     
54 }
55
56 /*
57     (c) Copyright 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
58     All rights reserved.
59
60     Redistribution and use in source and binary forms, with or without
61     modification, are permitted provided that the following conditions
62     are met:
63
64     1. Redistributions of source code must retain the above copyright
65        notice, this list of conditions and the following disclaimer.
66
67     2. Redistributions in binary form must reproduce the above copyright
68        notice, this list of conditions and the following disclaimer in the
69        documentation and/or other materials provided with the distribution.
70
71     3. The name of the author may not be used to endorse or promote products
72        derived from this software without specific prior written permission.
73
74     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
75     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
76     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
77     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
78     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
79     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
80     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
81     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
83     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84 */

85
Popular Tags