4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.6-b27-fcs
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk// Any modifications to this file will be lost upon recompilation of the source schema.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk// Generated on: 2012.06.11 at 10:33:54 AM PDT
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenkpackage com.sun.identity.federation.jaxb.entityconfig.impl.runtime;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Keeps the information about the grammar as a whole.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * This object is immutable and thread-safe.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenkpublic class GrammarInfoImpl implements GrammarInfo
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Map from {@link QName}s (root tag names) to {@link Class}es of the
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * content interface that should be instanciated.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Enclosing ObjectFactory class. Used to load resources.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Map from {@link Class}es that represent content interfaces
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * to {@link String}s that represent names of the corresponding
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * implementation classes.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * ClassLoader that should be used to load impl classes.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public GrammarInfoImpl( Map _rootTagMap, Map _defaultImplementationMap, Class _objectFactoryClass ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk this.defaultImplementationMap = _defaultImplementationMap;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // the assumption is that the content interfaces and their impls
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // are loaded from the same class loader.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk this.classLoader = objectFactoryClass.getClassLoader();
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * @return the name of the content interface that is registered with
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * the specified element name.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk private final Class lookupRootMap( String nsUri, String localName ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // note that the value of rootTagMap could be null.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk if(rootTagMap.containsKey(qn)) return (Class)rootTagMap.get(qn);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk if(rootTagMap.containsKey(qn)) return (Class)rootTagMap.get(qn);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public final Class getRootElement(String namespaceUri, String localName) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk Class intfCls = lookupRootMap(namespaceUri,localName);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public final UnmarshallingEventHandler createUnmarshaller(
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk String namespaceUri, String localName, UnmarshallingContext context ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk Class impl = getRootElement(namespaceUri,localName);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk return ((UnmarshallableObject)impl.newInstance()).createUnmarshaller(context);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk for (Iterator itr = rootTagMap.keySet().iterator(); itr.hasNext();) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk return (String[]) r.toArray(new String[r.size()]);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public final boolean recognize( String nsUri, String localName ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public final Class getDefaultImplementation( Class javaContentInterface ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // by caching the obtained Class objects.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk String name = (String)defaultImplementationMap.get(javaContentInterface);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Gets the MSV AGM which can be used to validate XML during
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public final com.sun.msv.grammar.Grammar getGrammar() throws JAXBException {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk InputStream is = objectFactoryClass.getResourceAsStream("bgm.ser");
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // unable to find bgm.ser
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk name = '/'+name.substring(0,idx+1).replace('.','/')+"bgm.ser";
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk // deserialize the bgm
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk ObjectInputStream ois = new ObjectInputStream( is );
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk com.sun.xml.bind.GrammarImpl g = (com.sun.xml.bind.GrammarImpl)ois.readObject();
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk g.connect(new com.sun.msv.grammar.Grammar[]{g}); // connect to itself
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk } catch( Exception e ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * @see com.sun.tools.xjc.runtime.GrammarInfo#castToXMLSerializable(java.lang.Object)
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public XMLSerializable castToXMLSerializable(Object o) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk if( o instanceof XMLSerializable ) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * @see com.sun.tools.xjc.runtime.GrammarInfo#castToValidatableObject(java.lang.Object)
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk public ValidatableObject castToValidatableObject(Object o) {
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk if( o instanceof ValidatableObject ) {