KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > metadata > JavaCompilerSection


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: JavaCompilerSection.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.metadata;
25
26 import java.util.ArrayList JavaDoc;
27
28 import org.w3c.dom.Document JavaDoc;
29
30 /**
31  * Java compiler metadata.
32  */

33 public class JavaCompilerSection extends MetaDataElement {
34     /**
35      * Element name.
36      */

37     public static final String JavaDoc TAG_NAME = "javaCompiler";
38
39     /**
40      * Attribute names.
41      */

42     private static final String JavaDoc JAVAC_ATTR = "javac";
43
44     /**
45      * Default javac compiler.
46      */

47     public static final String JavaDoc DEFAULT_JAVAC = "javac";
48
49     /**
50      * Constructor.
51      */

52     public JavaCompilerSection(Document JavaDoc ownerDoc) {
53         super(ownerDoc, TAG_NAME);
54     }
55
56     /**
57      * Get the value of the javac attribute or the default if not specified.
58      */

59     public String JavaDoc getJavac() {
60          String JavaDoc javac = getAttributeNull(JAVAC_ATTR);
61          if (javac == null) {
62              return DEFAULT_JAVAC;
63          } else {
64              return javac;
65          }
66     }
67
68     /**
69      * Set the value of the javac attribute.
70      */

71     public void setJavac(String JavaDoc value) {
72         setAttribute(JAVAC_ATTR, value);
73     }
74
75     /**
76      * Determine if the javac attribute is specified.
77      */

78     public boolean isJavacSpecified() {
79         return isAttributeSpecified(JAVAC_ATTR);
80     }
81
82     /**
83      * Get the JavacOption child elements.
84      */

85     public JavacOption[] getJavacOptions() {
86         return (JavacOption[])getChildren(JavacOption.class);
87     }
88
89     /**
90      * Add a JavacOption child element.
91      */

92     public void addJavacOption(JavacOption javacOption) {
93         appendChild(javacOption);
94     }
95
96     /**
97      * Create and add a new JavacOption child element.
98      */

99     public JavacOption addJavacOption() {
100         JavacOption javacOption = new JavacOption(getOwnerDocument());
101         appendChild(javacOption);
102         return javacOption;
103     }
104
105     /**
106      * Delete a JavacOption child element.
107      */

108     public void deleteJavacOption(JavacOption javacOption) {
109         removeChild(javacOption);
110     }
111
112     /**
113      * Delete a JavacOption child element by name. Ignore if it doesn't
114      * exist. Deletes all copies if specified multiple times.
115      */

116     public void deleteJavacOption(String JavaDoc optionName) {
117         JavacOption[] options = getJavacOptions();
118         for (int idx = 0; idx < options.length; idx++) {
119             if (options[idx].getName().equals(optionName)) {
120                 removeChild(options[idx]);
121             }
122         }
123     }
124
125     /*
126      * Get the javac arguments (flags + options), in command line form.
127      */

128     public String JavaDoc[] getJavacArgs() {
129         ArrayList JavaDoc args = new ArrayList JavaDoc();
130
131         JavacOption[] options = getJavacOptions();
132         for (int idx = 0; idx < options.length; idx++) {
133             args.add(options[idx].getName());
134             String JavaDoc value = options[idx].getValue();
135             if (value != null) {
136                 args.add(value);
137             }
138         }
139         return (String JavaDoc[])args.toArray(new String JavaDoc[args.size()]);
140     }
141 }
142
Popular Tags