001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Copyright (c) 2010 The JOMC Project
005     *   Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net>
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
021     *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
022     *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
023     *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
024     *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025     *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026     *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
027     *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
028     *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
029     *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
030     *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031     *
032     *   $Id: JaxpDocumentBuilderFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $
033     *
034     */
035    // </editor-fold>
036    // SECTION-END
037    package org.jomc.sdk.model.support;
038    
039    import java.util.Map;
040    import javax.xml.parsers.DocumentBuilder;
041    import javax.xml.parsers.DocumentBuilderFactory;
042    import javax.xml.parsers.ParserConfigurationException;
043    
044    // SECTION-START[Documentation]
045    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
046    /**
047     * JAXP 'DocumentBuilder' factory implementation.
048     * <p><b>Specifications</b><ul>
049     * <li>{@code 'javax.xml.parsers.DocumentBuilder'} {@code (javax.xml.parsers.DocumentBuilder)} {@code Multiton}</li>
050     * </ul></p>
051     * <p><b>Properties</b><ul>
052     * <li>"{@link #isXIncludeAware XIncludeAware}"
053     * <blockquote>Property of type {@code java.lang.Boolean}.
054     * <p>{@code true} if the factory is configured to produce XInclude aware parsers; {@code false} otherwise.</p>
055     * </blockquote></li>
056     * <li>"{@link #getAttributes attributes}"
057     * <blockquote>Property of type {@code java.util.Map<String,Object>}.
058     * </blockquote></li>
059     * <li>"{@link #isCoalescing coalescing}"
060     * <blockquote>Property of type {@code java.lang.Boolean}.
061     * <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>
062     * </blockquote></li>
063     * <li>"{@link #isExpandingEntityReferences expandingEntityReferences}"
064     * <blockquote>Property of type {@code java.lang.Boolean}.
065     * <p>{@code true} if the factory is configured to produce parsers which expand entity reference nodes; {@code false} otherwise.</p>
066     * </blockquote></li>
067     * <li>"{@link #getFeatures features}"
068     * <blockquote>Property of type {@code java.util.Map<String,Boolean>}.
069     * </blockquote></li>
070     * <li>"{@link #isIgnoringComments ignoringComments}"
071     * <blockquote>Property of type {@code java.lang.Boolean}.
072     * <p>{@code true} if the factory is configured to produce parsers which ignores comments; {@code false} otherwise.</p>
073     * </blockquote></li>
074     * <li>"{@link #isIgnoringElementContentWhitespace ignoringElementContentWhitespace}"
075     * <blockquote>Property of type {@code java.lang.Boolean}.
076     * <p>{@code true} if the factory is configured to produce parsers which ignore ignorable whitespace in element content; {@code false} otherwise.</p>
077     * </blockquote></li>
078     * <li>"{@link #isNamespaceAware namespaceAware}"
079     * <blockquote>Property of type {@code java.lang.Boolean}.
080     * <p>{@code true} if the factory is configured to produce parsers which are namespace aware; {@code false} otherwise.</p>
081     * </blockquote></li>
082     * <li>"{@link #isValidating validating}"
083     * <blockquote>Property of type {@code java.lang.Boolean}.
084     * <p>{@code true} if the factory is configured to produce parsers which validate the XML content during parse; {@code false} otherwise.</p>
085     * </blockquote></li>
086     * </ul></p>
087     * <p><b>Dependencies</b><ul>
088     * <li>"{@link #getEntityResolver entityResolver}"<blockquote>
089     * Dependency on {@code 'org.xml.sax.EntityResolver'} {@code (org.xml.sax.EntityResolver)} bound to an instance.</blockquote></li>
090     * <li>"{@link #getErrorHandler errorHandler}"<blockquote>
091     * Dependency on {@code 'org.xml.sax.ErrorHandler'} {@code (org.xml.sax.ErrorHandler)} bound to an instance.</blockquote></li>
092     * <li>"{@link #getSchema schema}"<blockquote>
093     * Dependency on {@code 'javax.xml.validation.Schema'} {@code (javax.xml.validation.Schema)} bound to an instance.</blockquote></li>
094     * </ul></p>
095     *
096     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
097     * @version $Id: JaxpDocumentBuilderFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $
098     */
099    // </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    }