001: package org.enhydra.kelp.ant.node;
002:
003: //Kelp imports
004: import org.enhydra.kelp.common.node.OtterFileNode;
005: import org.enhydra.kelp.common.node.OtterProject;
006: import org.enhydra.kelp.common.node.OtterNode;
007: import org.enhydra.kelp.common.node.PropertyKeys;
008: import org.enhydra.kelp.common.PropUtil;
009:
010: /**
011: * <p>Title: </p>
012: * <p>Description: </p>
013: * <p>Copyright: Copyright (c) 2003</p>
014: * <p>Company: </p>
015: * @author Damir Milovic
016: * @version 1.0
017: */
018:
019: public class AntFileNode implements OtterFileNode {
020:
021: protected Throwable exception = null;
022: protected OtterNode otterNode = null;
023: protected String path = null;
024: protected OtterProject project = null;
025: //FIXME spesific properties for now are holds here (should be paged into unique file)
026: protected String selected = "false";
027:
028: public AntFileNode(OtterNode node) {
029: otterNode = node;
030: project = otterNode.getProject();
031: }
032:
033: public AntFileNode(OtterNode node, String filePath) {
034: this (node);
035: path = filePath;
036: }
037:
038: public String getFilePath() {
039: return path;
040: }
041:
042: public String getProperty(String property) {
043: if (property.equalsIgnoreCase(PropertyKeys.NAME_SELECTED))
044: return selected; //FIXME see the Definition of selected
045: else
046: return project.getProperty(property); //The OtterProject (AntProjet) holds all properties
047: }
048:
049: public void setProperty(String property, String value) {
050: if (property.equalsIgnoreCase(PropertyKeys.NAME_SELECTED))
051: selected = value;
052: else
053: project.setProperty(property, value); //Let the OtterProject (AntProjet) holds all properties
054: }
055:
056: public void setProperty(String property, int value) {
057: project.setProperty(property, value); //Let the OtterProject (AntProjet) holds all properties
058: }
059:
060: public Object getNativeNode() {
061: return null;
062: }
063:
064: public void setNativeNode(Object o) {
065: /**@todo: Implement this org.enhydra.kelp.common.node.OtterNode method*/
066: throw new java.lang.UnsupportedOperationException(
067: "Method setNativeNode() not yet implemented.");
068: }
069:
070: public OtterProject getProject() {
071: return project;
072: }
073:
074: public OtterNode getParent() {
075: if (otterNode instanceof OtterProject)
076: return otterNode;
077: else
078: return otterNode.getParent();
079: }
080:
081: public String getXMLCOptionFilePath() {
082: return project.getXMLCOptionFilePath(); //The OtterProject (AntProjet) holds all properties
083: }
084:
085: public void setXMLCOptionFilePath(String n) {
086: project.setXMLCOptionFilePath(n); //Let the OtterProject (AntProjet) holds all properties
087: }
088:
089: public String getXMLCParameters() {
090: return project.getXMLCParameters(); //...
091: }
092:
093: public void setXMLCParameters(String p) {
094: project.setXMLCParameters(p);
095: }
096:
097: public boolean isSelected() {
098: String in = getProperty(PropertyKeys.NAME_SELECTED);
099: return PropUtil.stringToBoolean(in, false);
100: }
101:
102: public void setSelected(boolean b) {
103: setProperty(PropertyKeys.NAME_SELECTED, PropUtil
104: .booleanToString(b));
105: }
106:
107: /**
108: * Save Exception information for reporting. This lets exceptions from
109: * multiple nodes to be reported in a batch.
110: *
111: * @param e
112: * An exception that occured while invoking XMLC.
113: */
114: public void setException(Throwable e) {
115: exception = e;
116: }
117:
118: /**
119: * Get an exception that occured when invoking XMLC. Null if the node
120: * has not been compiled or was compiled without error.
121: */
122: public Throwable getException() {
123: return exception;
124: }
125:
126: public void save() {
127: //FIXME
128: // System.out.println("AntFileNode path="+path+" save()");
129: }
130:
131: }
|