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