Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.DefaultHandler


        throws JAXBException {
        if (validateOutput && schema != null) {
            marshaller.setEventHandler(eventHandler);
            marshaller.setSchema(schema);
            if (validateBeforeWrite) {
                marshaller.marshal(obj, new DefaultHandler());
                marshaller.setSchema(null);
            }
        }
    }
View Full Code Here


        Parser parser = tika.getParser();
        Metadata metadata = new Metadata();
        InputStream stream = new FileInputStream(file);
        try {
            parser.parse(
                    stream, new DefaultHandler(), metadata, new ParseContext());
        } finally {
            stream.close();
        }
        assertEquals("Sample Word Document", metadata.get(TikaCoreProperties.TITLE));
    }
View Full Code Here

        Parser parser = tika.getParser();
        Metadata metadata = new Metadata();
        InputStream stream = new FileInputStream(file);
        try {
            parser.parse(
                    stream, new DefaultHandler(), metadata, new ParseContext());
        } finally {
            stream.close();
        }
        assertEquals("Simple Excel document", metadata.get(TikaCoreProperties.TITLE));
    }
View Full Code Here

        final StringWriter name = new StringWriter();
        ContentHandler body = new BodyContentHandler();
        Metadata metadata = new Metadata();
        InputStream stream = HtmlParserTest.class.getResourceAsStream(path);
        try {
            ContentHandler link = new DefaultHandler() {
                @Override
                public void startElement(
                        String u, String l, String n, Attributes a)
                        throws SAXException {
                    if ("a".equals(l)) {
View Full Code Here

            "<html><head><base href=\"" + base + "\"></head>"
            + "<body><a href=\"" + relative + "\">test</a></body></html>";
        final List<String> links = new ArrayList<String>();
        new HtmlParser().parse(
                new ByteArrayInputStream(test.getBytes("UTF-8")),
                new DefaultHandler() {
                    @Override
                    public void startElement(
                            String u, String l, String name, Attributes atts) {
                        if (name.equals("a") && atts.getValue("", "href") != null) {
                            links.add(atts.getValue("", "href"));
View Full Code Here

   * @return the metadata
   * @throws Exception
   */
  @POST
  public Response getMetadata(InputStream is) throws Exception {
    parser.parse(is, new DefaultHandler(), metadata);
    return Response.ok(metadata).build();
  }
View Full Code Here

    // use BAD request to indicate that we may not have had enough data to
    // process the request
    Status defaultErrorResponse = Status.BAD_REQUEST;
    try {
      parser.parse(is, new DefaultHandler(), metadata);
      // once we've parsed the document successfully, we should use NOT_FOUND
      // if we did not see the field
      defaultErrorResponse = Status.NOT_FOUND;
    } catch (Exception e) {
      logger.info("Failed to process field " + field, e);
View Full Code Here

    // use BAD request to indicate that we may not have had enough data to
    // process the request
    Status defaultErrorResponse = Status.BAD_REQUEST;
    try {
      parser.parse(is, new DefaultHandler(), metadata);
      // once we've parsed the document successfully, we should use NOT_FOUND
      // if we did not see the field
      defaultErrorResponse = Status.NOT_FOUND;
    } catch (Exception e) {
      logger.info("Failed to process field " + field, e);
View Full Code Here

    ByteArrayOutputStream text = new ByteArrayOutputStream();

    if (saveAll) {
      ch = new BodyContentHandler(new RichTextContentHandler(new OutputStreamWriter(text, "UTF-8")));
    } else {
      ch = new DefaultHandler();
    }

    ParseContext pc = new ParseContext();

    Map<String, byte[]> files = new HashMap<String, byte[]>();
View Full Code Here

        }
        String name = inputBuilder.toString();
        byte[] data = ("From: " + name + "\r\n\r\n").getBytes("US-ASCII");

        Parser parser = new RFC822Parser();
        ContentHandler handler = new DefaultHandler();
        Metadata metadata = new Metadata();
        ParseContext context = new ParseContext();

        try {
            parser.parse(
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.DefaultHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.