1 26 27 package org.objectweb.jonas.ant; 28 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.taskdefs.Property; 31 32 36 public class JProperty extends Property { 37 38 41 private String internalValue = null; 42 43 46 private String defaultValue = null; 47 48 52 public void setValue(String value) { 53 this.internalValue = value; 54 } 55 56 60 public void setDefaultValue(String defaultValue) { 61 this.defaultValue = defaultValue; 62 } 63 64 69 public void execute() throws BuildException { 70 71 if (internalValue == null) { 72 throw new BuildException("The property '" + internalValue 73 + "' was not set."); 74 } 75 76 String valueEvaluated = getProject().getProperty(internalValue); 77 78 if (valueEvaluated == null && defaultValue != null) { 80 valueEvaluated = defaultValue; 81 } 82 83 if (valueEvaluated == null) { 85 throw new BuildException("The property '" + internalValue 86 + "' cannot be evaluated in the current project."); 87 } 88 89 super.setValue(valueEvaluated); 91 92 super.execute(); 94 } 95 96 } | Popular Tags |