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: JaxbIntrospectorFactory.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 javax.xml.bind.JAXBContext; |
40 | import javax.xml.bind.JAXBException; |
41 | import javax.xml.bind.JAXBIntrospector; |
42 | import org.jomc.sdk.model.SchemaType; |
43 | import static org.jomc.sdk.model.modlet.SdkModelProvider.XML_SCHEMA_JAVA_CONTEXT_ID_ATTRIBUTE; |
44 | |
45 | // SECTION-START[Documentation] |
46 | // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> |
47 | /** |
48 | * XML Schema Set 'JAXBIntrospector' factory implementation. |
49 | * <p><b>Specifications</b><ul> |
50 | * <li>{@code 'javax.xml.bind.JAXBIntrospector'} {@code (javax.xml.bind.JAXBIntrospector)} {@code Multiton}</li> |
51 | * </ul></p> |
52 | * <p><b>Properties</b><ul> |
53 | * <li>"{@link #getSchemas schemas}" |
54 | * <blockquote>Property of type {@code org.jomc.sdk.model.SchemasType}. |
55 | * <p>List of XML schemas ('schemas' element from XML namespace 'http://jomc.org/sdk/model).</p> |
56 | * </blockquote></li> |
57 | * </ul></p> |
58 | * |
59 | * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 |
60 | * @version $Id: JaxbIntrospectorFactory.java 2234 2010-06-29 00:03:38Z schulte2005 $ |
61 | */ |
62 | // </editor-fold> |
63 | // SECTION-END |
64 | // SECTION-START[Annotations] |
65 | // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> |
66 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) |
67 | // </editor-fold> |
68 | // SECTION-END |
69 | public final class JaxbIntrospectorFactory |
70 | { |
71 | // SECTION-START[JAXBIntrospector] |
72 | // SECTION-END |
73 | // SECTION-START[JaxbIntrospectorFactory] |
74 | |
75 | public JAXBIntrospector getObject() throws JAXBException |
76 | { |
77 | JAXBIntrospector introspector = null; |
78 | final StringBuilder packages = new StringBuilder(); |
79 | |
80 | for ( SchemaType s : this.getSchemas().getSchema() ) |
81 | { |
82 | if ( s.getOtherAttributes().containsKey( XML_SCHEMA_JAVA_CONTEXT_ID_ATTRIBUTE ) ) |
83 | { |
84 | packages.append( ':' ).append( s.getOtherAttributes().get( XML_SCHEMA_JAVA_CONTEXT_ID_ATTRIBUTE ) ); |
85 | } |
86 | } |
87 | |
88 | if ( packages.length() > 0 ) |
89 | { |
90 | final String ctx = packages.toString().substring( 1 ); |
91 | introspector = JAXBContext.newInstance( ctx ).createJAXBIntrospector(); |
92 | } |
93 | |
94 | return introspector; |
95 | } |
96 | |
97 | // SECTION-END |
98 | // SECTION-START[Constructors] |
99 | // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> |
100 | |
101 | /** Creates a new {@code JaxbIntrospectorFactory} instance. */ |
102 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) |
103 | public JaxbIntrospectorFactory() |
104 | { |
105 | // SECTION-START[Default Constructor] |
106 | super(); |
107 | // SECTION-END |
108 | } |
109 | // </editor-fold> |
110 | // SECTION-END |
111 | // SECTION-START[Dependencies] |
112 | // SECTION-END |
113 | // SECTION-START[Properties] |
114 | // <editor-fold defaultstate="collapsed" desc=" Generated Properties "> |
115 | |
116 | /** |
117 | * Gets the value of the {@code schemas} property. |
118 | * @return List of XML schemas ('schemas' element from XML namespace 'http://jomc.org/sdk/model). |
119 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
120 | */ |
121 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) |
122 | private org.jomc.sdk.model.SchemasType getSchemas() |
123 | { |
124 | final org.jomc.sdk.model.SchemasType _p = (org.jomc.sdk.model.SchemasType) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "schemas" ); |
125 | assert _p != null : "'schemas' property not found."; |
126 | return _p; |
127 | } |
128 | // </editor-fold> |
129 | // SECTION-END |
130 | // SECTION-START[Messages] |
131 | // SECTION-END |
132 | } |