Java 类com.fasterxml.jackson.core.json.JsonWriteContext 实例源码

项目:vertx-web    文件:JsonCodec.java   
@Override
public void serialize(String str, JsonGenerator gen, SerializerProvider provider) throws IOException {
  int status = ((JsonWriteContext) gen.getOutputContext()).writeValue();
  switch (status) {
    case JsonWriteContext.STATUS_OK_AFTER_COLON:
      gen.writeRaw(':');
      break;
    case JsonWriteContext.STATUS_OK_AFTER_COMMA:
      gen.writeRaw(',');
      break;
    case JsonWriteContext.STATUS_EXPECT_NAME:
      throw new JsonGenerationException("Can not write string value here");
  }
  gen.writeRaw('"');
  for (char c : str.toCharArray()) {
    if (c >= 0x80) writeUnicodeEscape(gen, c); // use generic escaping for all non US-ASCII characters
    else {
      // use escape table for first 128 characters
      int code = (c < ESCAPE_CODES.length ? ESCAPE_CODES[c] : 0);
      if (code == 0) gen.writeRaw(c); // no escaping
      else if (code == -1) writeUnicodeEscape(gen, c); // generic escaping
      else writeShortEscape(gen, (char) code); // short escaping (\n \t ...)
    }
  }
  gen.writeRaw('"');
}
项目:GitHub    文件:GeneratorBase.java   
protected GeneratorBase(ObjectWriteContext writeCtxt, int features) {
    super();
    _objectWriteContext = writeCtxt;
    _features = features;
    DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
            ? DupDetector.rootDetector(this) : null;
    _outputContext = JsonWriteContext.createRootContext(dups);
    _cfgNumbersAsStrings = Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(features);
}
项目:GitHub    文件:GeneratorBase.java   
protected GeneratorBase(ObjectWriteContext writeCtxt, int features, JsonWriteContext ctxt) {
    super();
    _objectWriteContext = writeCtxt;
    _features = features;
    _outputContext = ctxt;
    _cfgNumbersAsStrings = Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(features);
}
项目:QuizUpWinner    文件:TokenBuffer.java   
public TokenBuffer(ObjectCodec paramObjectCodec)
{
  this._objectCodec = paramObjectCodec;
  this._generatorFeatures = DEFAULT_PARSER_FEATURES;
  this._writeContext = JsonWriteContext.createRootContext();
  Segment localSegment = new Segment();
  this._last = localSegment;
  this._first = localSegment;
  this._appendOffset = 0;
}
项目:QuizUpWinner    文件:TokenBuffer.java   
public final void writeEndArray()
{
  _append(JsonToken.END_ARRAY);
  JsonWriteContext localJsonWriteContext = this._writeContext.getParent();
  if (localJsonWriteContext != null)
    this._writeContext = localJsonWriteContext;
}
项目:QuizUpWinner    文件:TokenBuffer.java   
public final void writeEndObject()
{
  _append(JsonToken.END_OBJECT);
  JsonWriteContext localJsonWriteContext = this._writeContext.getParent();
  if (localJsonWriteContext != null)
    this._writeContext = localJsonWriteContext;
}
项目:QuizUpWinner    文件:GeneratorBase.java   
public GeneratorBase(int paramInt, ObjectCodec paramObjectCodec)
{
  this._features = paramInt;
  this._writeContext = JsonWriteContext.createRootContext();
  this._objectCodec = paramObjectCodec;
  this._cfgNumbersAsStrings = isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);
}
项目:jackson-dataformat-msgpack    文件:MessagePackGenerator.java   
@Override
protected void _verifyValueWrite(String typeMsg) throws IOException, JsonGenerationException {
    int status = _writeContext.writeValue();
    if (status == JsonWriteContext.STATUS_EXPECT_NAME) {
        _reportError("Can not "+typeMsg+", expecting field name");
    }
}
项目:Beam    文件:SmileGenerator.java   
@Override
public final void writeFieldName(String name)  throws IOException, JsonGenerationException
{
    if (_writeContext.writeFieldName(name) == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }
    _writeFieldName(name);
}
项目:Beam    文件:SmileGenerator.java   
@Override
public final void writeFieldName(SerializableString name)
    throws IOException, JsonGenerationException
{
    // Object is a value, need to verify it's allowed
    if (_writeContext.writeFieldName(name.getValue()) == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }
    _writeFieldName(name);
}
项目:Beam    文件:SmileGenerator.java   
@Override
public final void writeStringField(String fieldName, String value)
    throws IOException, JsonGenerationException
{
    if (_writeContext.writeFieldName(fieldName) == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }
    _writeFieldName(fieldName);
    writeString(value);
}
项目:Beam    文件:SmileGenerator.java   
@Override
protected final void _verifyValueWrite(String typeMsg)
    throws IOException, JsonGenerationException
{
    int status = _writeContext.writeValue();
    if (status == JsonWriteContext.STATUS_EXPECT_NAME) {
        _reportError("Can not "+typeMsg+", expecting field name");
    }
}
项目:Beam    文件:GeneratorBase.java   
protected GeneratorBase(int features, ObjectCodec codec)
{
    super();
    _features = features;
    DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
            ? DupDetector.rootDetector(this) : null;
    _writeContext = JsonWriteContext.createRootContext(dups);
    _objectCodec = codec;
    _cfgNumbersAsStrings = Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(features);
}
项目:joyplus-tv    文件:TokenBuffer.java   
/**
 * @param codec Object codec to use for stream-based object
 *   conversion through parser/generator interfaces. If null,
 *   such methods can not be used.
 */
public TokenBuffer(ObjectCodec codec)
{
    _objectCodec = codec;
    _generatorFeatures = DEFAULT_PARSER_FEATURES;
    _writeContext = JsonWriteContext.createRootContext();
    // at first we have just one segment
    _first = _last = new Segment();
    _appendOffset = 0;
}
项目:joyplus-tv    文件:TokenBuffer.java   
@Override
public final void writeEndArray()
    throws IOException, JsonGenerationException
{
    _append(JsonToken.END_ARRAY);
    // Let's allow unbalanced tho... i.e. not run out of root level, ever
    JsonWriteContext c = _writeContext.getParent();
    if (c != null) {
        _writeContext = c;
    }
}
项目:joyplus-tv    文件:TokenBuffer.java   
@Override
public final void writeEndObject()
    throws IOException, JsonGenerationException
{
    _append(JsonToken.END_OBJECT);
    // Let's allow unbalanced tho... i.e. not run out of root level, ever
    JsonWriteContext c = _writeContext.getParent();
    if (c != null) {
        _writeContext = c;
    }
}
项目:joyplus-tv    文件:GeneratorBase.java   
protected GeneratorBase(int features, ObjectCodec codec)
{
    super();
    _features = features;
    _writeContext = JsonWriteContext.createRootContext();
    _objectCodec = codec;
    _cfgNumbersAsStrings = isEnabled(Feature.WRITE_NUMBERS_AS_STRINGS);
}
项目:QuizUpWinner    文件:TokenBuffer.java   
public final JsonWriteContext getOutputContext()
{
  return this._writeContext;
}
项目:QuizUpWinner    文件:GeneratorBase.java   
public final JsonWriteContext getOutputContext()
{
  return this._writeContext;
}
项目:joyplus-tv    文件:TokenBuffer.java   
@Override
public final JsonWriteContext getOutputContext() { return _writeContext; }
项目:Beam    文件:GeneratorBase.java   
/**
 * Note: co-variant return type.
 */
@Override
public final JsonWriteContext getOutputContext() { return _writeContext; }
项目:joyplus-tv    文件:GeneratorBase.java   
/**
 * Note: co-variant return type.
 */
@Override
public final JsonWriteContext getOutputContext() { return _writeContext; }