1 19 20 package org.netbeans.modules.xslt.model.impl; 21 22 import java.math.BigDecimal ; 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.List ; 26 27 import org.netbeans.modules.xslt.model.Import; 28 import org.netbeans.modules.xslt.model.InvalidAttributeValueException; 29 import org.netbeans.modules.xslt.model.Stylesheet; 30 import org.netbeans.modules.xslt.model.StylesheetChild; 31 import org.netbeans.modules.xslt.model.XslComponent; 32 import org.netbeans.modules.xslt.model.XslVisitor; 33 import org.netbeans.modules.xslt.model.enums.Annotaions; 34 import org.netbeans.modules.xslt.model.enums.DefaultValidation; 35 import org.w3c.dom.Element ; 36 37 38 42 class StylesheetImpl extends XslComponentImpl implements Stylesheet { 43 44 StylesheetImpl( XslModelImpl model ) { 45 this( model , null ); 46 } 47 48 StylesheetImpl( XslModelImpl model , Element element ) { 49 super( model , element ); 50 } 51 52 55 @Override 56 public void accept( XslVisitor visitor ) 57 { 58 visitor.visit( this ); 59 } 60 61 64 @Override 65 public Class <? extends XslComponent> getComponentType() 66 { 67 return Stylesheet.class; 68 } 69 70 73 public void addImport( Import impt, int position ) { 74 insertAtIndex( IMPORT_PROPERTY , impt, position ); 75 } 76 77 80 public void appendImport( Import impt ) { 81 addAfter( IMPORT_PROPERTY, impt , STYLESHEET_CHILDREN ); 82 } 83 84 87 public void removeImport( Import impt ) { 88 removeChild( IMPORT_PROPERTY , impt ); 89 } 90 91 94 public void setID( String id ) { 95 setAttribute( XslAttributes.ID, id ); 96 } 97 98 101 public String getID() { 102 return getAttribute( XslAttributes.ID ); 103 } 104 105 108 public void addStylesheetChild( StylesheetChild child, int position ) { 109 insertAtIndex( STYLESHEET_TOP_LEVEL_ELEMENTS, child , position ); 110 } 111 112 115 public void appendStylesheetChild( StylesheetChild child ) { 116 appendChild( STYLESHEET_TOP_LEVEL_ELEMENTS, child); 117 } 118 119 122 public List <Import> getImports() { 123 return getChildren( Import.class ); 124 } 125 126 129 public List <StylesheetChild> getStylesheetChildren() { 130 return getChildren( StylesheetChild.class ); 131 } 132 133 136 public void removeStylesheetChild( StylesheetChild child ) { 137 removeChild( STYLESHEET_TOP_LEVEL_ELEMENTS, child ); 138 } 139 140 143 @SuppressWarnings ("unchecked") 144 public List <String > getDefaultCollation() { 145 return (List <String >) getAttributeValueOf( 146 XslAttributes.DEFAULT_COLLATION, 147 getAttribute( XslAttributes.DEFAULT_COLLATION )); 148 } 149 150 153 public DefaultValidation getDefaultValidation() { 154 return DefaultValidation.forString( 155 getAttribute( XslAttributes.DEFAULT_VALIDATION ) ); 156 } 157 158 161 @SuppressWarnings ("unchecked") 162 public List <String > getExcludeResultPrefixes() { 163 return (List <String >) getAttributeValueOf( 164 XslAttributes.EXCLUDE_RESULT_PREFIXES, 165 getAttribute( XslAttributes.EXCLUDE_RESULT_PREFIXES )); 166 } 167 168 171 @SuppressWarnings ("unchecked") 172 public List <String > getExtensionElementPrefixes() { 173 return (List <String >)getAttributeValueOf( 174 XslAttributes.EXTENSION_ELEMENT_PREFIXES, 175 getAttribute( XslAttributes.EXTENSION_ELEMENT_PREFIXES)); 176 } 177 178 181 public Annotaions getInputTypeAnnotations() { 182 return Annotaions.forString( 183 getAttribute( XslAttributes.INPUT_TYPE_ANNOTAIONS )); 184 } 185 186 189 public BigDecimal getVersion() throws InvalidAttributeValueException { 190 String value = getAttribute( XslAttributes.VERSION ); 191 BigDecimal ret = null; 192 try { 193 ret = new BigDecimal ( value ); 194 } 195 catch ( NumberFormatException exc ) { 196 throw new InvalidAttributeValueException( value , exc ); 197 } 198 return ret; 199 } 200 201 204 public String getXpathDefaultNamespace() { 205 return getAttribute( XslAttributes.XPATH_DEFAULT_NAMESPACE ); 206 } 207 208 211 public void setDefaultCollation( List <String > list ) { 212 setAttributeTokenList( XslAttributes.DEFAULT_COLLATION, list); 213 } 214 215 218 public void setDefaultValidation( DefaultValidation value ) { 219 setAttribute( XslAttributes.DEFAULT_VALIDATION, value ); 220 } 221 222 225 public void setExcludeResultPrefixes( List <String > list ) { 226 setAttributeTokenList( XslAttributes.EXCLUDE_RESULT_PREFIXES, list); 227 } 228 229 232 public void setExtensionElementPrefixes( List <String > list ) { 233 setAttributeTokenList( XslAttributes.EXTENSION_ELEMENT_PREFIXES, list); 234 } 235 236 239 public void setInputTypeAnnotations( Annotaions value ) { 240 setAttribute( XslAttributes.INPUT_TYPE_ANNOTAIONS, value ); 241 } 242 243 246 public void setVersion( BigDecimal value ) { 247 setAttribute( XslAttributes.VERSION , value ); 248 } 249 250 253 public void setXpathDefaultNamespace( String value ) { 254 setAttribute( XslAttributes.XPATH_DEFAULT_NAMESPACE, value ); 255 } 256 257 260 public Collection <StylesheetChild> findAllDefinedChildren() { 261 return null; 263 } 264 265 private static final Collection <Class <? extends XslComponent>> STYLESHEET_CHILDREN = new ArrayList <Class <? extends XslComponent>>( 266 1); 267 268 static { 269 STYLESHEET_CHILDREN.add(StylesheetChild.class); 270 } 271 272 } 273 | Popular Tags |