1 package org.ejen; 22 23 import org.apache.tools.ant.Task; 24 import org.apache.tools.ant.BuildException; 25 26 61 public class EjenTask extends Task { 62 private EjenRootNode _ern = null; 63 private boolean _stacktrace = false; 64 65 70 public EjenTask() { 71 _ern = new EjenRootNode(); 72 _ern.setListener(new EjenListener() { 73 public void stateChanged(EjenEvent ev) { 74 log("(" + ev.getMessage() + ") " + ev.getSource().toString(), 75 ev.getLevel()); 76 } 77 78 public void nodeMessageSent(EjenEvent ev) { 79 log(ev.getMessage(), ev.getLevel()); 80 } 81 82 public void xslMessageSent(EjenEvent ev) { 83 log(ev.getMessage(), ev.getLevel()); 84 } 85 }); 86 } 87 88 94 public void setStacktrace(boolean stacktrace) { 95 _stacktrace = stacktrace; 96 } 97 98 102 public EjenFilterNode createFilter() { 103 EjenFilterNode f = new EjenFilterNode(); 104 105 _ern.appendChildNode(f); 106 return f; 107 } 108 109 113 public EjenTemplateNode createTemplate() { 114 EjenTemplateNode t = new EjenTemplateNode(); 115 116 _ern.appendChildNode(t); 117 return t; 118 } 119 120 124 public EjenSourceNode createSource() { 125 EjenSourceNode s = new EjenSourceNode(); 126 127 _ern.appendChildNode(s); 128 return s; 129 } 130 131 135 public EjenSaveNode createSave() { 136 EjenSaveNode s = new EjenSaveNode(); 137 138 _ern.appendChildNode(s); 139 return s; 140 } 141 142 146 public EjenMergeNode createMerge() { 147 EjenMergeNode s = new EjenMergeNode(); 148 149 _ern.appendChildNode(s); 150 return s; 151 } 152 153 157 public void execute() throws BuildException { 158 try { 159 _ern.check(); 160 _ern.beforeProcess(); 161 _ern.process(); 162 _ern.afterProcess(); 163 _ern.idle(); 164 } catch (Exception e) { 165 throw new BuildException("\n\n" 166 + EjenErrors.toString(null, null, e, _stacktrace)); 167 } 168 } 169 } 170 | Popular Tags |