Package org.apache.tika.sax

Examples of org.apache.tika.sax.WriteOutContentHandler$WriteLimitReachedException


public class SimpleBodyContentHandler extends ContentHandlerDecorator {

    private boolean _inBody;
   
    public SimpleBodyContentHandler() {
        this(new WriteOutContentHandler());
    }
View Full Code Here


        Metadata metadata = new Metadata();
        StringWriter writer = new StringWriter();
        parser.parse(
                new ByteArrayInputStream(text.getBytes("UTF-8")),
                new WriteOutContentHandler(writer),
                metadata,
                new ParseContext());
        String content = writer.toString();

        assertEquals("text/plain", metadata.get(Metadata.CONTENT_TYPE));
View Full Code Here

        try {
            Metadata metadata = new Metadata();
            metadata.set(Metadata.RESOURCE_NAME_KEY, tp.resourceStatedName);
            metadata.set(Metadata.CONTENT_TYPE, tp.statedType);
            StringWriter writer = new StringWriter();
            ContentHandler handler = new WriteOutContentHandler(writer);
            new AutoDetectParser().parse(input, handler, metadata);

            assertEquals("Bad content type: " + tp,
                    tp.realType, metadata.get(Metadata.CONTENT_TYPE));
View Full Code Here

    /**
     * Test {@link AppendableAdaptor#append(char)}.
     */
    public void testAppendChar() {
        StringWriter writer = new StringWriter();
        WriteOutContentHandler handler = new WriteOutContentHandler(writer);
        Appendable appendable = new AppendableAdaptor(handler);

        try {
            appendable.append('F').append('o').append('o');
        } catch (Throwable t) {
View Full Code Here

    /**
     * Test {@link AppendableAdaptor#append(String)}.
     */
    public void testAppendString() {
        StringWriter writer = new StringWriter();
        WriteOutContentHandler handler = new WriteOutContentHandler(writer);
        Appendable appendable = new AppendableAdaptor(handler);

        try {
            appendable.append("Foo").append("Bar");
        } catch (Throwable t) {
View Full Code Here

    /**
     * Test {@link AppendableAdaptor#append(String)}.
     */
    public void testAppendStringBuilder() {
        StringWriter writer = new StringWriter();
        WriteOutContentHandler handler = new WriteOutContentHandler(writer);
        Appendable appendable = new AppendableAdaptor(handler);

        try {
            appendable.append(new StringBuilder("Foo"))
                      .append(new StringBuilder("Bar"));
View Full Code Here

    /**
     * Test {@link AppendableAdaptor#append(String, int, int)}.
     */
    public void testAppendPortion() {
        StringWriter writer = new StringWriter();
        WriteOutContentHandler handler = new WriteOutContentHandler(writer);
        Appendable appendable = new AppendableAdaptor(handler);

        try {
            appendable.append("12345", 1, 3).append("ABC", 2, 3);
        } catch (Throwable t) {
View Full Code Here

            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected result
        }

        WriteOutContentHandler handler = new WriteOutContentHandler(new StringWriter());
        Appendable appendable = new AppendableAdaptor(handler);

        try {
            appendable.append("123", 2, 8);
            fail("End too big, expected IndexOutOfBoundsException");
View Full Code Here

        Metadata metadata = new Metadata();
        StringWriter writer = new StringWriter();
        parser.parse(
                new ByteArrayInputStream(text.getBytes("UTF-8")),
                new WriteOutContentHandler(writer),
                metadata);
        String content = writer.toString();

        assertEquals("text/plain", metadata.get(Metadata.CONTENT_TYPE));
        assertEquals("en", metadata.get(Metadata.CONTENT_LANGUAGE));
View Full Code Here

        Metadata metadata = new Metadata();
        StringWriter writer = new StringWriter();
        parser.parse(
                new ByteArrayInputStream(text.getBytes("UTF-8")),
                new WriteOutContentHandler(writer),
                metadata);
        String content = writer.toString();

        assertEquals("text/plain", metadata.get(Metadata.CONTENT_TYPE));
        assertEquals("UTF-8", metadata.get(Metadata.CONTENT_ENCODING));
View Full Code Here

TOP

Related Classes of org.apache.tika.sax.WriteOutContentHandler$WriteLimitReachedException

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.