KickJava   Java API By Example, From Geeks To Geeks.

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


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

23
24 package org.enhydra.xml.xmlc.metadata;
25
26 import org.w3c.dom.Document JavaDoc;
27
28 //FIXME: modify Xerces to take a already created document class.
29

30 /**
31  * Specifies the parser and parsing options.
32  */

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

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

42     private static final String JavaDoc NAME_ATTR = "name";
43     private static final String JavaDoc VALIDATE_ATTR = "validate";
44     private static final String JavaDoc WARNINGS_ATTR = "warnings";
45
46     /**
47      * Constructor.
48      */

49     public Parser(Document JavaDoc ownerDoc) {
50         super(ownerDoc, TAG_NAME);
51     }
52
53     /**
54      * Get the xcatalog metadata.
55      */

56     public XCatalog[] getXCatalog() {
57         return (XCatalog[])getChildren(XCatalog.class);
58     }
59
60     /**
61      * Add a XCatalog metadata object.
62      */

63     public void addXCatalog(XCatalog xCatalog) {
64         appendChild(xCatalog);
65     }
66
67     /**
68      * Create and add a XCatalog metadata object.
69      */

70     public XCatalog addXCatalog() {
71         XCatalog xCatalog = new XCatalog(getOwnerDocument());
72         appendChild(xCatalog);
73         return xCatalog;
74     }
75
76     /**
77      * Delete a XCatalog metadata object.
78      */

79     public void deleteXCatalog(XCatalog xCatalog) {
80         removeChild(xCatalog);
81     }
82
83     /**
84      * Get the list of XCatalog file URLs.
85      */

86     public String JavaDoc[] getXCatalogURLs() {
87         XCatalog[] xCatalogs = getXCatalog();
88         String JavaDoc[] urls = new String JavaDoc[xCatalogs.length];
89         for (int idx = 0; idx < xCatalogs.length; idx++) {
90             urls[idx] = xCatalogs[idx].getUrl();
91         }
92         return urls;
93     }
94
95     /**
96      * Get the parser to use.
97      */

98     public ParserType getName() {
99         return ParserType.getType(getAttributeNull(NAME_ATTR));
100     }
101
102     /**
103      * Set the parser to use.
104      */

105     public void setName(ParserType value) {
106         if (value == null) {
107             removeAttribute(NAME_ATTR);
108         } else {
109             setAttribute(NAME_ATTR, value.getName());
110         }
111     }
112
113     /**
114      * Get the document validation flag. Returns null if not specified.
115      */

116     public Boolean JavaDoc getValidate() {
117         return getBooleanObjectAttribute(VALIDATE_ATTR);
118     }
119
120     /**
121      * Set the document validation flag. Use a null value to make
122      * attribute unspecified.
123      */

124     public void setValidate(Boolean JavaDoc validate) {
125         setBooleanObjectAttribute(VALIDATE_ATTR, validate);
126     }
127
128     /**
129      * Set the document validation flag.
130      */

131     public void setValidate(boolean validate) {
132         setBooleanAttribute(VALIDATE_ATTR, validate);
133     }
134
135     /**
136      * Get the parser warning flag. Returns null if not specified.
137      */

138     public boolean getWarnings() {
139         return getBooleanAttribute(WARNINGS_ATTR, true);
140     }
141
142     /**
143      * Set the document validation flag.
144      */

145     public void setWarnings(boolean warnings) {
146         setBooleanAttribute(WARNINGS_ATTR, warnings, true);
147     }
148 }
149
Popular Tags