01: /*
02: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
03: [See end of file]
04: $Id: MultiOperandTree.java,v 1.5 2008/01/02 12:06:04 andy_seaborne Exp $
05: */
06: package com.hp.hpl.jena.graph.query.regexptrees;
07:
08: /**
09: MultiOperandTree
10: @author kers
11: */
12: public abstract class MultiOperandTree extends RegexpTree {
13: protected RegexpTree[] operands;
14:
15: protected MultiOperandTree(RegexpTree[] operands) {
16: this .operands = operands;
17: }
18:
19: /* (non-Javadoc)
20: * @see java.lang.Object#equals(java.lang.Object)
21: */
22: public boolean equals(Object other) {
23: // TODO Auto-generated method stub
24: return false;
25: }
26:
27: /* (non-Javadoc)
28: * @see java.lang.Object#hashCode()
29: */
30: public int hashCode() {
31: // TODO Auto-generated method stub
32: return 0;
33: }
34:
35: public String toString(String kind) {
36: StringBuffer result = new StringBuffer();
37: result.append("<");
38: result.append(kind);
39: for (int i = 0; i < operands.length; i += 1)
40: result.append(" ").append(operands[i]);
41: result.append(">");
42: return result.toString();
43: }
44:
45: protected boolean sameOperands(MultiOperandTree other) {
46: if (other.operands.length == operands.length) {
47: for (int i = 0; i < operands.length; i += 1)
48: if (operands[i].equals(other.operands[i]) == false)
49: return false;
50: return true;
51: } else
52: return false;
53: }
54:
55: public int hashCode(int base) {
56: int result = base;
57: for (int i = 0; i < operands.length; i += 1)
58: result = (result << 1) ^ operands[i].hashCode();
59: return result;
60: }
61: }
62:
63: /*
64: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
65: All rights reserved.
66:
67: Redistribution and use in source and binary forms, with or without
68: modification, are permitted provided that the following conditions
69: are met:
70:
71: 1. Redistributions of source code must retain the above copyright
72: notice, this list of conditions and the following disclaimer.
73:
74: 2. Redistributions in binary form must reproduce the above copyright
75: notice, this list of conditions and the following disclaimer in the
76: documentation and/or other materials provided with the distribution.
77:
78: 3. The name of the author may not be used to endorse or promote products
79: derived from this software without specific prior written permission.
80:
81: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
82: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
83: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
84: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
85: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
86: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
87: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
88: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
90: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91: */
|