KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > query > Domain


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

6
7 package com.hp.hpl.jena.graph.query;
8
9 import com.hp.hpl.jena.graph.*;
10
11 import java.util.*;
12
13 /**
14     A Domain is an answer to a Binding query. It satisfies the List
15     interface so that casual users don't have to worry about its special
16     features - for them, it is immutable (they only ever get to see Domains
17     that have emerged from the query process).
18     
19     @author kers
20 */

21
22
23 public class Domain extends AbstractList implements IndexValues
24     {
25     /**
26         The array holding the bound values.
27     */

28     private Node [] value;
29     
30     /**
31         Initialise a Domain with a copy of a Node value array.
32     */

33     public Domain( Node [] value )
34         {
35         Node [] result = new Node[value.length];
36         for (int i = 0; i < value.length; i += 1) result[i] = value[i];
37         this.value = result;
38         }
39     
40     /**
41     */

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

94
Popular Tags