1 56 57 package org.objectstyle.cayenne.exp; 58 59 import java.io.PrintWriter ; 60 61 68 public class UnaryExpression extends Expression { 69 protected Object operand; 70 71 public UnaryExpression() { 72 } 73 74 public UnaryExpression(int type) { 75 this.type = type; 76 } 77 78 protected void flattenTree() { 79 80 } 81 82 protected boolean pruneNodeForPrunedChild(Object prunedChild) { 83 return true; 84 } 85 86 91 public Expression shallowCopy() { 92 return new UnaryExpression(type); 93 } 94 95 public final int getOperandCount() { 96 return 1; 97 } 98 99 public Object getOperand(int index) { 100 if (index == 0) 101 return operand; 102 103 throw new IllegalArgumentException ( 104 "Invalid operand index for UnaryExpression: " + index); 105 } 106 107 public void setOperand(int index, Object value) { 108 if (index == 0) { 109 operand = value; 110 return; 111 } 112 113 throw new IllegalArgumentException ( 114 "Invalid operand index for UnaryExpression: " + index); 115 } 116 117 120 public void encodeAsString(PrintWriter pw) { 121 StringBuffer buffer = new StringBuffer (); 124 toStringBuffer(buffer); 125 pw.print(buffer.toString()); 126 } 127 } 128 | Popular Tags |