1 21 22 23 package org.apache.derby.impl.tools.ij; 24 25 import org.apache.derby.iapi.reference.Attribute; 26 import org.apache.derby.iapi.tools.i18n.LocalizedResource; 27 import org.apache.derby.tools.URLCheck; 28 import java.util.Locale ; 29 import java.util.Vector ; 30 import java.util.Properties ; 31 import java.util.Enumeration ; 32 import java.util.StringTokenizer ; 33 import java.lang.reflect.Field ; 34 import java.sql.SQLException ; 35 36 public class AttributeHolder { 37 38 String name; 42 String value; 43 String token; 44 Vector errors = new Vector (); 45 46 public String getName(){ 47 return name; 48 } 49 public void setName(String aString){ 50 name = aString; 51 } 52 String getValue(){ 53 return value; 54 } 55 public void setValue(String aString){ 56 value = aString; 57 } 58 String getToken(){ 59 return token; 60 } 61 public void setToken(String aString){ 62 token = aString; 63 } 64 public void addError(String aString) { 65 if (!errors.contains(aString)) 67 errors.addElement(aString); 68 } 69 public void check( Vector validProps){ 70 checkName( validProps); 71 displayErrors(); 73 } 74 void displayErrors(){ 75 Enumeration e = errors.elements(); 77 if (e.hasMoreElements()) 80 display(LocalizedResource.getMessage("TL_urlLabel1", "[", getToken(), "]")); 81 while (e.hasMoreElements()){ 83 String aString = (String )e.nextElement(); 84 displayIndented(aString); 85 } 86 } 87 void checkName( Vector validProps){ 88 if( validProps == null) 89 return; String anAtt = getName(); 91 try { 92 if (!validProps.contains(anAtt)) { 94 if (validProps.contains(anAtt.toLowerCase(java.util.Locale.ENGLISH))) { 96 errors.addElement(LocalizedResource.getMessage("TL_incorCase")); 97 } 98 else { 100 errors.addElement(LocalizedResource.getMessage("TL_unknownAtt")); 101 } 102 } 103 else { 104 } 106 } 107 catch (Exception ex) { 108 ex.printStackTrace(); 109 } 110 } 111 void checkValue(){ 112 String anAtt = getName(); 113 String aValue = getValue(); 114 try { 115 if (URLCheck.getBooleanAttributes().contains(anAtt)) { 117 if (!checkBoolean(aValue)) { 118 errors.addElement(LocalizedResource.getMessage("TL_trueFalse")); 119 } 120 } 121 } 122 catch (Exception ex) { 123 ex.printStackTrace(); 124 } 125 } 126 boolean checkBoolean(String aValue) { 127 if (aValue == null) 128 return false; 129 return aValue.toLowerCase(Locale.ENGLISH).equals("true") || 130 aValue.toLowerCase(Locale.ENGLISH).equals("false"); 131 } 132 void display(String aString) { 133 LocalizedResource.OutputWriter().println(aString); 134 } 135 void displayIndented(String aString) { 136 LocalizedResource.OutputWriter().println(" " + aString); 137 } 138 } 139 | Popular Tags |