KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > query > regexptrees > MultiOperandTree


1 /*
2   (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
3   [See end of file]
4   $Id: MultiOperandTree.java,v 1.2 2005/02/21 11:52:29 andy_seaborne Exp $
5 */

6 package com.hp.hpl.jena.graph.query.regexptrees;
7
8 /**
9  MultiOperandTree
10  @author kers
11  */

12 public abstract class MultiOperandTree extends RegexpTree
13     {
14     protected RegexpTree [] operands;
15     
16     protected MultiOperandTree( RegexpTree [] operands )
17         { this.operands = operands; }
18     
19     /* (non-Javadoc)
20      * @see java.lang.Object#equals(java.lang.Object)
21      */

22     public boolean equals( Object JavaDoc other )
23         {
24         // TODO Auto-generated method stub
25
return false;
26         }
27
28     /* (non-Javadoc)
29      * @see java.lang.Object#hashCode()
30      */

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