KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > invicta > process > TiedDefinedProperty


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 /**
12  *
13  */

14 public class TiedDefinedProperty extends BasicDefinedProperty implements DefinedProperty {
15     protected String JavaDoc formattedValue = null;
16     protected String JavaDoc unformattedValue = null;
17     protected String JavaDoc referenceValue = null;
18     protected String JavaDoc 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     /**
27      * Returns the formattedValue.
28      * @return String
29      */

30     public String JavaDoc getFormattedValue() {
31         return this.formattedValue;
32     }
33
34     public String JavaDoc getReferenceValue() {
35         return this.referenceValue;
36     }
37         
38     public String JavaDoc getUnformattedValue() {
39         return this.formattedValue;
40     }
41
42     
43     public String JavaDoc getActualValue() {
44         return this.actualValue;
45     }
46     
47
48     protected void formatProperty(InvictaComponent component, InvictaProject project) throws InvictaException {
49         
50         // Set the unformatted value
51
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         // Set the formatted value
73
if (this.valueTemplate == null) {
74             this.formattedValue = this.unformattedValue;
75         } else {
76                                                                                                        
77             // Format the value template. Supply the parameter 'value' with the
78
// original value of the property.
79
this.formattedValue =
80                 TemplateHelper.format(getValueTemplate(), project, component,
81                                       new Object JavaDoc[][] { { "value", this.unformattedValue } });
82                                                                                                                                         
83         }
84         
85         // Format reference value
86
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