1 // SECTION-START[License Header] 2 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 3 /* 4 * Copyright (c) 2010 The JOMC Project 5 * Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * o Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * o Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * $Id: JaxpDocumentBuilderFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $ 33 * 34 */ 35 // </editor-fold> 36 // SECTION-END 37 package org.jomc.sdk.model.support; 38 39 import java.util.Map; 40 import javax.xml.parsers.DocumentBuilder; 41 import javax.xml.parsers.DocumentBuilderFactory; 42 import javax.xml.parsers.ParserConfigurationException; 43 44 // SECTION-START[Documentation] 45 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 46 /** 47 * JAXP 'DocumentBuilder' factory implementation. 48 * <p><b>Specifications</b><ul> 49 * <li>{@code 'javax.xml.parsers.DocumentBuilder'} {@code (javax.xml.parsers.DocumentBuilder)} {@code Multiton}</li> 50 * </ul></p> 51 * <p><b>Properties</b><ul> 52 * <li>"{@link #isXIncludeAware XIncludeAware}" 53 * <blockquote>Property of type {@code java.lang.Boolean}. 54 * <p>{@code true} if the factory is configured to produce XInclude aware parsers; {@code false} otherwise.</p> 55 * </blockquote></li> 56 * <li>"{@link #getAttributes attributes}" 57 * <blockquote>Property of type {@code java.util.Map<String,Object>}. 58 * </blockquote></li> 59 * <li>"{@link #isCoalescing coalescing}" 60 * <blockquote>Property of type {@code java.lang.Boolean}. 61 * <p>{@code true} if the factory is configured to produce parsers which convert CDATA nodes to Text nodes and append them to the adjacent (if any) Text node; {@code false} otherwise.</p> 62 * </blockquote></li> 63 * <li>"{@link #isExpandingEntityReferences expandingEntityReferences}" 64 * <blockquote>Property of type {@code java.lang.Boolean}. 65 * <p>{@code true} if the factory is configured to produce parsers which expand entity reference nodes; {@code false} otherwise.</p> 66 * </blockquote></li> 67 * <li>"{@link #getFeatures features}" 68 * <blockquote>Property of type {@code java.util.Map<String,Boolean>}. 69 * </blockquote></li> 70 * <li>"{@link #isIgnoringComments ignoringComments}" 71 * <blockquote>Property of type {@code java.lang.Boolean}. 72 * <p>{@code true} if the factory is configured to produce parsers which ignores comments; {@code false} otherwise.</p> 73 * </blockquote></li> 74 * <li>"{@link #isIgnoringElementContentWhitespace ignoringElementContentWhitespace}" 75 * <blockquote>Property of type {@code java.lang.Boolean}. 76 * <p>{@code true} if the factory is configured to produce parsers which ignore ignorable whitespace in element content; {@code false} otherwise.</p> 77 * </blockquote></li> 78 * <li>"{@link #isNamespaceAware namespaceAware}" 79 * <blockquote>Property of type {@code java.lang.Boolean}. 80 * <p>{@code true} if the factory is configured to produce parsers which are namespace aware; {@code false} otherwise.</p> 81 * </blockquote></li> 82 * <li>"{@link #isValidating validating}" 83 * <blockquote>Property of type {@code java.lang.Boolean}. 84 * <p>{@code true} if the factory is configured to produce parsers which validate the XML content during parse; {@code false} otherwise.</p> 85 * </blockquote></li> 86 * </ul></p> 87 * <p><b>Dependencies</b><ul> 88 * <li>"{@link #getEntityResolver entityResolver}"<blockquote> 89 * Dependency on {@code 'org.xml.sax.EntityResolver'} {@code (org.xml.sax.EntityResolver)} bound to an instance.</blockquote></li> 90 * <li>"{@link #getErrorHandler errorHandler}"<blockquote> 91 * Dependency on {@code 'org.xml.sax.ErrorHandler'} {@code (org.xml.sax.ErrorHandler)} bound to an instance.</blockquote></li> 92 * <li>"{@link #getSchema schema}"<blockquote> 93 * Dependency on {@code 'javax.xml.validation.Schema'} {@code (javax.xml.validation.Schema)} bound to an instance.</blockquote></li> 94 * </ul></p> 95 * 96 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 97 * @version $Id: JaxpDocumentBuilderFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $ 98 */ 99 // </editor-fold> 100 // SECTION-END 101 // SECTION-START[Annotations] 102 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 103 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 104 // </editor-fold> 105 // SECTION-END 106 public final class JaxpDocumentBuilderFactory 107 { 108 // SECTION-START[DocumentBuilder] 109 // SECTION-END 110 // SECTION-START[JaxpDocumentBuilderFactory] 111 112 public DocumentBuilder getObject() throws ParserConfigurationException 113 { 114 final DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); 115 f.setSchema( this.getSchema() ); 116 f.setCoalescing( this.isCoalescing() ); 117 f.setExpandEntityReferences( this.isExpandingEntityReferences() ); 118 f.setIgnoringComments( this.isIgnoringComments() ); 119 f.setIgnoringElementContentWhitespace( this.isIgnoringElementContentWhitespace() ); 120 f.setNamespaceAware( this.isNamespaceAware() ); 121 f.setValidating( this.isValidating() ); 122 f.setXIncludeAware( this.isXIncludeAware() ); 123 124 for ( Map.Entry<String, Boolean> e : this.getFeatures().entrySet() ) 125 { 126 f.setFeature( e.getKey(), e.getValue() ); 127 } 128 129 for ( Map.Entry<String, Object> e : this.getAttributes().entrySet() ) 130 { 131 f.setAttribute( e.getKey(), e.getValue() ); 132 } 133 134 final DocumentBuilder b = f.newDocumentBuilder(); 135 b.setEntityResolver( this.getEntityResolver() ); 136 b.setErrorHandler( this.getErrorHandler() ); 137 return b; 138 } 139 140 // SECTION-END 141 // SECTION-START[Constructors] 142 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> 143 144 /** Creates a new {@code JaxpDocumentBuilderFactory} instance. */ 145 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 146 public JaxpDocumentBuilderFactory() 147 { 148 // SECTION-START[Default Constructor] 149 super(); 150 // SECTION-END 151 } 152 // </editor-fold> 153 // SECTION-END 154 // SECTION-START[Dependencies] 155 // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies "> 156 157 /** 158 * Gets the {@code entityResolver} dependency. 159 * <p>This method returns the {@code 'JOMC SDK Model Default'} object of the {@code 'org.xml.sax.EntityResolver'} {@code (org.xml.sax.EntityResolver)} specification.</p> 160 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 161 * @return The {@code entityResolver} dependency. 162 * {@code null} if no object is available. 163 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 164 */ 165 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 166 private org.xml.sax.EntityResolver getEntityResolver() 167 { 168 return (org.xml.sax.EntityResolver) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "entityResolver" ); 169 } 170 171 /** 172 * Gets the {@code errorHandler} dependency. 173 * <p>This method returns the {@code 'JOMC SDK Model Default'} object of the {@code 'org.xml.sax.ErrorHandler'} {@code (org.xml.sax.ErrorHandler)} specification.</p> 174 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 175 * @return The {@code errorHandler} dependency. 176 * {@code null} if no object is available. 177 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 178 */ 179 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 180 private org.xml.sax.ErrorHandler getErrorHandler() 181 { 182 return (org.xml.sax.ErrorHandler) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "errorHandler" ); 183 } 184 185 /** 186 * Gets the {@code schema} dependency. 187 * <p>This method returns the {@code 'JOMC SDK Model Default'} object of the {@code 'javax.xml.validation.Schema'} {@code (javax.xml.validation.Schema)} specification.</p> 188 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 189 * @return The {@code schema} dependency. 190 * {@code null} if no object is available. 191 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 192 */ 193 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 194 private javax.xml.validation.Schema getSchema() 195 { 196 return (javax.xml.validation.Schema) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "schema" ); 197 } 198 // </editor-fold> 199 // SECTION-END 200 // SECTION-START[Properties] 201 // <editor-fold defaultstate="collapsed" desc=" Generated Properties "> 202 203 /** 204 * Gets the value of the {@code XIncludeAware} property. 205 * @return {@code true} if the factory is configured to produce XInclude aware parsers; {@code false} otherwise. 206 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 207 */ 208 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 209 private java.lang.Boolean isXIncludeAware() 210 { 211 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "XIncludeAware" ); 212 assert _p != null : "'XIncludeAware' property not found."; 213 return _p; 214 } 215 216 /** 217 * Gets the value of the {@code attributes} property. 218 * @return The value of the {@code attributes} property. 219 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 220 */ 221 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 222 private java.util.Map<String,Object> getAttributes() 223 { 224 final java.util.Map<String,Object> _p = (java.util.Map<String,Object>) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "attributes" ); 225 assert _p != null : "'attributes' property not found."; 226 return _p; 227 } 228 229 /** 230 * Gets the value of the {@code coalescing} property. 231 * @return {@code true} if the factory is configured to produce parsers which convert CDATA nodes to Text nodes and append them to the adjacent (if any) Text node; {@code false} otherwise. 232 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 233 */ 234 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 235 private java.lang.Boolean isCoalescing() 236 { 237 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "coalescing" ); 238 assert _p != null : "'coalescing' property not found."; 239 return _p; 240 } 241 242 /** 243 * Gets the value of the {@code expandingEntityReferences} property. 244 * @return {@code true} if the factory is configured to produce parsers which expand entity reference nodes; {@code false} otherwise. 245 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 246 */ 247 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 248 private java.lang.Boolean isExpandingEntityReferences() 249 { 250 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "expandingEntityReferences" ); 251 assert _p != null : "'expandingEntityReferences' property not found."; 252 return _p; 253 } 254 255 /** 256 * Gets the value of the {@code features} property. 257 * @return The value of the {@code features} property. 258 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 259 */ 260 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 261 private java.util.Map<String,Boolean> getFeatures() 262 { 263 final java.util.Map<String,Boolean> _p = (java.util.Map<String,Boolean>) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "features" ); 264 assert _p != null : "'features' property not found."; 265 return _p; 266 } 267 268 /** 269 * Gets the value of the {@code ignoringComments} property. 270 * @return {@code true} if the factory is configured to produce parsers which ignores comments; {@code false} otherwise. 271 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 272 */ 273 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 274 private java.lang.Boolean isIgnoringComments() 275 { 276 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "ignoringComments" ); 277 assert _p != null : "'ignoringComments' property not found."; 278 return _p; 279 } 280 281 /** 282 * Gets the value of the {@code ignoringElementContentWhitespace} property. 283 * @return {@code true} if the factory is configured to produce parsers which ignore ignorable whitespace in element content; {@code false} otherwise. 284 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 285 */ 286 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 287 private java.lang.Boolean isIgnoringElementContentWhitespace() 288 { 289 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "ignoringElementContentWhitespace" ); 290 assert _p != null : "'ignoringElementContentWhitespace' property not found."; 291 return _p; 292 } 293 294 /** 295 * Gets the value of the {@code namespaceAware} property. 296 * @return {@code true} if the factory is configured to produce parsers which are namespace aware; {@code false} otherwise. 297 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 298 */ 299 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 300 private java.lang.Boolean isNamespaceAware() 301 { 302 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "namespaceAware" ); 303 assert _p != null : "'namespaceAware' property not found."; 304 return _p; 305 } 306 307 /** 308 * Gets the value of the {@code validating} property. 309 * @return {@code true} if the factory is configured to produce parsers which validate the XML content during parse; {@code false} otherwise. 310 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 311 */ 312 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 313 private java.lang.Boolean isValidating() 314 { 315 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "validating" ); 316 assert _p != null : "'validating' property not found."; 317 return _p; 318 } 319 // </editor-fold> 320 // SECTION-END 321 // SECTION-START[Messages] 322 // SECTION-END 323 }