1 6 package com.hp.hpl.jena.graph.query.regexptrees; 7 8 12 public abstract class MultiOperandTree extends RegexpTree 13 { 14 protected RegexpTree [] operands; 15 16 protected MultiOperandTree( RegexpTree [] operands ) 17 { this.operands = operands; } 18 19 22 public boolean equals( Object other ) 23 { 24 return false; 26 } 27 28 31 public int hashCode() 32 { 33 return 0; 35 } 36 37 public String toString( String kind ) 38 { StringBuffer result = new StringBuffer (); 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 | Popular Tags |