congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GraphIOUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
GraphIOUtil
in
io.protostuff

Best Java code snippets using io.protostuff.GraphIOUtil (Showing top 20 results out of 315)

origin: protostuff/protostuff

public void readExternal(ObjectInput in) throws IOException
{
  GraphIOUtil.mergeDelimitedFrom(in, this, this);
}
origin: protostuff/protostuff

public void writeExternal(ObjectOutput out) throws IOException
{
  GraphIOUtil.writeDelimitedTo(out, this, this);
}
origin: protostuff/protostuff

/**
 * Merges the {@code message} with the byte array using the given {@code schema}.
 */
public static <T> void mergeFrom(byte[] data, T message, Schema<T> schema)
{
  mergeFrom(data, 0, data.length, message, schema);
}
origin: protostuff/protostuff

public void testGraph()
{
  System.err.println(RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS);
  Bean bean = fill(new Bean());
  verify(bean);
  Schema<Bean> schema = RuntimeSchema.getSchema(Bean.class);
  // print(schema);
  byte[] bytes = GraphIOUtil.toByteArray(bean, schema,
      LinkedBuffer.allocate(256));
  Bean deBean = new Bean();
  GraphIOUtil.mergeFrom(bytes, deBean, schema);
  verify(deBean);
}
origin: apache/incubator-dubbo

@SuppressWarnings("unchecked")
@Override
public void writeObject(Object obj) throws IOException {
  byte[] bytes;
  byte[] classNameBytes;
  try {
    if (WrapperUtils.needWrapper(obj)) {
      Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class);
      Wrapper wrapper = new Wrapper(obj);
      bytes = GraphIOUtil.toByteArray(wrapper, schema, buffer);
      classNameBytes = Wrapper.class.getName().getBytes();
    } else {
      Schema schema = RuntimeSchema.getSchema(obj.getClass());
      bytes = GraphIOUtil.toByteArray(obj, schema, buffer);
      classNameBytes = obj.getClass().getName().getBytes();
    }
  } finally {
    buffer.clear();
  }
  dos.writeInt(classNameBytes.length);
  dos.writeInt(bytes.length);
  dos.write(classNameBytes);
  dos.write(bytes);
}
origin: protostuff/protostuff

ByteArrayOutputStream oss = new ByteArrayOutputStream(1024);
GraphIOUtil.writeTo(oss, obj, schema, buffer);
GraphIOUtil.mergeFrom(oss.toByteArray(), objParsed, schema);
origin: protostuff/protostuff

/**
 * Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and this method
 * will return false.
 * <p>
 * This is strictly for reading a single message from the stream because the buffer is aggressively filled when
 * reading the delimited size (which could result into reading more bytes than it has to).
 * <p>
 * The remaining bytes will be drained (consumed and discared) when the message is too large.
 */
public static <T> boolean optMergeDelimitedFrom(InputStream in,
    T message, Schema<T> schema,
    LinkedBuffer buffer) throws IOException
{
  return optMergeDelimitedFrom(in, message, schema, true, buffer);
}
origin: org.apache.cayenne/cayenne-protostuff

@Override
public void serialize(Object object, OutputStream outputStream) throws IOException {
  GraphIOUtil.writeTo(outputStream, new Wrapper(object), wrapperSchema, LinkedBuffer.allocate());
}
origin: protostuff/protostuff

public void testBeanCyclic()
{
  System.err.println(RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS);
  Bean bean = fillCyclic(new Bean());
  verifyCyclic(bean);
  Schema<Bean> schema = RuntimeSchema.getSchema(Bean.class);
  // print(schema);
  byte[] bytes = GraphIOUtil.toByteArray(bean, schema,
      LinkedBuffer.allocate(256));
  Bean deBean = new Bean();
  GraphIOUtil.mergeFrom(bytes, deBean, schema);
  verifyCyclic(deBean);
}
origin: apache/incubator-dubbo

@SuppressWarnings("unchecked")
@Override
public void writeObject(Object obj) throws IOException {
  byte[] bytes;
  byte[] classNameBytes;
  try {
    if (WrapperUtils.needWrapper(obj)) {
      Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class);
      Wrapper wrapper = new Wrapper(obj);
      bytes = GraphIOUtil.toByteArray(wrapper, schema, buffer);
      classNameBytes = Wrapper.class.getName().getBytes();
    } else {
      Schema schema = RuntimeSchema.getSchema(obj.getClass());
      bytes = GraphIOUtil.toByteArray(obj, schema, buffer);
      classNameBytes = obj.getClass().getName().getBytes();
    }
  } finally {
    buffer.clear();
  }
  dos.writeInt(classNameBytes.length);
  dos.writeInt(bytes.length);
  dos.write(classNameBytes);
  dos.write(bytes);
}
origin: protostuff/protostuff

@Override
protected <T> boolean optMergeDelimitedFrom(InputStream in, T message, Schema<T> schema,
    LinkedBuffer buffer) throws IOException
{
  return GraphIOUtil.optMergeDelimitedFrom(in, message, schema, buffer);
}
origin: protostuff/protostuff

public void readExternal(ObjectInput in) throws IOException
{
  GraphIOUtil.mergeDelimitedFrom(in, this, this);
}
origin: protostuff/protostuff

public void writeExternal(ObjectOutput out) throws IOException
{
  GraphIOUtil.writeDelimitedTo(out, this, this);
}
origin: protostuff/protostuff

public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema)
    throws IOException
{
  GraphIOUtil.mergeFrom(in, message, schema);
}
origin: protostuff/protostuff

public static <T> byte[] toByteArray(T message, Schema<T> schema) throws IOException
{
  return GraphIOUtil.toByteArray(message, schema, buf());
}
origin: protostuff/protostuff

public void readExternal(ObjectInput in) throws IOException
{
  GraphIOUtil.mergeDelimitedFrom(in, this, this);
}
origin: protostuff/protostuff

public void writeExternal(ObjectOutput out) throws IOException
{
  GraphIOUtil.writeDelimitedTo(out, this, this);
}
origin: protostuff/protostuff

public static <T> void mergeFrom(byte[] data, int offset, int length,
    T message, Schema<T> schema) throws IOException
{
  GraphIOUtil.mergeFrom(data, offset, length, message, schema);
}
origin: protostuff/protostuff

private static <T> byte[] serializeGraph(T object)
{
  @SuppressWarnings("unchecked")
  Class<T> clazz = (Class<T>) object.getClass();
  Schema<T> schema = RuntimeSchema.getSchema(clazz);
  return GraphIOUtil.toByteArray(object, schema, LinkedBuffer.allocate());
}
origin: protostuff/protostuff

@Override
public void readExternal(ObjectInput in) throws IOException
{
  GraphIOUtil.mergeDelimitedFrom(in, this, this);
}
io.protostuffGraphIOUtil

Javadoc

IO Utilities for graph objects (references and cyclic dependencies).

Most used methods

  • mergeDelimitedFrom
    Merges the message (delimited) from the InputStream using the given schema. The delimited message si
  • writeDelimitedTo
    Serializes the message, prefixed with its length, into an OutputStream.
  • mergeFrom
  • toByteArray
  • optMergeDelimitedFrom
    Optimal/Optional mergeDelimitedFrom - If the message does not fit the buffer, no merge is done and t
  • writeTo
  • optWriteDelimitedTo
    Optimal writeDelimitedTo - The varint32 prefix is written to the buffer instead of directly writing

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • Permission (java.security)
    Legacy security code; do not use.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now