KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > module > bridge > DummyBridgeImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.apache.tools.ant.module.bridge;
21
22 import java.io.File JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.util.Enumeration JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27 import org.apache.tools.ant.module.AntModule;
28 import org.netbeans.api.progress.ProgressHandle;
29 import org.openide.ErrorManager;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Enumerations;
32 import org.openide.windows.OutputWriter;
33
34 /**
35  * Used when the real Ant class loader cannot be initialized for some reason.
36  * @author Jesse Glick
37  */

38 final class DummyBridgeImpl implements BridgeInterface, IntrospectionHelperProxy {
39     
40     private final Throwable JavaDoc problem;
41     
42     public DummyBridgeImpl(Throwable JavaDoc problem) {
43         this.problem = problem;
44         AntModule.err.notify(ErrorManager.INFORMATIONAL, problem);
45     }
46     
47     public String JavaDoc getAntVersion() {
48         return NbBundle.getMessage(DummyBridgeImpl.class, "ERR_ant_not_loadable", problem);
49     }
50     
51     public boolean isAnt16() {
52         return false;
53     }
54     
55     public IntrospectionHelperProxy getIntrospectionHelper(Class JavaDoc clazz) {
56         return this;
57     }
58     
59     public Class JavaDoc getAttributeType(String JavaDoc name) {
60         throw new IllegalStateException JavaDoc();
61     }
62     
63     public Enumeration JavaDoc<String JavaDoc> getAttributes() {
64         return Enumerations.empty();
65     }
66     
67     public Class JavaDoc getElementType(String JavaDoc name) {
68         throw new IllegalStateException JavaDoc();
69     }
70     
71     public Enumeration JavaDoc<String JavaDoc> getNestedElements() {
72         return Enumerations.empty();
73     }
74     
75     public boolean supportsCharacters() {
76         return false;
77     }
78     
79     public boolean toBoolean(String JavaDoc val) {
80         return Boolean.valueOf(val).booleanValue();
81     }
82     
83     public String JavaDoc[] getEnumeratedValues(Class JavaDoc c) {
84         return null;
85     }
86     
87     public boolean run(File JavaDoc buildFile, List JavaDoc<String JavaDoc> targets, InputStream JavaDoc in, OutputWriter out, OutputWriter err, Map JavaDoc<String JavaDoc,String JavaDoc> properties, int verbosity, String JavaDoc displayName, Runnable JavaDoc interestingOutputCallback, ProgressHandle handle) {
88         err.println(NbBundle.getMessage(DummyBridgeImpl.class, "ERR_cannot_run_target"));
89         problem.printStackTrace(err);
90         return false;
91     }
92
93     public void stop(Thread JavaDoc process) {
94         // do nothing
95
}
96     
97 }
98
Popular Tags