001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.xslt.model.impl;
021:
022: import java.math.BigDecimal;
023: import java.util.ArrayList;
024: import java.util.Collection;
025: import java.util.List;
026:
027: import org.netbeans.modules.xslt.model.Import;
028: import org.netbeans.modules.xslt.model.InvalidAttributeValueException;
029: import org.netbeans.modules.xslt.model.Stylesheet;
030: import org.netbeans.modules.xslt.model.StylesheetChild;
031: import org.netbeans.modules.xslt.model.XslComponent;
032: import org.netbeans.modules.xslt.model.XslVisitor;
033: import org.netbeans.modules.xslt.model.enums.Annotaions;
034: import org.netbeans.modules.xslt.model.enums.DefaultValidation;
035: import org.w3c.dom.Element;
036:
037: /**
038: * @author ads
039: *
040: */
041: class StylesheetImpl extends XslComponentImpl implements Stylesheet {
042:
043: StylesheetImpl(XslModelImpl model) {
044: this (model, null);
045: }
046:
047: StylesheetImpl(XslModelImpl model, Element element) {
048: super (model, element);
049: }
050:
051: /* (non-Javadoc)
052: * @see org.netbeans.modules.xslt.model.impl.XslComponentImpl#accept(org.netbeans.modules.xslt.model.XslVisitor)
053: */
054: @Override
055: public void accept(XslVisitor visitor) {
056: visitor.visit(this );
057: }
058:
059: /* (non-Javadoc)
060: * @see org.netbeans.modules.xslt.model.impl.XslComponentImpl#getComponentType()
061: */
062: @Override
063: public Class<? extends XslComponent> getComponentType() {
064: return Stylesheet.class;
065: }
066:
067: /* (non-Javadoc)
068: * @see org.netbeans.modules.xslt.model.Stylesheet#addImport(org.netbeans.modules.xslt.model.Import, int)
069: */
070: public void addImport(Import impt, int position) {
071: insertAtIndex(IMPORT_PROPERTY, impt, position);
072: }
073:
074: /* (non-Javadoc)
075: * @see org.netbeans.modules.xslt.model.Stylesheet#appendImport(org.netbeans.modules.xslt.model.Import)
076: */
077: public void appendImport(Import impt) {
078: addAfter(IMPORT_PROPERTY, impt, STYLESHEET_CHILDREN);
079: }
080:
081: /* (non-Javadoc)
082: * @see org.netbeans.modules.xslt.model.Stylesheet#removeImport(org.netbeans.modules.xslt.model.Import)
083: */
084: public void removeImport(Import impt) {
085: removeChild(IMPORT_PROPERTY, impt);
086: }
087:
088: /* (non-Javadoc)
089: * @see org.netbeans.modules.xslt.model.Stylesheet#setID(java.lang.String)
090: */
091: public void setID(String id) {
092: setAttribute(XslAttributes.ID, id);
093: }
094:
095: /* (non-Javadoc)
096: * @see org.netbeans.modules.xslt.model.Stylesheet#getID()
097: */
098: public String getID() {
099: return getAttribute(XslAttributes.ID);
100: }
101:
102: /* (non-Javadoc)
103: * @see org.netbeans.modules.xslt.model.Stylesheet#addStylesheetChild(org.netbeans.modules.xslt.model.StylesheetChild, int)
104: */
105: public void addStylesheetChild(StylesheetChild child, int position) {
106: insertAtIndex(STYLESHEET_TOP_LEVEL_ELEMENTS, child, position);
107: }
108:
109: /* (non-Javadoc)
110: * @see org.netbeans.modules.xslt.model.Stylesheet#appendStylesheetChild(org.netbeans.modules.xslt.model.StylesheetChild)
111: */
112: public void appendStylesheetChild(StylesheetChild child) {
113: appendChild(STYLESHEET_TOP_LEVEL_ELEMENTS, child);
114: }
115:
116: /* (non-Javadoc)
117: * @see org.netbeans.modules.xslt.model.Stylesheet#getImports()
118: */
119: public List<Import> getImports() {
120: return getChildren(Import.class);
121: }
122:
123: /* (non-Javadoc)
124: * @see org.netbeans.modules.xslt.model.Stylesheet#getStylesheetChild()
125: */
126: public List<StylesheetChild> getStylesheetChildren() {
127: return getChildren(StylesheetChild.class);
128: }
129:
130: /* (non-Javadoc)
131: * @see org.netbeans.modules.xslt.model.Stylesheet#removeStylesheetChild(org.netbeans.modules.xslt.model.StylesheetChild)
132: */
133: public void removeStylesheetChild(StylesheetChild child) {
134: removeChild(STYLESHEET_TOP_LEVEL_ELEMENTS, child);
135: }
136:
137: /* (non-Javadoc)
138: * @see org.netbeans.modules.xslt.model.Stylesheet#getDefaultCollation()
139: */
140: @SuppressWarnings("unchecked")
141: public List<String> getDefaultCollation() {
142: return (List<String>) getAttributeValueOf(
143: XslAttributes.DEFAULT_COLLATION,
144: getAttribute(XslAttributes.DEFAULT_COLLATION));
145: }
146:
147: /* (non-Javadoc)
148: * @see org.netbeans.modules.xslt.model.Stylesheet#getDefaultValidation()
149: */
150: public DefaultValidation getDefaultValidation() {
151: return DefaultValidation
152: .forString(getAttribute(XslAttributes.DEFAULT_VALIDATION));
153: }
154:
155: /* (non-Javadoc)
156: * @see org.netbeans.modules.xslt.model.Stylesheet#getExcludeResultPrefixes()
157: */
158: @SuppressWarnings("unchecked")
159: public List<String> getExcludeResultPrefixes() {
160: return (List<String>) getAttributeValueOf(
161: XslAttributes.EXCLUDE_RESULT_PREFIXES,
162: getAttribute(XslAttributes.EXCLUDE_RESULT_PREFIXES));
163: }
164:
165: /* (non-Javadoc)
166: * @see org.netbeans.modules.xslt.model.Stylesheet#getExtensionElementPrefixes()
167: */
168: @SuppressWarnings("unchecked")
169: public List<String> getExtensionElementPrefixes() {
170: return (List<String>) getAttributeValueOf(
171: XslAttributes.EXTENSION_ELEMENT_PREFIXES,
172: getAttribute(XslAttributes.EXTENSION_ELEMENT_PREFIXES));
173: }
174:
175: /* (non-Javadoc)
176: * @see org.netbeans.modules.xslt.model.Stylesheet#getInputTypeAnnotations()
177: */
178: public Annotaions getInputTypeAnnotations() {
179: return Annotaions
180: .forString(getAttribute(XslAttributes.INPUT_TYPE_ANNOTAIONS));
181: }
182:
183: /* (non-Javadoc)
184: * @see org.netbeans.modules.xslt.model.Stylesheet#getVersion()
185: */
186: public BigDecimal getVersion()
187: throws InvalidAttributeValueException {
188: String value = getAttribute(XslAttributes.VERSION);
189: BigDecimal ret = null;
190: try {
191: ret = new BigDecimal(value);
192: } catch (NumberFormatException exc) {
193: throw new InvalidAttributeValueException(value, exc);
194: }
195: return ret;
196: }
197:
198: /* (non-Javadoc)
199: * @see org.netbeans.modules.xslt.model.Stylesheet#getXpathDefaultNamespace()
200: */
201: public String getXpathDefaultNamespace() {
202: return getAttribute(XslAttributes.XPATH_DEFAULT_NAMESPACE);
203: }
204:
205: /* (non-Javadoc)
206: * @see org.netbeans.modules.xslt.model.Stylesheet#setDefaultCollation(java.util.List)
207: */
208: public void setDefaultCollation(List<String> list) {
209: setAttributeTokenList(XslAttributes.DEFAULT_COLLATION, list);
210: }
211:
212: /* (non-Javadoc)
213: * @see org.netbeans.modules.xslt.model.Stylesheet#setDefaultValidation(org.netbeans.modules.xslt.model.enums.DefaultValidation)
214: */
215: public void setDefaultValidation(DefaultValidation value) {
216: setAttribute(XslAttributes.DEFAULT_VALIDATION, value);
217: }
218:
219: /* (non-Javadoc)
220: * @see org.netbeans.modules.xslt.model.Stylesheet#setExcludeResultPrefixes(java.util.List)
221: */
222: public void setExcludeResultPrefixes(List<String> list) {
223: setAttributeTokenList(XslAttributes.EXCLUDE_RESULT_PREFIXES,
224: list);
225: }
226:
227: /* (non-Javadoc)
228: * @see org.netbeans.modules.xslt.model.Stylesheet#setExtensionElementPrefixes(java.util.List)
229: */
230: public void setExtensionElementPrefixes(List<String> list) {
231: setAttributeTokenList(XslAttributes.EXTENSION_ELEMENT_PREFIXES,
232: list);
233: }
234:
235: /* (non-Javadoc)
236: * @see org.netbeans.modules.xslt.model.Stylesheet#setInputTypeAnnotations(org.netbeans.modules.xslt.model.enums.Annotaions)
237: */
238: public void setInputTypeAnnotations(Annotaions value) {
239: setAttribute(XslAttributes.INPUT_TYPE_ANNOTAIONS, value);
240: }
241:
242: /* (non-Javadoc)
243: * @see org.netbeans.modules.xslt.model.Stylesheet#setVersion(java.math.BigDecimal)
244: */
245: public void setVersion(BigDecimal value) {
246: setAttribute(XslAttributes.VERSION, value);
247: }
248:
249: /* (non-Javadoc)
250: * @see org.netbeans.modules.xslt.model.Stylesheet#setXpathDefaultNamespace(java.lang.String)
251: */
252: public void setXpathDefaultNamespace(String value) {
253: setAttribute(XslAttributes.XPATH_DEFAULT_NAMESPACE, value);
254: }
255:
256: /* (non-Javadoc)
257: * @see org.netbeans.modules.xslt.model.Stylesheet#findAllDefinedChildren()
258: */
259: public Collection<StylesheetChild> findAllDefinedChildren() {
260: // TODO Auto-generated method stub
261: return null;
262: }
263:
264: private static final Collection<Class<? extends XslComponent>> STYLESHEET_CHILDREN = new ArrayList<Class<? extends XslComponent>>(
265: 1);
266:
267: static {
268: STYLESHEET_CHILDREN.add(StylesheetChild.class);
269: }
270:
271: }
|