1 package net.sf.invicta.process; 2 3 import net.sf.invicta.InvictaConstants; 4 import net.sf.invicta.InvictaException; 5 import net.sf.invicta.api.DefinedProperty; 6 import net.sf.invicta.api.InvictaComponent; 7 import net.sf.invicta.api.InvictaProject; 8 import net.sf.invicta.template.TemplateHelper; 9 import net.sf.invicta.type.BasicDefinedProperty; 10 11 14 public class TiedDefinedProperty extends BasicDefinedProperty implements DefinedProperty { 15 protected String formattedValue = null; 16 protected String unformattedValue = null; 17 protected String referenceValue = null; 18 protected String actualValue = null; 19 20 public TiedDefinedProperty(BasicDefinedProperty basicDefinedProperty, 21 InvictaComponent component, InvictaProject project) throws InvictaException { 22 super(basicDefinedProperty); 23 formatProperty(component, project); 24 } 25 26 30 public String getFormattedValue() { 31 return this.formattedValue; 32 } 33 34 public String getReferenceValue() { 35 return this.referenceValue; 36 } 37 38 public String getUnformattedValue() { 39 return this.formattedValue; 40 } 41 42 43 public String getActualValue() { 44 return this.actualValue; 45 } 46 47 48 protected void formatProperty(InvictaComponent component, InvictaProject project) throws InvictaException { 49 50 if (isComponentType()) { 52 this.unformattedValue = component.getComponentPropertyValue(this.name); 53 this.actualValue = this.unformattedValue; 54 } else if (isLocalType()) { 55 this.unformattedValue = this.defaultValue; 56 this.formattedValue = this.unformattedValue; 57 this.actualValue = this.unformattedValue; 58 this.referenceValue = this.unformattedValue; 59 } else { 60 this.unformattedValue = InvictaConstants.ANT_PROPERTY_PREFIX; 61 this.unformattedValue += this.type; 62 63 this.unformattedValue += InvictaConstants.ANT_PROPERTY_SEPARATOR + this.name + 64 InvictaConstants.ANT_PROPERTY_SUFFIX; 65 if (isProjectType()) { 66 this.actualValue = component.getProject().getProjectPropertyValue(this.name); 67 } else if (isGeneralType()) { 68 this.actualValue = this.defaultValue; 69 } 70 } 71 72 if (this.valueTemplate == null) { 74 this.formattedValue = this.unformattedValue; 75 } else { 76 77 this.formattedValue = 80 TemplateHelper.format(getValueTemplate(), project, component, 81 new Object [][] { { "value", this.unformattedValue } }); 82 83 } 84 85 if (!isLocalType()) { 87 this.referenceValue = InvictaConstants.ANT_PROPERTY_PREFIX; 88 this.referenceValue += component.getName(); 89 this.referenceValue += InvictaConstants.ANT_PROPERTY_SEPARATOR + this.name + 90 InvictaConstants.ANT_PROPERTY_SUFFIX; 91 } 92 93 } 94 95 96 } 97 | Popular Tags |