public final int hashCode() { if (getNamespaceURI() != null) { return getNamespaceURI().hashCode(); } return 0; } }
public final int hashCode() { if (getNamespaceURI() != null) { return getNamespaceURI().hashCode(); } return 0; } }
public final int hashCode() { if ( getNamespaceURI() != null ) { return getNamespaceURI().hashCode(); } return 0; } }
/** * Equals override, equality is based soley on {@link #getNamespaceURI()}. */ public final boolean equals(Object obj) { if ( obj instanceof Configuration ) { Configuration other = (Configuration) obj; return Utilities.equals( getNamespaceURI(), other.getNamespaceURI() ); } return false; }
/** * Equals override, equality is based soley on {@link #getNamespaceURI()}. */ public final boolean equals(Object obj) { if (obj instanceof Configuration) { Configuration other = (Configuration) obj; return Utilities.equals(getNamespaceURI(), other.getNamespaceURI()); } return false; }
/** * Equals override, equality is based soley on {@link #getNamespaceURI()}. */ public final boolean equals(Object obj) { if (obj instanceof Configuration) { Configuration other = (Configuration) obj; return Utilities.equals(getNamespaceURI(), other.getNamespaceURI()); } return false; }
) { if ( configuration.getNamespaceURI().equals( namespaceURI ) ) { if ( this.schema != null ){ logger.finer("returning cached schema for " + namespaceURI); String msg = "Failed to create schema: " + configuration.getNamespaceURI(); logger.log( Level.WARNING, msg, t );
/** * Resolves <param>location<param> to a physical location. * <p> * Resolution is performed by stripping the filename off of <param>location</param> * and looking up a resource located in the same package as the class of the configuration. * </p> */ public String resolveSchemaLocation( XSDSchema schema, String uri, String location ) { if ( location == null ) { return null; } //if no namespace given, assume default for the current schema if ((( uri == null) || "".equals( uri)) && ( schema != null ) ) { uri = schema.getTargetNamespace(); } //namespace match? if ( configuration.getNamespaceURI().equals( uri )) { //strip off the filename and do a resource lookup String fileName = new File( location ).getName(); URL xsd = configuration.getClass().getResource( fileName ); if ( xsd != null ) { return xsd.toString(); } } return null; }
/** * Convenience method for creating an instance of the schema for this configuration. * * @return The schema for this configuration. */ public XSDSchema schema() { return getSchemaLocator().locateSchema( null, getNamespaceURI(), null, null ); }
Configuration conf = (Configuration) it.next(); if(LOGGER.isLoggable(Level.FINE)) LOGGER.fine("looking up schema for " + conf.getNamespaceURI()); LOGGER.fine("No schema locator for " + conf.getNamespaceURI()); continue; String namespaceURI = conf.getNamespaceURI(); String schemaLocation = null; try{
/** * Template method for creating the schema instance from the xml configuration. * <p> * Subclasses may with to override or exten this method. The default implementation * uses {@link Configuration#getSchemaFileURL()} and {@link Configuration#getSchemaLocationResolver()} * to parse the schema directly. * </p> * * @return The created schema. * * @throws Exception Any errors that occur while parsing the schema. */ protected XSDSchema createSchema() throws Exception { //add dependent location resolvers List resolvers = new ArrayList(); for ( Iterator d = configuration.allDependencies().iterator(); d.hasNext(); ) { Configuration dependency = (Configuration) d.next(); XSDSchemaLocationResolver resolver = dependency.getSchemaLocationResolver(); if ( resolver != null) { resolvers.add( resolver ); } } String location = configuration.getSchemaFileURL().toString(); if(logger.isLoggable(Level.FINE)) logger.fine("parsing schema " + configuration.getNamespaceURI() ); return Schemas.parse( location, null, resolvers ); } }
/** * Encodes an object, element name pair. * * @param object The object to encode. * @param element The name of the element to encode. * * @return The object encoded. * @throws Exception */ protected Document encode( Object object, QName element ) throws Exception { Configuration configuration = createConfiguration(); XSDSchema schema = configuration.getSchemaLocator().locateSchema( null, configuration.getNamespaceURI(), null, null ); Encoder encoder = new Encoder( configuration, schema ); ByteArrayOutputStream output = new ByteArrayOutputStream(); encoder.write( object, element, output ); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware( true ); return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( output.toByteArray() ) ); }
config.getNamespaceURI() + " " + config.getSchemaFileURL());
/** * Parses the built document. * <p> * This method should be called after building the entire document. * * </p> * @throws Exception */ protected Object parse() throws Exception { Element root = document.getDocumentElement(); if (root == null) { throw new IllegalStateException("Document has no root element"); } Configuration config = createConfiguration(); registerNamespaces(root); //default root.setAttribute("xsi:schemaLocation", config.getNamespaceURI() + " " + config.getSchemaFileURL()); DOMParser parser = new DOMParser(config, document); return parser.parse(); }
QName key = new QName(dependency.getNamespaceURI(), "schemaLocationResolver"); container.registerComponentInstance(key, resolver); QName key = new QName(dependency.getNamespaceURI(), "schemaLocator"); container.registerComponentInstance(key, locator);
/** * Parses the built document. * <p> * This method should be called after building the entire document. * * </p> * @throws Exception */ protected Object parse() throws Exception { Element root = document.getDocumentElement(); if ( root == null ) { throw new IllegalStateException( "Document has no root element" ); } Configuration config = createConfiguration(); registerNamespaces(root); //default root.setAttribute( "xsi:schemaLocation", config.getNamespaceURI() + " " + config.getSchemaFileURL() ); DOMParser parser = new DOMParser(config, document); return parser.parse(); }
QName key = new QName( dependency.getNamespaceURI(), "schemaLocationResolver" ); container.registerComponentInstance( key, resolver ); QName key = new QName( dependency.getNamespaceURI(), "schemaLocator" ); container.registerComponentInstance( key, locator );
if (XS.NAMESPACE.equals(dependency.getNamespaceURI())) { continue; schemaLocation.append(dependency.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(dependency.getSchemaFileURL());
if (XS.NAMESPACE.equals(dependency.getNamespaceURI())) { continue; schemaLocation.append(dependency.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(dependency.getSchemaFileURL());
if ( XS.NAMESPACE.equals( dependency.getNamespaceURI() ) ) continue; schemaLocation.append( dependency.getNamespaceURI() ); schemaLocation.append( " " ); schemaLocation.append( dependency.getSchemaFileURL() );