本文整理汇总了Java中com.fasterxml.jackson.core.io.IOContext类的典型用法代码示例。如果您正苦于以下问题:Java IOContext类的具体用法?Java IOContext怎么用?Java IOContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOContext类属于com.fasterxml.jackson.core.io包,在下文中一共展示了IOContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParser
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Override
public JsonParser createParser(ObjectReadContext readCtxt,
String content) throws IOException
{
final int strLen = content.length();
// Actually, let's use this for medium-sized content, up to 64kB chunk (32kb char)
if ((_inputDecorator != null) || (strLen > 0x8000) || !canUseCharArrays()) {
// easier to just wrap in a Reader than extend InputDecorator; or, if content
// is too long for us to copy it over
return createParser(readCtxt, new StringReader(content));
}
IOContext ioCtxt = _createContext(content, true);
char[] buf = ioCtxt.allocTokenBuffer(strLen);
content.getChars(0, strLen, buf, 0);
return _createParser(readCtxt, ioCtxt, buf, 0, strLen, true);
}
示例2: UTF8StreamJsonParser
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
public UTF8StreamJsonParser(ObjectReadContext readCtxt, IOContext ctxt,
int features, InputStream in,
ByteQuadsCanonicalizer sym,
byte[] inputBuffer, int start, int end,
boolean bufferRecyclable)
{
super(readCtxt, ctxt, features);
_inputStream = in;
_symbols = sym;
_inputBuffer = inputBuffer;
_inputPtr = start;
_inputEnd = end;
_currInputRowStart = start;
// If we have offset, need to omit that from byte offset, so:
_currInputProcessed = -start;
_bufferRecyclable = bufferRecyclable;
}
示例3: JsonGeneratorImpl
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
public JsonGeneratorImpl(ObjectWriteContext writeCtxt, IOContext ctxt, int features,
SerializableString rvs, CharacterEscapes charEsc, PrettyPrinter pp)
{
super(writeCtxt, features);
_ioContext = ctxt;
if (Feature.ESCAPE_NON_ASCII.enabledIn(features)) {
// inlined `setHighestNonEscapedChar()`
_maximumNonEscapedChar = 127;
}
_cfgUnqNames = !Feature.QUOTE_FIELD_NAMES.enabledIn(features);
_rootValueSeparator = rvs;
_cfgPrettyPrinter = pp;
// 03-Oct-2017, tatu: Not clean (shouldn't call non-static methods from ctor),
// but for now best way to avoid code duplication
setCharacterEscapes(charEsc);
}
示例4: UTF8JsonGenerator
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
public UTF8JsonGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt,
int features, OutputStream out,
SerializableString rootValueSep, CharacterEscapes charEsc, PrettyPrinter pp)
{
super(writeCtxt, ioCtxt, features, rootValueSep, charEsc, pp);
_outputStream = out;
_bufferRecyclable = true;
_outputBuffer = ioCtxt.allocWriteEncodingBuffer();
_outputEnd = _outputBuffer.length;
// To be exact, each char can take up to 6 bytes when escaped (Unicode
// escape with backslash, 'u' and 4 hex digits); but to avoid fluctuation,
// we will actually round down to only do up to 1/8 number of chars
_outputMaxContiguous = _outputEnd >> 3;
_charBuffer = ioCtxt.allocConcatBuffer();
_charBufferLength = _charBuffer.length;
// By default we use this feature to determine additional quoting
if (isEnabled(Feature.ESCAPE_NON_ASCII)) {
setHighestNonEscapedChar(127);
}
}
示例5: ReaderBasedJsonParser
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
/**
* Method called when caller wants to provide input buffer directly,
* and it may or may not be recyclable use standard recycle context.
*/
public ReaderBasedJsonParser(ObjectReadContext readCtxt, IOContext ctxt,
int features, Reader r,
CharsToNameCanonicalizer st,
char[] inputBuffer, int start, int end,
boolean bufferRecyclable)
{
super(readCtxt, ctxt, features);
_reader = r;
_inputBuffer = inputBuffer;
_inputPtr = start;
_inputEnd = end;
_symbols = st;
_hashSeed = st.hashSeed();
_bufferRecyclable = bufferRecyclable;
}
示例6: test_decodeBase64ThrowsEOFException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void test_decodeBase64ThrowsEOFException() throws IOException {
IOContext ioContext = new IOContext(new BufferRecycler(), this, true);
byte[] byteArray = new byte[5];
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, (byte) 26, dataInputStream, byteQuadsCanonicalizer, 3);
try {
uTF8DataInputJsonParser._decodeBase64(null);
fail("Expecting exception: EOFException");
} catch (EOFException e) {
assertEquals(DataInputStream.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例7: test_skipStringThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void test_skipStringThrowsIOException() {
IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
byte[] byteArray = new byte[12];
byteArray[4] = (byte) (-10);
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 100, dataInputStream, null, 11);
try {
uTF8DataInputJsonParser._skipString();
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例8: testNextBooleanValueThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void testNextBooleanValueThrowsIOException() {
IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
byte[] byteArray = new byte[12];
byteArray[4] = (byte) (-10);
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 100, dataInputStream, null, 11);
try {
uTF8DataInputJsonParser.nextBooleanValue();
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例9: testNextTextValueThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void testNextTextValueThrowsIOException() {
IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
byte[] byteArray = new byte[20];
byteArray[0] = (byte) 47;
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 915, dataInputStream, null, (byte) 47);
try {
uTF8DataInputJsonParser.nextTextValue();
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例10: testNextFieldNameThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void testNextFieldNameThrowsIOException() {
IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
byte[] byteArray = new byte[20];
byteArray[0] = (byte) 47;
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 100, dataInputStream, null, -2624);
try {
uTF8DataInputJsonParser.nextFieldName();
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例11: test_handleAposThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@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());
}
}
示例12: test_parseAposNameThrowsEOFException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@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());
}
}
示例13: testParseEscapedNameThrowsArrayIndexOutOfBoundsException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void testParseEscapedNameThrowsArrayIndexOutOfBoundsException() throws IOException {
IOContext ioContext = new IOContext((BufferRecycler) null, null, false);
PipedOutputStream pipedOutputStream = new PipedOutputStream();
PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream, 131);
DataInputStream dataInputStream = new DataInputStream(pipedInputStream);
ByteQuadsCanonicalizer byteQuadsCanonicalizer = ByteQuadsCanonicalizer.createRoot();
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 131, dataInputStream, byteQuadsCanonicalizer, (byte) 57);
int[] intArray = new int[3];
try {
uTF8DataInputJsonParser.parseEscapedName(intArray, 56, (byte) 72, (byte) 127, (byte) 57);
fail("Expecting exception: ArrayIndexOutOfBoundsException");
} catch (ArrayIndexOutOfBoundsException e) {
assertEquals(UTF8DataInputJsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例14: test_parseNegNumberThrowsIOException
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@Test
public void test_parseNegNumberThrowsIOException() throws IOException {
IOContext ioContext = new IOContext(new BufferRecycler(), this, false);
byte[] byteArray = new byte[20];
byteArray[2] = (byte) 73;
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
UTF8DataInputJsonParser uTF8DataInputJsonParser = new UTF8DataInputJsonParser(ObjectReadContext.empty(),
ioContext, 100, dataInputStream, null, 3);
dataInputStream.readUnsignedShort();
try {
uTF8DataInputJsonParser._parseNegNumber();
fail("Expecting exception: IOException");
} catch (IOException e) {
assertEquals(JsonParser.class.getName(), e.getStackTrace()[0].getClassName());
}
}
示例15: test_parsePosNumber
import com.fasterxml.jackson.core.io.IOContext; //导入依赖的package包/类
@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());
}