当前位置: 首页>>代码示例>>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;未经允许,请勿转载。