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