1 18 package org.apache.geronimo.interop.properties; 19 20 public class BooleanProperty extends PropertyType { 21 private boolean defaultValue = false; 22 23 public BooleanProperty(Class componentClass, String propertyName) { 24 super(componentClass, propertyName); 25 } 26 27 public BooleanProperty displayName(String displayName) { 28 setDisplayName(displayName); 29 return this; 30 } 31 32 public BooleanProperty displayOnlyIf(PropertyType other, String value) { 33 setDisplayOnlyIf(other, value); 34 return this; 35 } 36 37 public BooleanProperty description(String description) { 38 setDescription(description); 39 return this; 40 } 41 42 public BooleanProperty consoleHelp(String consoleHelp) { 43 setConsoleHelp(consoleHelp); 44 return this; 45 } 46 47 public BooleanProperty sortOrder(int sortOrder) { 48 setSortOrder(sortOrder); 49 return this; 50 } 51 52 public BooleanProperty defaultValue(boolean defaultValue) { 53 defaultValue = defaultValue; 54 return this; 55 } 56 57 public boolean getDefaultValue() { 58 return defaultValue; 59 } 60 61 public String getDefaultValueAsString() { 62 return String.valueOf(defaultValue); 63 } 64 65 public boolean getBoolean() { 66 return getBoolean(null, getComponentProperties()); 67 } 68 69 public boolean getBoolean(String instanceName, PropertyMap props) { 70 boolean b; 71 boolean ok = true; 72 String value = props.getProperty(getPropertyName(), String.valueOf(defaultValue)); 73 value = value.toLowerCase(); 74 if (value.equals("true")) { 75 b = true; 76 } else if (value.equals("false")) { 77 b = false; 78 } else { 79 ok = false; 80 b = false; 81 } 82 if (!ok) { 83 badPropertyValue(instanceName, value, expectedTrueOrFalse()); 84 } 85 logPropertyValue(instanceName, value, b == defaultValue); 86 return b; 87 } 88 } 89 | Popular Tags |