gpt4 book ai didi

com.fasterxml.jackson.dataformat.yaml.YAMLGenerator类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 02:59:31 33 4
gpt4 key购买 nike

本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLGenerator类的一些代码示例,展示了YAMLGenerator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLGenerator类的具体详情如下:
包路径:com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
类名称:YAMLGenerator

YAMLGenerator介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

@Override
public void writeNumber(String encodedValue) throws IOException,JsonGenerationException, UnsupportedOperationException
{
  if (encodedValue == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write number");
  _writeScalar(encodedValue, "number", STYLE_SCALAR);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeNumber(long l) throws IOException
{
  // First: maybe 32 bits is enough?
  if (l <= MAX_INT_AS_LONG && l >= MIN_INT_AS_LONG) {
    writeNumber((int) l);
    return;
  }
  _verifyValueWrite("write number");
  _writeScalar(String.valueOf(l), "long", STYLE_SCALAR);
}

代码示例来源:origin: redisson/redisson

@Override
public final void writeStringField(String fieldName, String value)
  throws IOException
{
  if (_writeContext.writeFieldName(fieldName) == JsonWriteContext.STATUS_EXPECT_VALUE) {
    _reportError("Can not write a field name, expecting a value");
  }
  _writeFieldName(fieldName);
  writeString(value);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeNull() throws IOException
{
  _verifyValueWrite("write null value");
  // no real type for this, is there?
  _writeScalar("null", "object", STYLE_SCALAR);
}

代码示例来源:origin: jillesvangurp/jsonj

private void serialize(YAMLGenerator yaml, JsonElement e) throws IOException {
  switch (e.type()) {
  case object:
    yaml.writeStartObject();
    e.asObject().forEach((k,v) -> {
      try {
        yaml.writeFieldName(k);
        serialize(yaml, v);
      } catch (IOException e1) {
    yaml.writeEndObject();
    yaml.writeStartArray();
    e.asArray().forEach(element -> {
      try {
    yaml.writeEndArray();
    break;
  case string:
    yaml.writeString(e.asString());
    break;
  case bool:
    yaml.writeBoolean(e.asBoolean());
    break;
  case number:
    Class<? extends Number> clazz = number.getClass();
    if(clazz.isAssignableFrom(Double.class) || clazz.isAssignableFrom(Float.class)) {
      yaml.writeNumber(number.doubleValue());
    } else {

代码示例来源:origin: redisson/redisson

@Override
public void writeNumber(BigDecimal dec) throws IOException
{
  if (dec == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write number");
  String str = isEnabled(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN) ? dec.toPlainString() : dec.toString();
  _writeScalar(str, "java.math.BigDecimal", STYLE_SCALAR);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeString(String text) throws IOException,JsonGenerationException
{
  if (text == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write String value");
  Character style = STYLE_QUOTED;
  if (Feature.MINIMIZE_QUOTES.enabledIn(_formatFeatures) && !isBooleanContent(text)) {
   // If this string could be interpreted as a number, it must be quoted.
    if (Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS.enabledIn(_formatFeatures)
        && PLAIN_NUMBER_P.matcher(text).matches()) {
      style = STYLE_QUOTED;
    } else if (text.indexOf('\n') >= 0) {
      style = STYLE_LITERAL;
    } else {
      style = STYLE_PLAIN;
    }
  } else if (Feature.LITERAL_BLOCK_STYLE.enabledIn(_formatFeatures) && text.indexOf('\n') >= 0) {
    style = STYLE_LITERAL;
  }
  _writeScalar(text, "string", style);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException
{
  if (data == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write Binary value");
  if (offset > 0 || (offset+len) != data.length) {
    data = Arrays.copyOfRange(data, offset, offset+len);
  }
  _writeScalarBinary(b64variant, data);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeRawUTF8String(byte[] text, int offset, int len)
  throws IOException
{
  _reportUnsupportedOperation();
}

代码示例来源:origin: redisson/redisson

@Override
public final void writeFieldName(String name) throws IOException
{
  if (_writeContext.writeFieldName(name) == JsonWriteContext.STATUS_EXPECT_VALUE) {
    _reportError("Can not write a field name, expecting a value");
  }
  _writeFieldName(name);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeString(char[] text, int offset, int len) throws IOException
{
  writeString(new String(text, offset, len));
}

代码示例来源:origin: redisson/redisson

@Override
protected final void _verifyValueWrite(String typeMsg)
  throws IOException
{
  int status = _writeContext.writeValue();
  if (status == JsonWriteContext.STATUS_EXPECT_NAME) {
    _reportError("Can not "+typeMsg+", expecting field name");
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void writeObjectRef(Object id)
  throws IOException
{
  _verifyValueWrite("write Object reference");
  AliasEvent evt = new AliasEvent(String.valueOf(id), null, null);
  _emitter.emit(evt);
}

代码示例来源:origin: redisson/redisson

@Override
protected YAMLGenerator _createGenerator(Writer out, IOContext ctxt) throws IOException {
  int feats = _yamlGeneratorFeatures;
  YAMLGenerator gen = new YAMLGenerator(ctxt, _generatorFeatures, feats,
      _objectCodec, out, _version);
  // any other initializations? No?
  return gen;
}

代码示例来源:origin: redisson/redisson

protected void _writeScalar(String value, String type, Character style) throws IOException
{
  _emitter.emit(_scalarEvent(value, style));
}

代码示例来源:origin: redisson/redisson

private final void _writeFieldName(String name)
  throws IOException
{
  _writeScalar(name, "string", STYLE_NAME);
}

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

@Override
public void writeNumber(BigDecimal dec) throws IOException
{
  if (dec == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write number");
  String str = isEnabled(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN) ? dec.toPlainString() : dec.toString();
  _writeScalar(str, "java.math.BigDecimal", STYLE_SCALAR);
}

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

@Override
public void writeString(String text) throws IOException,JsonGenerationException
{
  if (text == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write String value");
  Character style = STYLE_QUOTED;
  if (Feature.MINIMIZE_QUOTES.enabledIn(_formatFeatures) && !isBooleanContent(text)) {
   // If this string could be interpreted as a number, it must be quoted.
    if (Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS.enabledIn(_formatFeatures)
        && PLAIN_NUMBER_P.matcher(text).matches()) {
      style = STYLE_QUOTED;
    } else if (text.indexOf('\n') >= 0) {
      style = STYLE_LITERAL;
    } else {
      style = STYLE_PLAIN;
    }
  } else if (Feature.LITERAL_BLOCK_STYLE.enabledIn(_formatFeatures) && text.indexOf('\n') >= 0) {
    style = STYLE_LITERAL;
  }
  _writeScalar(text, "string", style);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeBoolean(boolean state) throws IOException
{
  _verifyValueWrite("write boolean value");
  _writeScalar(state ? "true" : "false", "bool", STYLE_SCALAR);
}

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException
{
  if (data == null) {
    writeNull();
    return;
  }
  _verifyValueWrite("write Binary value");
  if (offset > 0 || (offset+len) != data.length) {
    data = Arrays.copyOfRange(data, offset, offset+len);
  }
  _writeScalarBinary(b64variant, data);
}

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com