1 55 56 package org.apache.bsf.util; 57 58 64 public class ObjInfo 65 { 66 static private String QUOTE_CHARS = "\'\"", 67 EXEC_CHARS = "(="; 68 public String objName; 69 public Class objClass; 70 71 public ObjInfo(Class objClass, String objName) 72 { 73 this.objClass = objClass; 74 this.objName = objName; 75 } 76 public boolean isExecutable() 77 { 78 char[] chars = objName.toCharArray(); 79 char openingChar = ' '; 80 boolean inString = false, 81 inEscapeSequence = false; 82 83 for (int i = 0; i < chars.length; i++) 84 { 85 if (inEscapeSequence) 86 { 87 inEscapeSequence = false; 88 } 89 else if (QUOTE_CHARS.indexOf(chars[i]) != -1) 90 { 91 if (!inString) 92 { 93 openingChar = chars[i]; 94 inString = true; 95 } 96 else 97 { 98 if (chars[i] == openingChar) 99 { 100 inString = false; 101 } 102 } 103 } 104 else if (EXEC_CHARS.indexOf(chars[i]) != -1) 105 { 106 if (!inString) 107 { 108 return true; 109 } 110 } 111 else if (inString && chars[i] == '\\') 112 { 113 inEscapeSequence = true; 114 } 115 } 116 117 return false; 118 } 119 public boolean isValueReturning() 120 { 121 return (objClass != void.class && objClass != Void .class); 122 } 123 public String toString() 124 { 125 return StringUtils.getClassName(objClass) + " " + objName; 126 } 127 } 128 | Popular Tags |