io.protostuff.Schema.messageName()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(110)

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

Schema.messageName介绍

[英]Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();
[中]返回绑定到此架构的消息的简单名称。允许自定义架构提供除typeClass()之外的自定义名称。getSimpleName();

代码示例

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

@Override
public String messageName()
{
  return wrappedSchema.messageName();
}

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

@Override
public String messageName()
{
  return schema.messageName();
}

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

/**
 * Serializes the {@code message} into an {@link XMLStreamWriter} using the given {@code schema}.
 */
public static <T> void writeTo(XMLStreamWriter writer, T message, Schema<T> schema)
    throws IOException, XMLStreamException, XmlOutputException
{
  writer.writeStartElement(schema.messageName());
  schema.writeTo(new XmlOutput(writer, schema), message);
  writer.writeEndElement();
}

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

@Override
protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException
{
  // final String simpleName = pipeSchema.wrappedSchema.messageName();
  try
  {
    if (parser.nextTag() != START_ELEMENT ||
        !pipeSchema.wrappedSchema.messageName().equals(parser.getLocalName()))
    {
      throw new XmlInputException("Expected token START_ELEMENT: " +
          pipeSchema.wrappedSchema.messageName());
    }
    if (parser.nextTag() == END_ELEMENT)
    {
      // if(!simpleName.equals(parser.getLocalName()))
      // throw new XmlInputException("Expecting token END_ELEMENT: " +
      // simpleName);
      // empty message;
      return null;
    }
  }
  catch (XMLStreamException e)
  {
    throw new XmlInputException(e);
  }
  return xmlInput;
}

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

/**
 * Serializes the {@code messages} into the {@link XMLStreamWriter} using the given schema.
 */
public static <T> void writeListTo(XMLStreamWriter writer, List<T> messages, Schema<T> schema)
    throws IOException, XMLStreamException
{
  writer.writeStartElement("list");
  if (messages.isEmpty())
  {
    writer.writeEndElement();
    return;
  }
  final String simpleName = schema.messageName();
  final XmlOutput output = new XmlOutput(writer, schema);
  for (T m : messages)
  {
    writer.writeStartElement(simpleName);
    schema.writeTo(output, m);
    writer.writeEndElement();
  }
  writer.writeEndElement();
}

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

/**
 * Merges the {@code message} from the {@link XMLStreamReader} using the given {@code schema}.
 */
public static <T> void mergeFrom(XMLStreamReader parser, T message, Schema<T> schema)
    throws IOException, XMLStreamException, XmlInputException
{
  // final String simpleName = schema.messageName();
  if (parser.nextTag() != START_ELEMENT ||
      !schema.messageName().equals(parser.getLocalName()))
  {
    throw new XmlInputException("Expected token START_ELEMENT: " + schema.messageName());
  }
  if (parser.nextTag() == END_ELEMENT)
  {
    // if(!simpleName.equals(parser.getLocalName()))
    // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);
    // empty message;
    return;
  }
  schema.mergeFrom(new XmlInput(parser), message);
  // if(!simpleName.equals(parser.getLocalName()))
  // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);
}

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

if (tag != START_ELEMENT || !schema.messageName().equals(parser.getLocalName()))
  throw new XmlInputException("Expected token START_ELEMENT: " + schema.messageName());

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

/**
 * Serializes the {@code message} into a byte array with the supplied buffer.
 */
public static <T> byte[] toByteArray(T message, Schema<T> schema, LinkedBuffer buffer)
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final YamlOutput output = new YamlOutput(buffer, schema);
  try
  {
    output.tail = YamlOutput.writeTag(
        schema.messageName(),
        false,
        output.sink,
        output,
        output.sink.writeByteArray(
            START_DIRECTIVE,
            output,
            buffer));
    schema.writeTo(output, message);
  }
  catch (IOException e)
  {
    throw new RuntimeException("Serializing to a byte array threw an IOException " +
        "(should never happen).", e);
  }
  return output.toByteArray();
}

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

/**
 * Serializes the {@code message} into the {@link LinkedBuffer}.
 * 
 * @return the total bytes written to the output.
 */
public static <T> int writeTo(LinkedBuffer buffer, T message, Schema<T> schema)
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final YamlOutput output = new YamlOutput(buffer, schema);
  try
  {
    output.tail = YamlOutput.writeTag(
        schema.messageName(),
        false,
        output.sink,
        output,
        output.sink.writeByteArray(
            START_DIRECTIVE,
            output,
            buffer));
    schema.writeTo(output, message);
  }
  catch (IOException e)
  {
    throw new RuntimeException("Serializing to a LinkedBuffer threw an IOException " +
        "(should never happen).", e);
  }
  return output.getSize();
}

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

/**
 * Serializes the {@code message} into an {@link OutputStream} with the supplied buffer.
 * 
 * @return the total bytes written to the output.
 */
public static <T> int writeTo(OutputStream out, T message, Schema<T> schema,
    LinkedBuffer buffer) throws IOException
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final YamlOutput output = new YamlOutput(buffer, out, schema);
  output.tail = YamlOutput.writeTag(
      schema.messageName(),
      false,
      output.sink,
      output,
      output.sink.writeByteArray(
          START_DIRECTIVE,
          output,
          buffer));
  schema.writeTo(output, message);
  LinkedBuffer.writeTo(out, buffer);
  return output.getSize();
}

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

schema.messageName(),
true,
output.sink,

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

final String name = schema.messageName();
try

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

final String name = schema.messageName();
try

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

/**
 * Serializes the {@code messages} into an {@link OutputStream} using the given schema with the supplied buffer.
 * 
 * @return the total bytes written to the output.
 */
public static <T> int writeListTo(OutputStream out, List<T> messages,
    Schema<T> schema, LinkedBuffer buffer) throws IOException
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final YamlOutput output = new YamlOutput(buffer, out, schema);
  output.tail = YamlOutput.writeTag(
      schema.messageName(),
      true,
      output.sink,
      output,
      output.sink.writeByteArray(
          START_DIRECTIVE,
          output,
          buffer));
  for (T m : messages)
  {
    schema.writeTo(output.writeSequenceDelim(), m);
    output.reset();
  }
  LinkedBuffer.writeTo(out, buffer);
  return output.getSize();
}

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

/**
 * Serializes the {@code message} into an {@link OutputStream} using the given schema.
 * 
 * @return the size of the message
 */
public static <T> int writeTo(final OutputStream out, final T message,
    final Schema<T> schema, final LinkedBuffer buffer) throws IOException
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final XmlXOutput output = new XmlXOutput(buffer, out, schema);
  final String name = schema.messageName();
  // header and start root element
  output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
      output.sink.writeStrAscii(name, output,
          output.sink.writeByte(XmlXOutput.START_TAG, output,
              output.sink.writeByteArray(HEADER, output, output.tail))));
  schema.writeTo(output, message);
  // end root element
  output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
      output.sink.writeStrAscii(name, output,
          output.sink.writeByteArray(XmlXOutput.START_SLASH_TAG, output, output.tail)));
  LinkedBuffer.writeTo(out, buffer);
  return output.size;
}

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

schema.messageName(),
repeated,
sink,

相关文章