當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。