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


Java ContentHandler类代码示例

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


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

示例1: setResult

import org.xml.sax.ContentHandler; //导入依赖的package包/类
@Override
public void setResult(Result result) throws IllegalArgumentException
{
	SAXResult saxResult = toSAXResult(result);

	ContentHandler handler = saxResult.getHandler();
	this.nextContentHandler = handler;
	if (handler instanceof LexicalHandler)
	{
		this.nextLexicalHandler = (LexicalHandler) handler;
	}
	if (handler instanceof DTDHandler)
	{
		this.nextDtdHandler = (DTDHandler) handler;
	}

}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:18,代码来源:AbstractSAXFilter.java

示例2: extractText

import org.xml.sax.ContentHandler; //导入依赖的package包/类
@Override
public void extractText(String mimeType, InputStream input, StringBuilder outputText, int maxSize)
	throws IOException
{
	WriteOutContentHandler wrapped = new WriteOutContentHandler(maxSize);
	ContentHandler handler = new BodyContentHandler(wrapped);
	try
	{
		Metadata meta = new Metadata();
		Parser parser = new AutoDetectParser(new TikaConfig(getClass().getClassLoader()));
		parser.parse(input, handler, meta, new ParseContext());

		appendText(handler, outputText, maxSize);
	}
	catch( Exception t )
	{
		if( wrapped.isWriteLimitReached(t) )
		{
			// keep going
			LOGGER.debug("PDF size limit reached.  Indexing truncated text");
			appendText(handler, outputText, maxSize);
			return;
		}
		throw Throwables.propagate(t);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:PdfExtracter.java

示例3: parse

import org.xml.sax.ContentHandler; //导入依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:DOMForestParser.java

示例4: outputTableMetaData

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Serialise the meta data for a table.
 *
 * @param table The meta data to serialise.
 * @param contentHandler Content handler to receive the meta data xml.
 * @throws SAXException Propagates from SAX API calls.
 */
private void outputTableMetaData(Table table, ContentHandler contentHandler) throws SAXException {
  AttributesImpl tableAttributes = new AttributesImpl();
  tableAttributes.addAttribute(XmlDataSetNode.URI, XmlDataSetNode.NAME_ATTRIBUTE, XmlDataSetNode.NAME_ATTRIBUTE,
    XmlDataSetNode.STRING_TYPE, table.getName());
  contentHandler.startElement(XmlDataSetNode.URI, XmlDataSetNode.METADATA_NODE, XmlDataSetNode.METADATA_NODE, tableAttributes);

  for (Column column : table.columns()) {
    emptyElement(contentHandler, XmlDataSetNode.COLUMN_NODE, buildColumnAttributes(column));
  }

  // we need to sort the indexes by name to ensure consistency, since indexes don't have an explicit "sequence" in databases.
  List<Index> indexes = new ArrayList<>(table.indexes());
  Collections.sort(indexes, new Comparator<Index>() {
    @Override
    public int compare(Index o1, Index o2) {
      return o1.getName().compareTo(o2.getName());
    }
  });

  for (Index index : indexes) {
    emptyElement(contentHandler, XmlDataSetNode.INDEX_NODE, buildIndexAttributes(index));
  }

  contentHandler.endElement(XmlDataSetNode.URI, XmlDataSetNode.METADATA_NODE, XmlDataSetNode.METADATA_NODE);
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:33,代码来源:XmlDataSetConsumer.java

示例5: executeCharsToContentHandler

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Execute an expression in the XPath runtime context, and return the
 * result of the expression.
 *
 *
 * @param xctxt The XPath runtime context.
 *
 * @return The result of the expression in the form of a <code>XObject</code>.
 *
 * @throws javax.xml.transform.TransformerException if a runtime exception
 *         occurs.
 */
public void executeCharsToContentHandler(XPathContext xctxt,
                                            ContentHandler handler)
  throws javax.xml.transform.TransformerException,
         org.xml.sax.SAXException
{
  if(Arg0IsNodesetExpr())
  {
    int node = getArg0AsNode(xctxt);
    if(DTM.NULL != node)
    {
      DTM dtm = xctxt.getDTM(node);
      dtm.dispatchCharactersEvents(node, handler, true);
    }
  }
  else
  {
    XObject obj = execute(xctxt);
    obj.dispatchCharactersEvents(handler);
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:FuncNormalizeSpace.java

示例6: testEndElementContentHandlerStringString

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Test method for {@link XmlGeneratorUtils#endElement(ContentHandler, String, String)}.
 */
@Test
public void testEndElementContentHandlerStringString() throws SAXException {
  final AtomicReference<String> uriRef = new AtomicReference<String>();
  final AtomicReference<String> localnameRef = new AtomicReference<String>();
  final AtomicReference<String> qNameRef = new AtomicReference<String>();

  final ContentHandler contentHandler = new MockContentHandler() {
    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
      uriRef.set(uri);
      localnameRef.set(localName);
      qNameRef.set(qName);
    }
  };

  XmlGeneratorUtils.endElement(contentHandler, "prefix", "localname");
  assertEquals("localname", localnameRef.get());
  assertEquals("prefix:localname", qNameRef.get());
  assertEquals(NULL_NS_URI, uriRef.get());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:XmlGeneratorUtilsJUnitTest.java

示例7: processSheet

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Parses and shows the content of one sheet using the specified styles and
 * shared-strings tables.
 *
 * @param styles
 * @param strings
 * @param sheetInputStream
 */
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler,
                         InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException {
    DataFormatter formatter = new DataFormatter();
    InputSource sheetSource = new InputSource(sheetInputStream);
    try {
        XMLReader sheetParser = SAXHelper.newXMLReader();
        ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
        sheetParser.setContentHandler(handler);
        sheetParser.parse(sheetSource);
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:22,代码来源:XLSX2CSV.java

示例8: testContentHandler

import org.xml.sax.ContentHandler; //导入依赖的package包/类
@Test
public void testContentHandler() {
    ValidatorHandler validatorHandler = getValidatorHandler();
    assertNull(validatorHandler.getContentHandler(), "When ValidatorHandler is created, initially ContentHandler should not be set.");

    ContentHandler handler = new DefaultHandler();
    validatorHandler.setContentHandler(handler);
    assertSame(validatorHandler.getContentHandler(), handler);

    validatorHandler.setContentHandler(null);
    assertNull(validatorHandler.getContentHandler());

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ValidatorHandlerTest.java

示例9: createContentHandler

import org.xml.sax.ContentHandler; //导入依赖的package包/类
public final ContentHandler createContentHandler() {
    final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    return new ASMContentHandler(cw) {
        @Override
        public void endDocument() throws SAXException {
            try {
                os.write(cw.toByteArray());
            } catch (IOException e) {
                throw new SAXException(e);
            }
        }
    };
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:14,代码来源:Processor.java

示例10: contentHandler01

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Verifies parserAdapter.getContentHandler()
 */
@Test
public void contentHandler01() {
    ContentHandler contentHandler = new XMLFilterImpl();
    parserAdapter.setContentHandler(contentHandler);
    assertNotNull(parserAdapter.getContentHandler());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ParserAdapterTest.java

示例11: setContentHandler

import org.xml.sax.ContentHandler; //导入依赖的package包/类
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler)handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DOM2SAX.java

示例12: processEntry

import org.xml.sax.ContentHandler; //导入依赖的package包/类
private void processEntry(final ZipInputStream zis, final ZipEntry ze,
        final ContentHandlerFactory handlerFactory) {
    ContentHandler handler = handlerFactory.createContentHandler();
    try {

        // if (CODE2ASM.equals(command)) { // read bytecode and process it
        // // with TraceClassVisitor
        // ClassReader cr = new ClassReader(readEntry(zis, ze));
        // cr.accept(new TraceClassVisitor(null, new PrintWriter(os)),
        // false);
        // }

        boolean singleInputDocument = inRepresentation == SINGLE_XML;
        if (inRepresentation == BYTECODE) { // read bytecode and process it
            // with handler
            ClassReader cr = new ClassReader(readEntry(zis, ze));
            cr.accept(new SAXClassAdapter(handler, singleInputDocument), 0);

        } else { // read XML and process it with handler
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(handler);
            reader.parse(new InputSource(
                    singleInputDocument ? (InputStream) new ProtectedInputStream(
                            zis) : new ByteArrayInputStream(readEntry(zis,
                            ze))));

        }
    } catch (Exception ex) {
        update(ze.getName(), 0);
        update(ex, 0);
    }
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:33,代码来源:Processor.java

示例13: ViewXMLExporter

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * Construct
 * 
 * @param namespaceService  namespace service
 * @param nodeService  node service
 * @param contentHandler  content handler
 */
ViewXMLExporter(NamespaceService namespaceService, NodeService nodeService, SearchService searchService,
        DictionaryService dictionaryService, PermissionService permissionService, ContentHandler contentHandler)
{
    this.namespaceService = namespaceService;
    this.nodeService = nodeService;
    this.searchService = searchService;
    this.dictionaryService = dictionaryService;
    this.permissionService = permissionService;
    this.contentHandler = contentHandler;
    
    VIEW_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, namespaceService);
    VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VALUE_LOCALNAME, namespaceService);
    VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VALUES_LOCALNAME, namespaceService);
    CHILDNAME_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, CHILDNAME_LOCALNAME, namespaceService);
    ASPECTS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ASPECTS_LOCALNAME, namespaceService);
    PROPERTIES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PROPERTIES_LOCALNAME, namespaceService);
    ASSOCIATIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ASSOCIATIONS_LOCALNAME, namespaceService);
    DATATYPE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, DATATYPE_LOCALNAME, namespaceService);
    ISNULL_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ISNULL_LOCALNAME, namespaceService);
    METADATA_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, METADATA_LOCALNAME, namespaceService);
    EXPORTEDBY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTEDBY_LOCALNAME, namespaceService);
    EXPORTEDDATE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTEDDATE_LOCALNAME, namespaceService);
    EXPORTERVERSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTERVERSION_LOCALNAME, namespaceService);
    EXPORTOF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, namespaceService);
    ACL_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACL_LOCALNAME, namespaceService);
    ACE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACE_LOCALNAME, namespaceService);
    ACCESS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACCESS_LOCALNAME, namespaceService);
    AUTHORITY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, AUTHORITY_LOCALNAME, namespaceService);
    PERMISSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PERMISSION_LOCALNAME, namespaceService);
    INHERITPERMISSIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, INHERITPERMISSIONS_LOCALNAME, namespaceService);
    REFERENCE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, REFERENCE_LOCALNAME, namespaceService);
    PATHREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PATHREF_LOCALNAME, namespaceService);
    NODEREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, NODEREF_LOCALNAME, namespaceService);
    LOCALE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, LOCALE_LOCALNAME, namespaceService);
    MLVALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, MLVALUE_LOCALNAME, namespaceService);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:45,代码来源:ViewXMLExporter.java

示例14: marshal

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * @since 2.0.2
 */
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,contentHandler);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Bridge.java

示例15: parse

import org.xml.sax.ContentHandler; //导入依赖的package包/类
/**
 * @deprecated This method will be removed in Apache Tika 1.0.
 */
public void parse(InputStream stream,
      ContentHandler handler, Metadata metadata)
      throws IOException, SAXException, TikaException 
{
   parse(stream, handler, metadata, new ParseContext());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:TikaOfficeDetectParser.java


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