Constructors Summary |
---|
public EnvironmentProperty(EnvironmentProperty other)copy constructor.
super(other);
value = other.value;
type = other.type;
valueObject = other.valueObject;
|
public EnvironmentProperty()Construct an environment property if type String and empty string value and no description.
|
public EnvironmentProperty(String name, String value, String description)Construct an environment property of given name value and description.
this(name, value, description, null);
|
public EnvironmentProperty(String name, String value, String description, String type)Construct an environment property of given name value and description and type.
Throws an IllegalArgumentException if bounds checking is true and the value cannot be
reconciled with the given type.
super(name, description);
this.value = value;
checkType(type);
this.type = type;
|
Methods Summary |
---|
public void | addInjectionTarget(InjectionTarget target)
if (injectionTargets==null) {
injectionTargets = new HashSet<InjectionTarget>();
}
boolean found = false;
for (InjectionTarget injTarget : injectionTargets) {
if (injTarget.equals(target)) {
found = true;
break;
}
}
if (!found) {
injectionTargets.add(target);
}
|
private void | checkType(java.lang.String type)checks the given class type. throws an IllegalArgumentException if bounds checking
if the type is not allowed.
if (type != null) {
Class typeClass = null;
// is it loadable ?
try {
typeClass = Class.forName(type);
} catch (Throwable t) {
if (this.isBoundsChecking()) {
throw new IllegalArgumentException(localStrings.getLocalString(
"enterprise.deployment..exceptiontypenotallowedpropertytype",
"{0} is not an allowed property value type", new Object[] {type}));
} else {
return;
}
}
boolean allowedType = false;
for (int i = 0; i < allowedTypes.length; i++) {
if (allowedTypes[i].equals(typeClass)) {
allowedType = true;
break;
}
}
if (this.isBoundsChecking() && !allowedType) {
throw new IllegalArgumentException(localStrings.getLocalString(
"enterprise.deployment.exceptiontypenotallowedprprtytype",
"{0} is not an allowed property value type", new Object[] {type}));
}
}
|
private java.lang.String | convertPrimitiveTypes(java.lang.String type)
if (type == null) {
return type;
}
if (type.equals("int")) {
return "java.lang.Integer";
} else if (type.equals("boolean")) {
return "java.lang.Boolean";
} else if (type.equals("double")) {
return "java.lang.Double";
} else if (type.equals("float")) {
return "java.lang.Float";
} else if (type.equals("long")) {
return "java.lang.Long";
} else if (type.equals("short")) {
return "java.lang.Short";
} else if (type.equals("byte")) {
return "java.lang.Byte";
} else if (type.equals("char")) {
return "java.lang.Character";
}
return type;
|
public boolean | equals(java.lang.Object other)Returns true if the argument is an environment property of the same name, false else.
if (other instanceof EnvironmentProperty &&
this.getName().equals( ((EnvironmentProperty) other).getName() )) {
return true;
}
return false;
|
public java.lang.String | getComponentEnvName()
return getName();
|
public java.lang.String | getInjectResourceType()
return type;
|
public java.util.Set | getInjectionTargets()
return injectionTargets;
|
public java.lang.String | getMappedName()
return (mappedName != null)? mappedName : "";
|
private java.lang.Object | getObjectFromString(java.lang.String string, java.lang.Class type)
if (type == null && !this.isBoundsChecking()) {
Object obj = getValueObjectUsingAllowedTypes(string);
if (obj != null) return obj;
}
if (string == null || ("".equals(string) && !type.equals(String.class))) {
return null;
}
try {
if (String.class.equals(type)) {
return string;
} else if (Boolean.class.equals(type)) {
return Boolean.valueOf(string);
} else if (Integer.class.equals(type)) {
return Integer.valueOf(string);
} else if (Double.class.equals(type)) {
return new Double(string);
} else if (Float.class.equals(type)) {
return new Float(string);
} else if (Short.class.equals(type)) {
return Short.valueOf(string);
} else if (Byte.class.equals(type)) {
return Byte.valueOf(string);
} else if (Long.class.equals(type)) {
return Long.valueOf(string);
} else if (Character.class.equals(type)) {
if (string.length() != 1) {
throw new IllegalArgumentException();
} else {
return Character.valueOf(string.charAt(0));
}
}
} catch (Throwable t) {
throw new IllegalArgumentException(localStrings.getLocalString(
"enterprise.deployment.exceptioncouldnotcreateinstancetype",
"Could not create instance of {0} from {1}\n reason: {2}" + t, new Object[] {type, string, t}));
}
throw new IllegalArgumentException(localStrings.getLocalString(
"enterprise.deployment.exceptionillegaltypeenvproperty",
"Illegal type for environment properties: {0}", new Object[] {type}));
|
public java.lang.String | getResolvedValue()Returns a resolved value of this environment property
return RelativePathResolver.resolvePath(getValue());
|
public java.lang.Object | getResolvedValueObject()Returns the typed value object of this environment property. Throws an IllegalArgumentException if bounds checking is
true and the value cannot be
reconciled with the given type.
if (this.valueObject == null) {
this.valueObject = "";
}
return getObjectFromString(this.getResolvedValue(), this.getValueType());
|
public java.lang.String | getType()Returns value type of this environment property as a classname.
if (type == null && this.isBoundsChecking()) {
return String.class.getName();
} else {
return type;
}
|
public java.lang.String | getValue()Returns the String value of this environment property
if (this.value == null) {
this.value = "";
}
return value;
|
public java.lang.Object | getValueObject()Returns the typed value object of this environment property. Throws an IllegalArgumentException if bounds checking is
true and the value cannot be
reconciled with the given type.
if (this.valueObject == null) {
this.valueObject = "";
}
return getObjectFromString(this.getValue(), this.getValueType());
|
private java.lang.Object | getValueObjectUsingAllowedTypes(java.lang.String string)
if (this.type.equals(int.class.getName())) {
return Integer.valueOf(string);
} else if (this.type.equals(long.class.getName())) {
return Long.valueOf(string);
} else if (this.type.equals(short.class.getName())) {
return Short.valueOf(string);
} else if (this.type.equals(boolean.class.getName())) {
return Boolean.valueOf(string);
} else if (this.type.equals(float.class.getName())) {
return new Float(string);
} else if (this.type.equals(double.class.getName())) {
return new Double(string);
} else if (this.type.equals(byte.class.getName())) {
return Byte.valueOf(string);
} else if (this.type.equals(char.class.getName())) {
if (string.length() != 1) {
throw new IllegalArgumentException();
} else {
return Character.valueOf(string.charAt(0));
}
}
return null;
|
public java.lang.Class | getValueType()Returns value type of this environment property.
if (this.type == null) {
return String.class;
} else {
try {
return Class.forName(this.type);
} catch (Throwable t) {
return null;
}
}
|
public boolean | hasAValue()
return setValueCalled;
|
public int | hashCode()The hashCode of an environment property is the same as that of the name String.
return this.getName().hashCode();
|
public boolean | isInjectable()
return (injectionTargets!=null && injectionTargets.size()>0);
//return (getInjectTargetName() != null);
|
public void | print(java.lang.StringBuffer toStringBuffer)Returns a String representation of this environment property.
toStringBuffer.append("Env-Prop: ").append(super.getName()).append("@");
printInjectableResourceInfo(toStringBuffer);
toStringBuffer.append("@").append(this.getType()).append("@").append(this.getValue()).append("@").append("@").append(super.getDescription());
|
public java.lang.StringBuffer | printInjectableResourceInfo(java.lang.StringBuffer toStringBuffer)
if( isInjectable() ) {
for (InjectionTarget target : getInjectionTargets()) {
if( target.isFieldInjectable() ) {
toStringBuffer.append("Field-Injectable Resource. Class name = ").
append(target.getClassName()).append(" Field name=").
append(target.getFieldName());
} else {
toStringBuffer.append("Method-Injectable Resource. Class name =").
append(target.getClassName()).append(" Method =").
append(target.getMethodName());
}
}
} else {
toStringBuffer.append("Non-Injectable Resource");
}
return toStringBuffer;
|
public void | setInjectResourceType(java.lang.String resourceType)
type = convertPrimitiveTypes(resourceType);
|
public void | setMappedName(java.lang.String mName)
mappedName = mName;
|
public void | setType(java.lang.String type)Returns value type of this environment property. Throws Illegal argument exception if this is not an
allowed type and bounds checking.
checkType(type);
this.type = type;
|
public void | setValue(java.lang.String value)Sets the value of the environment property to the given string.
this.value = value;
this.setValueCalled = true;
super.changed();
|