KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > ant > node > AntFileNode


1 package org.enhydra.kelp.ant.node;
2 //Kelp imports
3
import org.enhydra.kelp.common.node.OtterFileNode;
4 import org.enhydra.kelp.common.node.OtterProject;
5 import org.enhydra.kelp.common.node.OtterNode;
6 import org.enhydra.kelp.common.node.PropertyKeys;
7 import org.enhydra.kelp.common.PropUtil;
8 // ToolBox imports
9
import org.enhydra.tool.common.PathHandle;
10
11 /**
12  * <p>Title: </p>
13  * <p>Description: </p>
14  * <p>Copyright: Copyright (c) 2003</p>
15  * <p>Company: </p>
16  * @author Damir Milovic
17  * @version 1.0
18  */

19
20 public class AntFileNode implements OtterFileNode {
21
22   protected Throwable JavaDoc exception = null;
23   protected OtterNode otterNode = null;
24   protected String JavaDoc path = null;
25   protected OtterProject project = null;
26   //FIXME spesific properties for now are holds here (should be paged into unique file)
27
protected String JavaDoc selected = "false";
28
29   public AntFileNode(OtterNode node) {
30     otterNode = node;
31     project = otterNode.getProject();
32   }
33   public AntFileNode(OtterNode node,String JavaDoc filePath) {
34     this(node);
35     path = filePath;
36   }
37   public String JavaDoc getFilePath() {
38     return path;
39   }
40   public String JavaDoc getProperty(String JavaDoc property) {
41     if(property.equalsIgnoreCase(PropertyKeys.NAME_SELECTED))
42       return selected; //FIXME see the Definition of selected
43
else
44       return project.getProperty(property); //The OtterProject (AntProjet) holds all properties
45
}
46   public void setProperty(String JavaDoc property, String JavaDoc value) {
47     if(property.equalsIgnoreCase(PropertyKeys.NAME_SELECTED))
48       selected = value;
49     else
50       project.setProperty(property,value); //Let the OtterProject (AntProjet) holds all properties
51
}
52   public void setProperty(String JavaDoc property, int value) {
53     project.setProperty(property,value); //Let the OtterProject (AntProjet) holds all properties
54
}
55   public Object JavaDoc getNativeNode() {
56     return null;
57   }
58   public void setNativeNode(Object JavaDoc o) {
59     /**@todo: Implement this org.enhydra.kelp.common.node.OtterNode method*/
60     throw new java.lang.UnsupportedOperationException JavaDoc("Method setNativeNode() not yet implemented.");
61   }
62   public OtterProject getProject() {
63     return project;
64   }
65   public OtterNode getParent() {
66     if(otterNode instanceof OtterProject)
67       return otterNode;
68     else
69       return otterNode.getParent();
70   }
71   public String JavaDoc getXMLCOptionFilePath() {
72     return project.getXMLCOptionFilePath(); //The OtterProject (AntProjet) holds all properties
73
}
74   public void setXMLCOptionFilePath(String JavaDoc n) {
75     project.setXMLCOptionFilePath(n); //Let the OtterProject (AntProjet) holds all properties
76
}
77   public String JavaDoc getXMLCParameters() {
78     return project.getXMLCParameters(); //...
79
}
80   public void setXMLCParameters(String JavaDoc p) {
81     project.setXMLCParameters(p);
82   }
83   public boolean isSelected() {
84     String JavaDoc in = getProperty(PropertyKeys.NAME_SELECTED);
85     return PropUtil.stringToBoolean(in, false);
86   }
87   public void setSelected(boolean b) {
88     setProperty(PropertyKeys.NAME_SELECTED, PropUtil.booleanToString(b));
89   }
90   /**
91    * Save Exception information for reporting. This lets exceptions from
92    * multiple nodes to be reported in a batch.
93    *
94    * @param e
95    * An exception that occured while invoking XMLC.
96    */

97   public void setException(Throwable JavaDoc e) {
98     exception = e;
99   }
100
101   /**
102    * Get an exception that occured when invoking XMLC. Null if the node
103    * has not been compiled or was compiled without error.
104    */

105   public Throwable JavaDoc getException() {
106       return exception;
107   }
108   public void save() {
109     //FIXME
110
// System.out.println("AntFileNode path="+path+" save()");
111
}
112
113 }
Popular Tags