Search in sources :

Example 1 with ByteQuadsCanonicalizer

use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.

the class JsonFactory method _createParser.

@Override
protected JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, DataInput input) throws IOException {
    // Also: while we can't do full bootstrapping (due to read-ahead limitations), should
    // at least handle possible UTF-8 BOM
    int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input);
    ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures);
    return new UTF8DataInputJsonParser(readCtxt, ioCtxt, readCtxt.getParserFeatures(_parserFeatures), input, can, firstByte);
}
Also used : ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)

Example 2 with ByteQuadsCanonicalizer

use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.

the class JsonFactory method createNonBlockingByteArrayParser.

/*
    /**********************************************************************
    /* Parser factories, non-blocking (async) sources
    /**********************************************************************
     */
@Override
public JsonParser createNonBlockingByteArrayParser(ObjectReadContext readCtxt) throws IOException {
    IOContext ioCtxt = _createContext(null, false);
    ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures);
    return new NonBlockingJsonParser(readCtxt, ioCtxt, readCtxt.getParserFeatures(_parserFeatures), can);
}
Also used : NonBlockingJsonParser(com.fasterxml.jackson.core.json.async.NonBlockingJsonParser) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)

Example 3 with ByteQuadsCanonicalizer

use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_handleAposThrowsIOException.

@Test
public void test_handleAposThrowsIOException() {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[7];
    byteArray[0] = (byte) (-80);
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 3, dataInputStream, byteQuadsCanonicalizer, 1);
    try {
        uTF8DataInputJsonParser._handleApos();
        fail("Expecting exception: IOException");
    } catch (IOException e) {
        assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 4 with ByteQuadsCanonicalizer

use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_parseAposNameThrowsEOFException.

@Test
public void test_parseAposNameThrowsEOFException() throws IOException {
    IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
    byte[] byteArray = new byte[17];
    byteArray[4] = (byte) 43;
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 42, dataInputStream, byteQuadsCanonicalizer, 0);
    try {
        uTF8DataInputJsonParser._parseAposName();
        fail("Expecting exception: EOFException");
    } catch (EOFException e) {
        assertEquals(DataInputStream.class.getName(), e.getStackTrace()[0].getClassName());
    }
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Example 5 with ByteQuadsCanonicalizer

use of com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer in project jackson-core by FasterXML.

the class UTF8DataInputJsonParserTest method test_parsePosNumber.

@Test
public void test_parsePosNumber() throws IOException {
    byte[] byteArray = new byte[2];
    byteArray[0] = (byte) 51;
    byteArray[1] = (byte) 22;
    IOContext ioContext = new IOContext(new BufferRecycler(), byteArray, false);
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(), ioContext, 1568, dataInputStream, byteQuadsCanonicalizer, 13);
    JsonToken jsonToken = uTF8DataInputJsonParser._parsePosNumber(7);
    assertEquals(7, jsonToken.id());
    assertNull(jsonToken.asString());
}
Also used : BufferRecycler(com.fasterxml.jackson.core.util.BufferRecycler) IOContext(com.fasterxml.jackson.core.io.IOContext) ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer) JsonToken(com.fasterxml.jackson.core.JsonToken) BaseTest(com.fasterxml.jackson.core.BaseTest) Test(org.junit.Test)

Aggregations

ByteQuadsCanonicalizer (com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)13 BaseTest (com.fasterxml.jackson.core.BaseTest)8 IOContext (com.fasterxml.jackson.core.io.IOContext)8 Test (org.junit.Test)8 BufferRecycler (com.fasterxml.jackson.core.util.BufferRecycler)7 JsonFactory (com.fasterxml.jackson.core.json.JsonFactory)2 NonBlockingJsonParserBase (com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase)2 AsyncReaderWrapper (com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)2 JsonToken (com.fasterxml.jackson.core.JsonToken)1 NonBlockingJsonParser (com.fasterxml.jackson.core.json.async.NonBlockingJsonParser)1 ByteArrayBuilder (com.fasterxml.jackson.core.util.ByteArrayBuilder)1