當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityResolver類代碼示例

本文整理匯總了Java中org.xml.sax.EntityResolver的典型用法代碼示例。如果您正苦於以下問題:Java EntityResolver類的具體用法?Java EntityResolver怎麽用?Java EntityResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityResolver類屬於org.xml.sax包,在下文中一共展示了EntityResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public void initialize(String pipelineURI, String uriResolverClassName, String entityResolverClassName) {
	try{
		if (uriResolverClassName != null && uriResolverClassName.trim().length()!=0)
			theURIResolver = (URIResolver) getClass().getClassLoader().loadClass(uriResolverClassName).newInstance();
		else
			theURIResolver = null;
		if (entityResolverClassName != null && entityResolverClassName.trim().length()!=0)
			theEntityResolver = (EntityResolver) getClass().getClassLoader().loadClass(entityResolverClassName).newInstance();
		else
			theEntityResolver = null;
		if (pipelineURI != null && pipelineURI.trim().length()!=0)
			thePipelineURI = pipelineURI;
		else
			thePipelineURI = null;
	}
	catch (Throwable t){
		compilationErrors.clear();
		compilationErrors.add(new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_ERROR, "Error initializing adapter: "+t.getMessage()));
		dumpStackTrace(t);
	}
}
 
開發者ID:xml-project,項目名稱:support-for-xmleditor,代碼行數:22,代碼來源:Adapter.java

示例2: validateAgainstAUDTDs

import org.xml.sax.EntityResolver; //導入依賴的package包/類
static void validateAgainstAUDTDs(InputSource input, final Path updaterJar, final Task task) throws IOException, SAXException {
    XMLUtil.parse(input, true, false, XMLUtil.rethrowHandler(), new EntityResolver() {
        ClassLoader loader = new AntClassLoader(task.getProject(), updaterJar);
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            String remote = "http://www.netbeans.org/dtds/";
            if (systemId.startsWith(remote)) {
                String rsrc = "org/netbeans/updater/resources/" + systemId.substring(remote.length());
                URL u = loader.getResource(rsrc);
                if (u != null) {
                    return new InputSource(u.toString());
                } else {
                    task.log(rsrc + " not found in " + updaterJar, Project.MSG_WARN);
                }
            }
            return null;
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:MakeNBM.java

示例3: getEntityResolver

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/**
 * Return the current entity resolver.
 *
 * @return The current entity resolver, or null if none
 *         has been registered.
 * @see #setEntityResolver
 */
public EntityResolver getEntityResolver() {

    EntityResolver entityResolver = null;
    try {
        XMLEntityResolver xmlEntityResolver =
            (XMLEntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER);
        if (xmlEntityResolver != null) {
            if (xmlEntityResolver instanceof EntityResolverWrapper) {
                entityResolver =
                    ((EntityResolverWrapper) xmlEntityResolver).getEntityResolver();
            }
            else if (xmlEntityResolver instanceof EntityResolver2Wrapper) {
                entityResolver =
                    ((EntityResolver2Wrapper) xmlEntityResolver).getEntityResolver();
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }
    return entityResolver;

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:AbstractSAXParser.java

示例4: parse

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public void parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver)

            throws SAXException, IOException {
        String systemId = source.getSystemId();
        Document dom = forest.get(systemId);

        if (dom == null) {
            // if no DOM tree is built for it,
            // let the fall back parser parse the original document.
            //
            // for example, XSOM parses datatypes.xsd (XML Schema part 2)
            // but this will never be built into the forest.
            fallbackParser.parse(source, handler, errorHandler, entityResolver);
            return;
        }

        scanner.scan(dom, handler);

    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:DOMForestParser.java

示例5: createEntityResolver

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/**
 * Similar to {@link #createNamespaceHandlerResolver(BundleContext, String, ClassLoader)} , this method creates
 * a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
 * service provided by the Spring DM extender.
 * 
 * @param bundleContext the OSGi context of which the resolver should be aware of
 * @param filter OSGi service filter
 * @param bundleClassLoader classloader for creating the OSGi namespace resolver proxy
 * @return a OSGi aware entity resolver
 */
private EntityResolver createEntityResolver(BundleContext bundleContext, String filter,
		ClassLoader bundleClassLoader) {
	Assert.notNull(bundleContext, "bundleContext is required");
	// create local namespace resolver
	EntityResolver localEntityResolver = new DelegatingEntityResolver(bundleClassLoader);
	// hook in OSGi namespace resolver
	EntityResolver osgiServiceEntityResolver = lookupEntityResolver(bundleContext, filter, localEntityResolver);

	ChainedEntityResolver delegate = new ChainedEntityResolver();
	delegate.addEntityResolver(localEntityResolver, "LocalEntityResolver for bundle "
			+ OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle()));

	// hook in OSGi namespace resolver
	delegate.addEntityResolver(osgiServiceEntityResolver, "OSGi Service resolver");

	return delegate;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:28,代碼來源:OsgiBundleXmlApplicationContext.java

示例6: createXSOMParser

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ModelLoader.java

示例7: parse

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public void parse(
    InputSource source,
    ContentHandler contentHandler,
    ErrorHandler errorHandler,
    EntityResolver entityResolver )
    throws SAXException, IOException {

    String systemId = source.getSystemId();
    Document dom = forest.get(systemId);

    if(dom==null) {
        // if no DOM tree is built for it,
        // let the fall back parser parse the original document.
        //
        // for example, XSOM parses datatypes.xsd (XML Schema part 2)
        // but this will never be built into the forest.
        fallbackParser.parse( source, contentHandler, errorHandler, entityResolver );
        return;
    }

    scanner.scan( dom, contentHandler );
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DOMForestParser.java

示例8: createRelativePathResolver

import org.xml.sax.EntityResolver; //導入依賴的package包/類
protected static EntityResolver createRelativePathResolver(final String workingDirectory) {
    return new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            if (systemId != null && systemId.startsWith("file:/")) {
                URI workingDirectoryURI = new File(workingDirectory).toURI();
                URI workingFile;
                try {
                    // Construction new File(new URI(String)).toURI() is used to be sure URI has correct representation without redundant '/'
                    workingFile = convertToNewWorkingDirectory(currentJavaWorkingDirectory, workingDirectoryURI, new File(new URI(systemId)).toURI());
                    return new InputSource(workingFile.toString());
                } catch (URISyntaxException ex) {
                    //Should not get here
                }
            }
            return null;
        }
    };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:TransformInputOutput.java

示例9: Load

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public static Document Load(URL url, EntityResolver er) {
//		try {
//			InputStream is = url.openStream();
//			BufferedInputStream buffer = new BufferedInputStream(is); 
//			return Load(buffer,er);
//		} catch (IOException e) {
//			throw new ProgrammingException("XMLHELPER","Error accessing to '"+url.toExternalForm()+"'",e);
//		}
		return null;
	}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:11,代碼來源:XmlHelper.java

示例10: getSchemaSource

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/**
     * convert an array of {@link InputSource InputSource} into an
     * array of {@link Source Source}
     *
     * @param schemas array of {@link InputSource InputSource}
     * @return array of {@link Source Source}
     */
    private static Source[] getSchemaSource(InputSource[] schemas, EntityResolver entityResolver) throws SAXException {
        SAXSource[] sources = new SAXSource[schemas.length];
        for (int i = 0; i < schemas.length; i++) {
            sources[i] = new SAXSource(schemas[i]);
//            sources[i].getXMLReader().setEntityResolver(entityResolver);
        }
        return sources;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:SchemaConstraintChecker.java

示例11: getXMLParser

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/** Returns a XML parser. The same parser can be returned assuming that config files
 * are parser sequentially.
 *
 * @return XML parser with set content handler, errror handler
 * and entity resolver.
 */
public XMLReader getXMLParser (DefaultHandler h) throws SAXException {
    if (parser == null) {
        // get non validating, not namespace aware parser
        parser = XMLUtil.createXMLReader();
        parser.setEntityResolver(new EntityResolver () {
            /** Implementation of entity resolver. Points to the local DTD
             * for our public ID */
            public InputSource resolveEntity (String publicId, String systemId)
            throws SAXException {
                if (ModeParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_1_1.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_1_2.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_1.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_2.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_3.equals(publicId)
                || GroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCGroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_1.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_2.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_1_1.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_2_1.equals(publicId)) {
                    InputStream is = new ByteArrayInputStream(new byte[0]);
                    return new InputSource(is);
                }
                return null; // i.e. follow advice of systemID
            }
        });
    }
    parser.setContentHandler(h);
    parser.setErrorHandler(h);
    return parser;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:PersistenceManager.java

示例12: createCatalogResolver

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/**
 * Instantiate catalog resolver using new catalog API (javax.xml.catalog.*)
 * added in JDK9. Usage of new API removes dependency on internal API
 * (com.sun.org.apache.xml.internal) for modular runtime.
 */
private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
    // Prepare array of catalog URIs
    URI[] uris = urls.stream()
                         .map(u -> URI.create(u.toExternalForm()))
                         .toArray(URI[]::new);

    //Create CatalogResolver with new JDK9+ API
    return (EntityResolver) CatalogManager.catalogResolver(CATALOG_FEATURES, uris);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XmlCatalogUtil.java

示例13: setEntityResolver

import org.xml.sax.EntityResolver; //導入依賴的package包/類
/**
 * Sets the resolver used to resolve external entities. The EntityResolver
 * interface supports resolution of public and system identifiers.
 *
 * @param resolver The new entity resolver. Passing a null value will
 *                 uninstall the currently installed resolver.
 */
public void setEntityResolver(EntityResolver resolver) {

    try {
        XMLEntityResolver xer = (XMLEntityResolver) fConfiguration.getProperty(ENTITY_RESOLVER);
        if (fUseEntityResolver2 && resolver instanceof EntityResolver2) {
            if (xer instanceof EntityResolver2Wrapper) {
                EntityResolver2Wrapper er2w = (EntityResolver2Wrapper) xer;
                er2w.setEntityResolver((EntityResolver2) resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolver2Wrapper((EntityResolver2) resolver));
            }
        }
        else {
            if (xer instanceof EntityResolverWrapper) {
                EntityResolverWrapper erw = (EntityResolverWrapper) xer;
                erw.setEntityResolver(resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolverWrapper(resolver));
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:DOMParser.java

示例14: assertValidate

import org.xml.sax.EntityResolver; //導入依賴的package包/類
private static void assertValidate(String xml) throws Exception {
    XMLUtil.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))), false, true, XMLUtil.defaultErrorHandler(), new EntityResolver() {
        public @Override InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return new InputSource(new ByteArrayInputStream(new byte[0]));
            /* XXX when #192595 is implemented, can move DTDs here from core.windows, set validate=true above, and use:
            InputSource r = EntityCatalog.getDefault().resolveEntity(publicId, systemId);
            if (r != null) {
                return r;
            } else {
                throw new IOException("network connection to " + systemId);
            }
             */
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:TopComponentProcessorTest.java

示例15: create

import org.xml.sax.EntityResolver; //導入依賴的package包/類
public static EntityResolver create(String configuration) {
	switch (configuration) {
		case "blank":
			return blank();
		case "simple":
			return withDefaultSimpleCatalogManager();
		case "simpleConfigured":
			return withConfiguredSimpleCatalogManager();
		case "":
		case "asPlugin":
			return asInPlugin();
		default:
			throw new IllegalArgumentException("Unknown configuration: " + configuration);
	}
}
 
開發者ID:CodeFX-org,項目名稱:java-9-wtf,代碼行數:16,代碼來源:EntityResolverFactory.java


注:本文中的org.xml.sax.EntityResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。