当前位置: 首页>>代码示例>>Java>>正文


Java ParserAdapter类代码示例

本文整理汇总了Java中org.xml.sax.helpers.ParserAdapter的典型用法代码示例。如果您正苦于以下问题:Java ParserAdapter类的具体用法?Java ParserAdapter怎么用?Java ParserAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParserAdapter类属于org.xml.sax.helpers包,在下文中一共展示了ParserAdapter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ContextFilterImpl

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
/** Create a new SAX parser for processing the Context document.<p>
 * Note that in order for WHERE Geometries to be created a valid SAX
 * parser for GML must be implemented on the {@link ContextDocumentReader}
 * 
 * @param reader
 * @param inStream
 * @throws SAXException 
 * @throws ParserConfigurationException 
 */
public ContextFilterImpl(ContextDocumentReader reader) throws SAXException, ParserConfigurationException {
	parent = reader;
	entry = new EntryFilter(this);
	contentBuffer = new ContentBuffer( reader.getInputStream() );
	
	// Set-up the SAX parser and source
       SAXParser contextParser = SAXParserFactory.newInstance().newSAXParser();
       contextAdapter = new ParserAdapter(contextParser.getParser());
       contextAdapter.setContentHandler( this );
       inputSource = new InputSource( new BufferedReader(new InputStreamReader(contentBuffer)) );
       charEncoding = inputSource.getEncoding();
       
       // Geometry parser
       SAXParser gmlParser = SAXParserFactory.newInstance().newSAXParser();
       gmAdapter = new ParserAdapter(gmlParser.getParser());
       gmAdapter.setContentHandler( parent.getGeometryFilter() );
}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:27,代码来源:ContextFilterImpl.java

示例2: readBean

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
protected static void readBean(Object bean, Mapping mapping, ContentHandler contentHandler) {
    try {
        contentHandler.startDocument();

        // Initialize Castor
        ParserAdapter adapter = new ParserAdapter(XMLUtils.newSAXParser(XMLUtils.ParserConfiguration.PLAIN).getParser());
        adapter.setContentHandler(contentHandler);
        Marshaller marshaller = new Marshaller(adapter);
        marshaller.setMarshalAsDocument(false);
        marshaller.setMapping(mapping);

        // Serialize with Castor
        marshaller.marshal(bean);

        contentHandler.endDocument();

    } catch (Exception e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:21,代码来源:ScopeGenerator.java

示例3: ParserAdapterTest

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
/**
 * Initiate ParserAdapter.
 * @throws Exception If any errors occur.
 */
ParserAdapterTest() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    XMLReaderAdapter xmlReaderAdapter = new XMLReaderAdapter(xmlReader);
    parserAdapter = new ParserAdapter(xmlReaderAdapter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ParserAdapterTest.java

示例4: testParserAdapter

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "ParserAdapter",
    args = { }
)
public void testParserAdapter() {
    System.setProperty("org.xml.sax.parser",
            "tests.api.org.xml.sax.support.DoNothingParser");

    try {
        new ParserAdapter();
    } catch (SAXException e) {
        throw new RuntimeException("Unexpected exception", e);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:ParserAdapterTest.java

示例5: CapabilitiesReader

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
/** Construct a new instance of the reader and immediately parse the supplied inputStream.
 * 
 * Use {@link #getTypeNames()} to retrieve the output.
 * 
 * @param inputStream
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 */
public CapabilitiesReader(InputStream inputStream)  throws SAXException, IOException, ParserConfigurationException {
	InputStream dStream = decompressStream( inputStream );
	//InputSource source = new InputSource( dStream );
	
	// Set-up the SAX parser and source
       SAXParser contextParser = SAXParserFactory.newInstance().newSAXParser();
       contextAdapter = new ParserAdapter(contextParser.getParser());
       contextAdapter.setContentHandler( this );
       contextAdapter.parse( new InputSource( dStream ) );
}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:20,代码来源:CapabilitiesReader.java

示例6: parseXgmmlFile

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
public Result parseXgmmlFile(File file, List<String> ids, Direction dir, DataSource ds) {
	Result res = new Result();
	try {
		SAXParserFactory spf = SAXParserFactory.newInstance();
		SAXParser sp = spf.newSAXParser();
		ParserAdapter pa = new ParserAdapter(sp.getParser());
		CyTargetLinkerParser parser = new CyTargetLinkerParser(ids, dir, ds);
		pa.setContentHandler(parser);
		pa.parse(new InputSource(new FileInputStream(file)));
		
		res.setReginName(parser.getNetworkName());
		res.setDir(dir);
		if(parser.getNetworkAttr().containsKey("url")) {
			res.setReginUrl(parser.getNetworkAttr().get("url"));
		}
		if(parser.getNetworkAttr().containsKey("type")) {
			res.setReginType(parser.getNetworkAttr().get("type"));
		}
		
		res.getEdges().addAll(parser.getEdgeList());
		
		parser.clean();
	} catch(Exception e) {
		e.printStackTrace();
	}
	return res;
}
 
开发者ID:CyTargetLinker,项目名称:cytargetlinker,代码行数:28,代码来源:XgmmlParser.java

示例7: parse

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
public void parse(DefaultHandler handler) throws IOException, SAXException {
  SAXParser sp = createSaxParser();
  ParserAdapter pa = new ParserAdapter(sp.getParser());
  pa.setContentHandler(handler);
  pa.parse(new InputSource(reader));
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:7,代码来源:SaxEventSource.java

示例8: readBean

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
protected void readBean(PipelineContext context, Config config, Mapping mapping, XMLReceiver xmlReceiver) {
    ExternalContext externalContext = (ExternalContext) context.getAttribute(PipelineContext.EXTERNAL_CONTEXT);
    if (externalContext == null)
        throw new OXFException("Missing external context in BeanGenerator");
    try {
        xmlReceiver.startDocument();
        String rootElementName = "beans";
        xmlReceiver.startElement("", rootElementName, rootElementName, XMLUtils.EMPTY_ATTRIBUTES);

        // Initialize Castor
        ParserAdapter adapter = new ParserAdapter(XMLUtils.newSAXParser(XMLUtils.ParserConfiguration.PLAIN).getParser());
        adapter.setContentHandler(xmlReceiver);
        Marshaller marshaller = new Marshaller(adapter);
        marshaller.setMarshalAsDocument(false);
        marshaller.setMapping(mapping);

        for (Iterator atts = config.getAttributesIterator(); atts.hasNext();) {
            String attName = (String) atts.next();
            Object bean = getBean(attName, config.getSourcesIterator(), externalContext);
            if (bean == null) {
                // Create empty element
                if (logger.isInfoEnabled())
                    logger.info("Bean " + attName + " is null");
                xmlReceiver.startElement("", attName, attName, XMLUtils.EMPTY_ATTRIBUTES);
                xmlReceiver.endElement("", attName, attName);
            } else if (bean instanceof org.w3c.dom.Document) {
                // W3C Document: send as-is
                TransformerUtils.sourceToSAX(new DOMSource((org.w3c.dom.Document) bean), new EmbeddedDocumentXMLReceiver(xmlReceiver));
            } else {
                // Serialize with Castor
                if (logger.isDebugEnabled())
                    logger.debug("Serializing bean" + attName + " value=" + bean);
                marshaller.setRootElement(attName);
                marshaller.marshal(bean);
            }
        }
        xmlReceiver.endElement("", rootElementName, rootElementName);
        xmlReceiver.endDocument();

    } catch (Exception e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:44,代码来源:BeanGenerator.java

示例9: isSax1Parser

import org.xml.sax.helpers.ParserAdapter; //导入依赖的package包/类
/**
 * test that returns true if we are using a SAX1 parser.
 * @return true when a SAX1 parser is in use
 */
protected boolean isSax1Parser() {
    return (xmlReader instanceof ParserAdapter);
}
 
开发者ID:apache,项目名称:ant,代码行数:8,代码来源:XMLValidateTask.java


注:本文中的org.xml.sax.helpers.ParserAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。