1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.common.BindingSupportImpl; 15 16 19 public class MethodNode extends Node { 20 21 public Node args; 22 private int method; 23 24 public static final int STARTS_WITH = 1; 25 public static final int ENDS_WITH = 2; 26 public static final int CONTAINS = 3; 27 public static final int IS_EMPTY = 4; 28 public static final int CONTAINS_KEY = 5; 29 public static final int TO_LOWER_CASE = 6; 30 public static final int SQL = 7; 31 public static final int CONTAINS_PARAM = 8; 32 33 public MethodNode() { 34 } 35 36 public MethodNode( int method ) { 37 this.method = method; 38 } 39 40 public Object accept(NodeVisitor visitor, Object [] results) { 41 return visitor.visitMethodNode(this, results); 42 } 43 44 public String getName() { 45 switch (method) { 46 case STARTS_WITH: return "startsWith"; 47 case ENDS_WITH: return "endsWith"; 48 case CONTAINS: return "contains"; 49 case IS_EMPTY: return "isEmpty"; 50 case CONTAINS_KEY: return "containsKey"; 51 case TO_LOWER_CASE: return "toLowerCase"; 52 case SQL: return "sql"; 53 } 54 return "Unknown(" + method + ")"; 55 } 56 57 public int getMethod() { 58 return method; 59 } 60 61 public void setName(String name) { 62 if (name.equals("startsWith")) method = STARTS_WITH; 63 else if (name.equals("endsWith")) method = ENDS_WITH; 64 else if (name.equals("contains")) method = CONTAINS; 65 else if (name.equals("isEmpty")) method = IS_EMPTY; 66 else if (name.equals("containsKey")) method = CONTAINS_KEY; 67 else if (name.equals("toLowerCase")) method = TO_LOWER_CASE; 68 else if (name.equals("sql")) method = SQL; 69 else throw BindingSupportImpl.getInstance().invalidOperation("Invalid method name: '" + name + "'"); 70 } 71 72 public String toString() { 73 return super.toString() + " : " + getName(); 74 } 75 76 public Field visit(MemVisitor visitor, Object obj) { 77 return visitor.visitMethodNode(this, obj); 78 } 79 80 public Object arrive(NodeVisitor v, Object msg) { 81 return v.arriveMethodNode(this, msg); 82 } 83 84 } 85 86 | Popular Tags |