PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/netbeans-7.3/java.source.ant/src/org/netbeans/modules/java/source/ant/ProjectRunnerImpl.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 812 lines | 630 code | 132 blank | 50 comment | 134 complexity | 9d69043281e242bc9430087d46f9f204 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * If you wish your version of this file to be governed by only the CDDL
  28. * or only the GPL Version 2, indicate your decision by adding
  29. * "[Contributor] elects to include this software in this distribution
  30. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  31. * single choice of license, a recipient has the option to distribute
  32. * your version of this file under either the CDDL, the GPL Version 2 or
  33. * to extend the choice of license to its licensees as provided above.
  34. * However, if you add GPL Version 2 code and therefore, elected the GPL
  35. * Version 2 license, then the option applies only if the new code is
  36. * made subject to such option by the copyright holder.
  37. *
  38. * Contributor(s):
  39. *
  40. * Portions Copyrighted 2008 Sun Microsystems, Inc.
  41. */
  42. package org.netbeans.modules.java.source.ant;
  43. import java.beans.PropertyChangeEvent;
  44. import java.beans.PropertyChangeListener;
  45. import java.util.TreeMap;
  46. import java.io.File;
  47. import java.io.IOException;
  48. import java.io.InputStream;
  49. import java.io.OutputStream;
  50. import java.net.URL;
  51. import java.net.URLConnection;
  52. import java.nio.charset.Charset;
  53. import java.text.MessageFormat;
  54. import java.util.ArrayList;
  55. import java.util.Collections;
  56. import java.util.HashMap;
  57. import java.util.LinkedList;
  58. import java.util.List;
  59. import java.util.Map;
  60. import java.util.Map.Entry;
  61. import java.util.Properties;
  62. import java.util.logging.Level;
  63. import java.util.logging.Logger;
  64. import javax.swing.event.ChangeEvent;
  65. import javax.swing.event.ChangeListener;
  66. import org.apache.tools.ant.module.api.AntProjectCookie;
  67. import org.apache.tools.ant.module.api.AntTargetExecutor;
  68. import org.apache.tools.ant.module.api.support.AntScriptUtils;
  69. import org.netbeans.api.extexecution.startup.StartupExtender;
  70. import org.netbeans.api.java.classpath.ClassPath;
  71. import org.netbeans.api.java.platform.JavaPlatform;
  72. import org.netbeans.api.java.project.runner.JavaRunner;
  73. import org.netbeans.api.java.queries.SourceForBinaryQuery;
  74. import org.netbeans.api.project.FileOwnerQuery;
  75. import org.netbeans.api.project.Project;
  76. import org.netbeans.api.project.ProjectUtils;
  77. import org.netbeans.api.queries.FileEncodingQuery;
  78. import org.netbeans.modules.java.source.usages.BuildArtifactMapperImpl;
  79. import org.netbeans.spi.java.project.runner.JavaRunnerImplementation;
  80. import org.openide.execution.ExecutionEngine;
  81. import org.openide.execution.ExecutorTask;
  82. import org.openide.filesystems.FileObject;
  83. import org.openide.filesystems.FileStateInvalidException;
  84. import org.openide.filesystems.FileUtil;
  85. import org.openide.modules.Places;
  86. import org.openide.util.ChangeSupport;
  87. import org.openide.util.Exceptions;
  88. import org.openide.util.NbBundle;
  89. import org.openide.util.Parameters;
  90. import org.openide.util.WeakListeners;
  91. import org.openide.windows.InputOutput;
  92. import org.w3c.dom.Attr;
  93. import org.w3c.dom.DOMException;
  94. import org.w3c.dom.Document;
  95. import org.w3c.dom.Element;
  96. import org.w3c.dom.NamedNodeMap;
  97. import org.w3c.dom.Node;
  98. import org.w3c.dom.NodeList;
  99. import org.w3c.dom.TypeInfo;
  100. import org.w3c.dom.UserDataHandler;
  101. import static org.netbeans.api.java.project.runner.JavaRunner.*;
  102. import org.netbeans.api.project.ProjectManager;
  103. import org.openide.loaders.DataObject;
  104. import org.openide.util.Lookup;
  105. import org.openide.util.Utilities;
  106. import org.openide.util.lookup.AbstractLookup;
  107. import org.openide.util.lookup.InstanceContent;
  108. /**
  109. *
  110. * @author Jan Lahoda
  111. */
  112. @org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.java.project.runner.JavaRunnerImplementation.class)
  113. public class ProjectRunnerImpl implements JavaRunnerImplementation {
  114. private static final Logger LOG = Logger.getLogger(ProjectRunnerImpl.class.getName());
  115. public boolean isSupported(String command, Map<String, ?> properties) {
  116. return locateScript(command) != null;
  117. }
  118. public ExecutorTask execute(String command, Map<String, ?> properties) throws IOException {
  119. if (QUICK_CLEAN.equals(command)) {
  120. return clean(properties);
  121. }
  122. String[] projectName = new String[1];
  123. Map<String,String> antProps = computeProperties(command, properties, projectName);
  124. FileObject script = buildScript(command, false);
  125. AntProjectCookie apc = new FakeAntProjectCookie(AntScriptUtils.antProjectCookieFor(script), command, projectName[0]);
  126. AntTargetExecutor.Env execenv = new AntTargetExecutor.Env();
  127. Properties props = execenv.getProperties();
  128. props.putAll(antProps);
  129. props.put("nb.wait.for.caches", "true");
  130. if (properties.containsKey("maven.disableSources")) {
  131. props.put("maven.disableSources", String.valueOf(properties.get("maven.disableSources")));
  132. }
  133. execenv.setProperties(props);
  134. return AntTargetExecutor.createTargetExecutor(execenv).execute(apc, null);
  135. }
  136. static Map<String,String> computeProperties(String command, Map<String, ?> properties, String[] projectNameOut) {
  137. properties = new HashMap<String, Object>(properties);
  138. FileObject toRun = getValue(properties, PROP_EXECUTE_FILE, FileObject.class);
  139. String workDir = getValue(properties, PROP_WORK_DIR, String.class);
  140. String className = getValue(properties, PROP_CLASSNAME, String.class);
  141. ClassPath boot = getValue(properties, "boot.classpath", ClassPath.class);
  142. ClassPath exec = getValue(properties, PROP_EXECUTE_CLASSPATH, ClassPath.class);
  143. String javaTool = getValue(properties, PROP_PLATFORM_JAVA, String.class);
  144. String projectName = getValue(properties, PROP_PROJECT_NAME, String.class);
  145. Iterable<String> args = getMultiValue(properties, PROP_APPLICATION_ARGS, String.class);
  146. final String tmpDir = getValue(properties, "tmp.dir", String.class); //NOI18N
  147. if (workDir == null) {
  148. Parameters.notNull(PROP_EXECUTE_FILE + " or " + PROP_WORK_DIR, toRun);
  149. Project project = FileOwnerQuery.getOwner(toRun);
  150. if (project != null) {
  151. //NOI18N
  152. FileObject projDirectory = project.getProjectDirectory();
  153. assert projDirectory != null;
  154. File file = FileUtil.toFile(projDirectory);
  155. if (file != null) {
  156. workDir = file.getAbsolutePath(); //NOI18N
  157. }
  158. }
  159. }
  160. if (className == null) {
  161. Parameters.notNull(PROP_EXECUTE_FILE + " or " + PROP_CLASSNAME, toRun);
  162. ClassPath source = ClassPath.getClassPath(toRun, ClassPath.SOURCE);
  163. if (source == null) {
  164. throw new IllegalArgumentException("The source classpath for specified toRun parameter has is null. " +
  165. "Report against caller module. [toRun = " + toRun + "]");
  166. }
  167. className = source.getResourceName(toRun, '.', false);
  168. }
  169. if (exec == null) {
  170. Parameters.notNull(PROP_EXECUTE_FILE + " or " + PROP_EXECUTE_CLASSPATH, toRun);
  171. exec = ClassPath.getClassPath(toRun, ClassPath.EXECUTE);
  172. }
  173. JavaPlatform p = getValue(properties, PROP_PLATFORM, JavaPlatform.class);
  174. if (p == null) {
  175. p = JavaPlatform.getDefault();
  176. }
  177. if (javaTool == null) {
  178. FileObject javaToolFO = p.findTool("java");
  179. if (javaToolFO == null) {
  180. IllegalArgumentException iae = new IllegalArgumentException("Cannot find java");
  181. Exceptions.attachLocalizedMessage(iae, NbBundle.getMessage(ProjectRunnerImpl.class, "ERR_CannotFindJava"));
  182. throw iae;
  183. }
  184. javaTool = FileUtil.toFile(javaToolFO).getAbsolutePath();
  185. }
  186. if (boot == null) {
  187. boot = p.getBootstrapLibraries();
  188. }
  189. Project project = getValue(properties, "project", Project.class);
  190. if (project == null && toRun != null) {
  191. project = FileOwnerQuery.getOwner(toRun);
  192. }
  193. if (project == null && workDir != null) {
  194. FileObject d = FileUtil.toFileObject(FileUtil.normalizeFile(new File(workDir)));
  195. if (d != null) {
  196. try {
  197. project = ProjectManager.getDefault().findProject(d);
  198. } catch (IOException x) {
  199. Exceptions.printStackTrace(x);
  200. }
  201. }
  202. }
  203. if (projectName == null) {
  204. if (project != null) {
  205. projectName = ProjectUtils.getInformation(project).getDisplayName();
  206. } else {
  207. projectName = "";
  208. }
  209. }
  210. List<String> runJVMArgs = new ArrayList<String>(getMultiValue(properties, PROP_RUN_JVMARGS, String.class));
  211. StartupExtender.StartMode mode;
  212. if (command.equals(QUICK_RUN)) {
  213. mode = StartupExtender.StartMode.NORMAL;
  214. } else if (command.equals(QUICK_DEBUG)) {
  215. mode = StartupExtender.StartMode.DEBUG;
  216. } else if (command.equals(QUICK_TEST)) {
  217. mode = StartupExtender.StartMode.TEST_NORMAL;
  218. } else if (command.equals(QUICK_TEST_DEBUG)) {
  219. mode = StartupExtender.StartMode.TEST_DEBUG;
  220. } else {
  221. mode = null;
  222. }
  223. if (mode != null) {
  224. InstanceContent ic = new InstanceContent();
  225. if (project != null) {
  226. ic.add(project);
  227. }
  228. if (p != null) {
  229. ic.add(p);
  230. }
  231. Lookup l = new AbstractLookup(ic);
  232. for (StartupExtender group : StartupExtender.getExtenders(l, mode)) {
  233. runJVMArgs.addAll(group.getArguments());
  234. }
  235. }
  236. LOG.log(Level.FINE, "execute classpath={0}", exec);
  237. String cp = exec.toString(ClassPath.PathConversionMode.FAIL);
  238. Map<String,String> antProps = new TreeMap<String,String>();
  239. setProperty(antProps, "platform.bootcp", boot.toString(ClassPath.PathConversionMode.FAIL));
  240. setProperty(antProps, "classpath", cp);
  241. setProperty(antProps, "classname", className);
  242. setProperty(antProps, "platform.java", javaTool);
  243. setProperty(antProps, "work.dir", workDir);
  244. setProperty(antProps, "run.jvmargs", toOneLine(runJVMArgs));
  245. setProperty(antProps, "run.jvmargs.ide", (String)properties.get("run.jvmargs.ide"));
  246. if (tmpDir != null) {
  247. setProperty(antProps, "tmp.dir", tmpDir); //NOI18N
  248. }
  249. if (toRun == null) {
  250. // #152881 - pass arguments only if not run single
  251. setProperty(antProps, "application.args", toOneLine(args));
  252. }
  253. {
  254. FileObject source = toRun;
  255. final Charset charset = getValue(properties, JavaRunner.PROP_RUNTIME_ENCODING, Charset.class); //NOI18N
  256. String encoding = charset != null && Charset.isSupported(charset.name()) ? charset.name() : null;
  257. if (encoding == null) {
  258. if (source == null) {
  259. String binaryResource = className.replace('.', '/') + ".class";
  260. out: for (FileObject root : exec.getRoots()) {
  261. if (root.getFileObject(binaryResource) != null) {
  262. try {
  263. String sourceResource = className.replace('.', '/') + ".java";
  264. for (FileObject srcRoot : SourceForBinaryQuery.findSourceRoots(root.getURL()).getRoots()) {
  265. FileObject srcFile = srcRoot.getFileObject(sourceResource);
  266. if (srcFile != null) {
  267. source = srcFile;
  268. break out;
  269. }
  270. }
  271. } catch (FileStateInvalidException ex) {
  272. Exceptions.printStackTrace(ex);
  273. }
  274. }
  275. }
  276. }
  277. if (source != null) {
  278. Charset sourceEncoding = FileEncodingQuery.getEncoding(source);
  279. if (Charset.isSupported(sourceEncoding.name())) {
  280. encoding = sourceEncoding.name();
  281. }
  282. }
  283. }
  284. if (encoding == null) {
  285. //Encoding still null => fallback to UTF-8
  286. encoding = "UTF-8"; //NOI18N
  287. }
  288. setProperty(antProps, "encoding", encoding);
  289. }
  290. for (Entry<String, ?> e : properties.entrySet()) {
  291. if (e.getValue() instanceof String) {
  292. antProps.put(e.getKey(), (String) e.getValue());
  293. }
  294. }
  295. projectNameOut[0] = projectName;
  296. return antProps;
  297. }
  298. private static ExecutorTask clean(Map<String, ?> properties) {
  299. properties = new HashMap<String, Object>(properties);
  300. String projectName = getValue(properties, PROP_PROJECT_NAME, String.class);
  301. FileObject toRun = getValue(properties, PROP_EXECUTE_FILE, FileObject.class);
  302. ClassPath exec = getValue(properties, PROP_EXECUTE_CLASSPATH, ClassPath.class);
  303. if (exec == null) {
  304. Parameters.notNull("toRun", toRun);
  305. exec = ClassPath.getClassPath(toRun, ClassPath.EXECUTE);
  306. }
  307. if (projectName == null) {
  308. Project project = getValue(properties, "project", Project.class);
  309. if (project != null) {
  310. projectName = ProjectUtils.getInformation(project).getDisplayName();
  311. }
  312. if (projectName == null && toRun != null) {
  313. project = FileOwnerQuery.getOwner(toRun);
  314. if (project != null) {
  315. //NOI18N
  316. projectName = ProjectUtils.getInformation(project).getDisplayName();
  317. }
  318. }
  319. if (projectName == null) {
  320. projectName = "";
  321. }
  322. }
  323. LOG.log(Level.FINE, "execute classpath={0}", exec);
  324. final ClassPath execFin = exec;
  325. return ExecutionEngine.getDefault().execute(projectName, new Runnable() {
  326. public void run() {
  327. try {
  328. doClean(execFin);
  329. } catch (IOException ex) {
  330. Exceptions.printStackTrace(ex);
  331. }
  332. }
  333. }, InputOutput.NULL);
  334. }
  335. private static void setProperty(Map<String,String> antProps, String property, String value) {
  336. if (value != null) {
  337. antProps.put(property, value);
  338. }
  339. }
  340. private static <T> T getValue(Map<String, ?> properties, String name, Class<T> type) {
  341. Object v = properties.remove(name);
  342. if (v instanceof FileObject && type == String.class) {
  343. FileObject f = (FileObject) v;
  344. File file = FileUtil.toFile(f);
  345. if (file == null) {
  346. return null;
  347. }
  348. v = file.getAbsolutePath();
  349. }
  350. if (v instanceof File && type == String.class) {
  351. v = ((File) v).getAbsolutePath();
  352. }
  353. return type.cast(v);
  354. }
  355. private static <T> List<T> getMultiValue(Map<String, ?> properties, String name, Class<T> type) {
  356. Iterable v = (Iterable) properties.remove(name);
  357. List<T> result = new LinkedList<T>();
  358. if (v == null) {
  359. return Collections.emptyList();
  360. }
  361. for (Object o : v) {
  362. result.add(type.cast(o));
  363. }
  364. return result;
  365. }
  366. private static String toOneLine(Iterable<String> it) {
  367. StringBuilder result = new StringBuilder();
  368. boolean first = true;
  369. for (String s : it) {
  370. if (!first) {
  371. result.append(' ');
  372. }
  373. first = false;
  374. result.append(s);
  375. }
  376. return result.toString();
  377. }
  378. private static URL locateScript(String actionName) {
  379. return ProjectRunnerImpl.class.getResource("/org/netbeans/modules/java/source/ant/resources/" + actionName + "-snippet.xml");
  380. }
  381. private static FileObject buildScript(String actionName, boolean forceCopy) throws IOException {
  382. URL script = locateScript(actionName);
  383. if (script == null) {
  384. return null;
  385. }
  386. URL thisClassSource = ProjectRunnerImpl.class.getProtectionDomain().getCodeSource().getLocation();
  387. File jarFile = FileUtil.archiveOrDirForURL(thisClassSource);
  388. File scriptFile = Places.getCacheSubfile("executor-snippets/" + actionName + ".xml");
  389. if (forceCopy || !scriptFile.canRead() || (jarFile != null && jarFile.lastModified() > scriptFile.lastModified())) {
  390. try {
  391. URLConnection connection = script.openConnection();
  392. FileObject target = FileUtil.createData(scriptFile);
  393. copyFile(connection, target);
  394. return target;
  395. } catch (IOException ex) {
  396. Exceptions.printStackTrace(ex);
  397. return null;
  398. }
  399. }
  400. return FileUtil.toFileObject(scriptFile);
  401. }
  402. private static void copyFile(URLConnection source, FileObject target) throws IOException {
  403. InputStream ins = null;
  404. OutputStream out = null;
  405. try {
  406. ins = source.getInputStream();
  407. out = target.getOutputStream();
  408. FileUtil.copy(ins, out);
  409. } finally {
  410. if (ins != null) {
  411. try {
  412. ins.close();
  413. } catch (IOException ex) {
  414. Exceptions.printStackTrace(ex);
  415. }
  416. }
  417. if (out != null) {
  418. try {
  419. out.close();
  420. } catch (IOException ex) {
  421. Exceptions.printStackTrace(ex);
  422. }
  423. }
  424. }
  425. }
  426. private static void doClean(ClassPath exec) throws IOException {
  427. for (ClassPath.Entry entry : exec.entries()) {
  428. SourceForBinaryQuery.Result2 r = SourceForBinaryQuery.findSourceRoots2(entry.getURL());
  429. if (r.preferSources() && r.getRoots().length > 0) {
  430. for (FileObject source : r.getRoots()) {
  431. File sourceFile = FileUtil.toFile(source);
  432. if (sourceFile == null) {
  433. LOG.log(Level.WARNING, "Source URL: {0} cannot be translated to file, skipped", source.getURL().toExternalForm());
  434. continue;
  435. }
  436. BuildArtifactMapperImpl.clean(Utilities.toURI(sourceFile).toURL());
  437. }
  438. }
  439. }
  440. }
  441. private static final class FakeAntProjectCookie implements AntProjectCookie, ChangeListener {
  442. private final AntProjectCookie apc;
  443. private final String command;
  444. private final String projectName;
  445. private final ChangeSupport cs = new ChangeSupport(this);
  446. public FakeAntProjectCookie(AntProjectCookie apc, String command, String projectName) {
  447. this.apc = apc;
  448. this.apc.addChangeListener(WeakListeners.change(this, this.apc));
  449. this.command = command;
  450. this.projectName = projectName;
  451. }
  452. public File getFile() {
  453. return this.apc.getFile();
  454. }
  455. public FileObject getFileObject() {
  456. return this.apc.getFileObject();
  457. }
  458. public Document getDocument() {
  459. return this.apc.getDocument();
  460. }
  461. public Element getProjectElement() {
  462. Element element = apc.getProjectElement();
  463. if (element == null || this.apc.getParseException() != null) {
  464. final File fo = this.apc.getFile();
  465. LOG.log(Level.FINE, String.format("Cannot parse: %s exists: %b readable: %b",
  466. fo == null ? null : fo.getAbsolutePath(),
  467. fo == null ? false : fo.exists(),
  468. fo == null ? false : fo.canRead()));
  469. try {
  470. DataObject od = DataObject.find(buildScript(command, true));
  471. //the APC does not refresh itself automatically, need to push it to the refresh:
  472. if (od instanceof PropertyChangeListener) {
  473. ((PropertyChangeListener) od).propertyChange(new PropertyChangeEvent(od, null, null, null));
  474. }
  475. } catch (IOException ex) {
  476. throw new IllegalStateException(ex);
  477. }
  478. element = apc.getProjectElement();
  479. if (element == null) return null;
  480. }
  481. return new FakeElement(element, projectName);
  482. }
  483. public Throwable getParseException() {
  484. return this.apc.getParseException();
  485. }
  486. public void addChangeListener(ChangeListener l) {
  487. cs.addChangeListener(l);
  488. }
  489. public void removeChangeListener(ChangeListener l) {
  490. cs.removeChangeListener(l);
  491. }
  492. public void stateChanged(ChangeEvent e) {
  493. cs.fireChange();
  494. }
  495. }
  496. private static final class FakeElement implements Element {
  497. private final Element delegate;
  498. private final String projectName;
  499. public FakeElement(final Element delegate, String projectName) {
  500. Parameters.notNull("delegate", delegate); //NOI18N
  501. this.delegate = delegate;
  502. this.projectName = projectName;
  503. }
  504. public Object setUserData(String key, Object data, UserDataHandler handler) {
  505. return delegate.setUserData(key, data, handler);
  506. }
  507. public void setTextContent(String textContent) throws DOMException {
  508. delegate.setTextContent(textContent);
  509. }
  510. public void setPrefix(String prefix) throws DOMException {
  511. delegate.setPrefix(prefix);
  512. }
  513. public void setNodeValue(String nodeValue) throws DOMException {
  514. delegate.setNodeValue(nodeValue);
  515. }
  516. public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
  517. return delegate.replaceChild(newChild, oldChild);
  518. }
  519. public Node removeChild(Node oldChild) throws DOMException {
  520. return delegate.removeChild(oldChild);
  521. }
  522. public void normalize() {
  523. delegate.normalize();
  524. }
  525. public String lookupPrefix(String namespaceURI) {
  526. return delegate.lookupPrefix(namespaceURI);
  527. }
  528. public String lookupNamespaceURI(String prefix) {
  529. return delegate.lookupNamespaceURI(prefix);
  530. }
  531. public boolean isSupported(String feature, String version) {
  532. return delegate.isSupported(feature, version);
  533. }
  534. public boolean isSameNode(Node other) {
  535. return delegate.isSameNode(other);
  536. }
  537. public boolean isEqualNode(Node arg) {
  538. return delegate.isEqualNode(arg);
  539. }
  540. public boolean isDefaultNamespace(String namespaceURI) {
  541. return delegate.isDefaultNamespace(namespaceURI);
  542. }
  543. public Node insertBefore(Node newChild, Node refChild) throws DOMException {
  544. return delegate.insertBefore(newChild, refChild);
  545. }
  546. public boolean hasChildNodes() {
  547. return delegate.hasChildNodes();
  548. }
  549. public boolean hasAttributes() {
  550. return delegate.hasAttributes();
  551. }
  552. public Object getUserData(String key) {
  553. return delegate.getUserData(key);
  554. }
  555. public String getTextContent() throws DOMException {
  556. return delegate.getTextContent();
  557. }
  558. public Node getPreviousSibling() {
  559. return delegate.getPreviousSibling();
  560. }
  561. public String getPrefix() {
  562. return delegate.getPrefix();
  563. }
  564. public Node getParentNode() {
  565. return delegate.getParentNode();
  566. }
  567. public Document getOwnerDocument() {
  568. return delegate.getOwnerDocument();
  569. }
  570. public String getNodeValue() throws DOMException {
  571. return delegate.getNodeValue();
  572. }
  573. public short getNodeType() {
  574. return delegate.getNodeType();
  575. }
  576. public String getNodeName() {
  577. return delegate.getNodeName();
  578. }
  579. public Node getNextSibling() {
  580. return delegate.getNextSibling();
  581. }
  582. public String getNamespaceURI() {
  583. return delegate.getNamespaceURI();
  584. }
  585. public String getLocalName() {
  586. return delegate.getLocalName();
  587. }
  588. public Node getLastChild() {
  589. return delegate.getLastChild();
  590. }
  591. public Node getFirstChild() {
  592. return delegate.getFirstChild();
  593. }
  594. public Object getFeature(String feature, String version) {
  595. return delegate.getFeature(feature, version);
  596. }
  597. public NodeList getChildNodes() {
  598. return delegate.getChildNodes();
  599. }
  600. public String getBaseURI() {
  601. return delegate.getBaseURI();
  602. }
  603. public NamedNodeMap getAttributes() {
  604. return delegate.getAttributes();
  605. }
  606. public short compareDocumentPosition(Node other) throws DOMException {
  607. return delegate.compareDocumentPosition(other);
  608. }
  609. public Node cloneNode(boolean deep) {
  610. return delegate.cloneNode(deep);
  611. }
  612. public Node appendChild(Node newChild) throws DOMException {
  613. return delegate.appendChild(newChild);
  614. }
  615. public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
  616. delegate.setIdAttributeNode(idAttr, isId);
  617. }
  618. public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException {
  619. delegate.setIdAttributeNS(namespaceURI, localName, isId);
  620. }
  621. public void setIdAttribute(String name, boolean isId) throws DOMException {
  622. delegate.setIdAttribute(name, isId);
  623. }
  624. public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
  625. return delegate.setAttributeNodeNS(newAttr);
  626. }
  627. public Attr setAttributeNode(Attr newAttr) throws DOMException {
  628. return delegate.setAttributeNode(newAttr);
  629. }
  630. public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
  631. delegate.setAttributeNS(namespaceURI, qualifiedName, value);
  632. }
  633. public void setAttribute(String name, String value) throws DOMException {
  634. delegate.setAttribute(name, value);
  635. }
  636. public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
  637. return delegate.removeAttributeNode(oldAttr);
  638. }
  639. public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
  640. delegate.removeAttributeNS(namespaceURI, localName);
  641. }
  642. public void removeAttribute(String name) throws DOMException {
  643. delegate.removeAttribute(name);
  644. }
  645. public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException {
  646. return delegate.hasAttributeNS(namespaceURI, localName);
  647. }
  648. public boolean hasAttribute(String name) {
  649. return delegate.hasAttribute(name);
  650. }
  651. public String getTagName() {
  652. return delegate.getTagName();
  653. }
  654. public TypeInfo getSchemaTypeInfo() {
  655. return delegate.getSchemaTypeInfo();
  656. }
  657. public NodeList getElementsByTagNameNS(String namespaceURI, String localName) throws DOMException {
  658. return delegate.getElementsByTagNameNS(namespaceURI, localName);
  659. }
  660. public NodeList getElementsByTagName(String name) {
  661. return delegate.getElementsByTagName(name);
  662. }
  663. public Attr getAttributeNodeNS(String namespaceURI, String localName) throws DOMException {
  664. return delegate.getAttributeNodeNS(namespaceURI, localName);
  665. }
  666. public Attr getAttributeNode(String name) {
  667. return delegate.getAttributeNode(name);
  668. }
  669. public String getAttributeNS(String namespaceURI, String localName) throws DOMException {
  670. return delegate.getAttributeNS(namespaceURI, localName);
  671. }
  672. public String getAttribute(String name) {
  673. if ("name".equals(name)) {
  674. String pattern = delegate.getAttribute(name);
  675. return MessageFormat.format(pattern, projectName);
  676. }
  677. return delegate.getAttribute(name);
  678. }
  679. }
  680. }