Package org.infinispan.protostream

Examples of org.infinispan.protostream.BaseMarshaller


   public void write(CodedOutputStream out, Object t) throws IOException {
      resetContext();
      if (t instanceof MessageLite) {
         ((MessageLite) t).writeTo(out);
      } else {
         BaseMarshaller marshaller = ctx.getMarshaller(t.getClass());
         Descriptors.Descriptor messageDescriptor = ctx.getMessageDescriptor(marshaller.getTypeName());
         enterContext(null, messageDescriptor, out);
         marshall(t, marshaller, out);
         exitContext();
      }
      out.flush();
View Full Code Here


   private void writeMessage(Descriptors.FieldDescriptor fd, Object value, Class clazz) throws IOException {
      if (MessageLite.class.isAssignableFrom(clazz)) {
         messageContext.out.writeMessage(fd.getNumber(), (MessageLite) value);
      } else {
         BaseMarshaller marshaller = ctx.getMarshaller(clazz);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();      //todo here we should use a better buffer allocation strategy
         CodedOutputStream out = CodedOutputStream.newInstance(baos);
         enterContext(fd.getName(), fd.getMessageType(), out);
         marshall(value, marshaller, out);
         out.flush();
View Full Code Here

      messageContext.out.writeTag(fd.getNumber(), WireFormat.WIRETYPE_START_GROUP);
      if (MessageLite.class.isAssignableFrom(clazz)) {
         messageContext.out.writeGroup(fd.getNumber(), (MessageLite) value);
      } else {
         enterContext(fd.getName(), fd.getMessageType(), messageContext.out);
         BaseMarshaller marshaller = ctx.getMarshaller(clazz);
         marshall(value, marshaller, messageContext.out);
         exitContext();
      }
      messageContext.out.writeTag(fd.getNumber(), WireFormat.WIRETYPE_END_GROUP);
   }
View Full Code Here

   public void write(CodedOutputStream out, Object t) throws IOException {
      resetContext();
      if (t instanceof MessageLite) {
         ((MessageLite) t).writeTo(out);
      } else {
         BaseMarshaller marshaller = ctx.getMarshaller(t.getClass());
         Descriptors.Descriptor messageDescriptor = ctx.getMessageDescriptor(marshaller.getFullName());
         enterContext(messageDescriptor, out);
         marshall(t, marshaller, out);
         exitContext();
      }
      out.flush();
View Full Code Here

   private void writeMessage(Descriptors.FieldDescriptor fd, Object value, Class clazz) throws IOException {
      if (MessageLite.class.isAssignableFrom(clazz)) {
         messageContext.out.writeMessage(fd.getNumber(), (MessageLite) value);
      } else {
         BaseMarshaller marshaller = ctx.getMarshaller(clazz);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();      //todo here we should use a better buffer allocation strategy
         CodedOutputStream out = CodedOutputStream.newInstance(baos);
         enterContext(fd.getMessageType(), out);
         marshall(value, marshaller, out);
         out.flush();
View Full Code Here

      messageContext.out.writeTag(fd.getNumber(), WireFormat.WIRETYPE_START_GROUP);
      if (MessageLite.class.isAssignableFrom(clazz)) {
         messageContext.out.writeGroup(fd.getNumber(), (MessageLite) value);
      } else {
         enterContext(fd.getMessageType(), messageContext.out);
         BaseMarshaller marshaller = ctx.getMarshaller(clazz);
         marshall(value, marshaller, messageContext.out);
         exitContext();
      }
      messageContext.out.writeTag(fd.getNumber(), WireFormat.WIRETYPE_END_GROUP);
   }
View Full Code Here

         out.writeString(WRAPPED_DESCRIPTOR_FULL_NAME, enumMarshaller.getTypeName());
         out.writeEnum(WRAPPED_ENUM, enumMarshaller.encode((Enum) t));
      } else {
         // this is either an unknown primitive type or a message type
         // try to use a message marshaller
         BaseMarshaller marshaller = ctx.getMarshaller(t.getClass());
         out.writeString(WRAPPED_DESCRIPTOR_FULL_NAME, marshaller.getTypeName());

         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         ProtoStreamWriterImpl writer = new ProtoStreamWriterImpl((SerializationContextImpl) ctx);
         writer.write(CodedOutputStream.newInstance(buffer), t);
View Full Code Here

TOP

Related Classes of org.infinispan.protostream.BaseMarshaller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.