KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > driver > XmlcTestParams


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: XmlcTestParams.java,v 1.2 2005/01/26 08:29:25 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.driver;
25
26 import java.io.File JavaDoc;
27
28 import org.enhydra.xml.driver.TestProperties;
29 import org.enhydra.xml.xmlc.commands.xmlc.XMLC;
30
31 /**
32  * Object to hold parameters that are globally applied to the tests.
33  * Instances are immutable. Also contains methods for getting
34  * the paths to directories defined by these paramameters.
35  */

36 public class XmlcTestParams {
37     /** Constants for test names */
38     public static final String JavaDoc RELOADING = "reload";
39     public static final String JavaDoc STD_LOADING = "stdload";
40
41     /** Is this an XML or HTML test? */
42     private final boolean fIsXml;
43
44     /** Whether to use deferred parsing for reloading */
45     private final boolean fIsDeferredParsing;
46
47     /** Parser to use */
48     private final String JavaDoc fParser;
49
50     /** The DOM to use */
51     private final String JavaDoc fDom;
52     
53     /** Is jikes being used? */
54     private final boolean fUsingJikes;
55
56     /** Doing reloading/recomp testing? */
57     private final boolean fReloading;
58     private final String JavaDoc fReloadingStr;
59
60     /** Parameters, seperated by `.' */
61     private final String JavaDoc fParamsStr;
62
63     /** Get the basic parameters as a string (less reloading) */
64     private final String JavaDoc fBasicParamsStr;
65
66     /**
67      * Constructor.
68      */

69     public XmlcTestParams(boolean isXml,
70                           String JavaDoc parser,
71                           String JavaDoc dom,
72                           boolean reloading) {
73     this(isXml, parser, dom, reloading, false);
74     }
75
76     /**
77      * Constructor.
78      */

79     public XmlcTestParams(boolean isXml,
80                           String JavaDoc parser,
81                           String JavaDoc dom,
82                           boolean reloading,
83               boolean isDeferringParsing) {
84         fIsXml = isXml;
85     fIsDeferredParsing = isDeferringParsing;
86
87         fParser = parser;
88         fDom = dom;
89         fReloading = reloading;
90         fReloadingStr = (fReloading ? RELOADING : STD_LOADING);
91
92         // Determine if the property is set to use jikes as the
93
// default XMLC parser
94
String JavaDoc defaultJavac = System.getProperty(XMLC.JAVAC_PROPERTY);
95         boolean usingJikes = false;
96         if (defaultJavac != null) {
97             File JavaDoc javac = new File JavaDoc(defaultJavac);
98             if (javac.getName().indexOf("jikes") >= 0) {
99                 usingJikes = true;
100             }
101         }
102         fUsingJikes = usingJikes;
103         fBasicParamsStr = fParser + "." + fDom;
104         fParamsStr = fBasicParamsStr + "." + fReloadingStr;
105     }
106
107     /**
108      * Factory method to obtain an instance of the parameters with parser,
109      * DOM, and reload set from properties.
110      */

111     public static XmlcTestParams getParams(boolean isXml) {
112         String JavaDoc defParser = (isXml ? ExecXmlc.XERCES_PARSER
113                             : ExecXmlc.TIDY_PARSER);
114     
115         return new XmlcTestParams(isXml,
116                                   TestProperties.getParser(defParser),
117                                   TestProperties.getDom(ExecXmlc.XERCES_DOM),
118                                   TestProperties.getReloading(),
119                   TestProperties.getDeferredParsing());
120     }
121
122
123     /** Is this an XML or HTML test */
124     public boolean getIsXml() {
125         return fIsXml;
126     }
127
128     /** Is this a deferred parsing test */
129     public boolean getIsDeferredParsing() {
130         return fIsDeferredParsing;
131     }
132
133     /** Get the parser to use */
134     public String JavaDoc getParser() {
135         return fParser;
136     }
137
138     /** The DOM to use */
139     public String JavaDoc getDom() {
140         return fDom;
141     }
142
143     /** Doing reloading testing? */
144     public boolean getReloading() {
145         return fReloading;
146     }
147
148     /** Is jikes the default compiler? */
149     public boolean getUsingJikes() {
150         return fUsingJikes;
151     }
152
153     /** Get the parameters as a string, seperated by `.' */
154     public String JavaDoc getParamsStr() {
155         return fParamsStr;
156     }
157
158     /**
159      * Get the basic parameters as a string (less reloading),
160      * seperated by `.'
161      */

162     public String JavaDoc getBasicParamsStr() {
163         return fBasicParamsStr;
164     }
165 }
166
Popular Tags