Encodes an object in amf3 as an object of
the specified type
@param obj The object to encode
@param marker The type marker for this object
@throws IOException
177262
public void encodeAmf3(Object obj, Amf3Type marker) throws IOException {

        out.write(marker.ordinal());
        if (marker == Amf3Type.NULL) {
            return; // Null marker is enough
        }

        serializeAmf3(obj, marker);
    }
1025843
public void writeObject (Object object)
        throws IOException
    {
        // if the object to be written is null, simply write a zero
        if (object == null) {
            writeShort(0);
            return;
        }

        // otherwise, write the class mapping, then the bare object
        Class<?> sclass = Streamer.getStreamerClass(object);
        ClassMapping cmap = writeClassMapping(sclass);
        writeBareObject(object, cmap.streamer, true);
    }
562638
public static <T extends Serializable> void serializeToStream(T obj, OutputStream out) throws IOException
	{
		ObjectOutputStream objOut;

		if(out instanceof ObjectOutputStream)
			objOut = (ObjectOutputStream)out;
		else
			objOut = new ObjectOutputStream(out);
		objOut.writeObject(obj);
		objOut.close();
	}
843
protected void writeObject(Object o)
	{
		if (o == null)
		{
			return;
		}
		getPersistenceDelegate(o.getClass()).writeObject(o, this);
	}
1280293
@Override
  public byte[] encode(final NSMessage<T> obj) {
    if (isStreamingCodec) {
      final StreamingCodec<T> streamingCodec = (StreamingCodec<T>) codec;
      try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        try (DataOutputStream daos = new DataOutputStream(baos)) {
          daos.writeUTF(obj.getSrcId().toString());
          daos.writeUTF(obj.getDestId().toString());
          daos.writeInt(obj.getData().size());
          for (final T rec : obj.getData()) {
            streamingCodec.encodeToStream(rec, daos);
          }
        }
        return baos.toByteArray();
      } catch (final IOException e) {
        throw new RuntimeException("IOException", e);
      }
    } else {
      final NSMessagePBuf.Builder pbuf = NSMessagePBuf.newBuilder();
      pbuf.setSrcid(obj.getSrcId().toString());
      pbuf.setDestid(obj.getDestId().toString());
      for (final T rec : obj.getData()) {
        final NSRecordPBuf.Builder rbuf = NSRecordPBuf.newBuilder();
        rbuf.setData(ByteString.copyFrom(codec.encode(rec)));
        pbuf.addMsgs(rbuf);
      }
      return pbuf.build().toByteArray();
    }
  }
970348
@Override
  public byte[] encode(final T obj) {
    try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
         final ObjectOutputStream out = new ObjectOutputStream(bos)) {
      out.writeObject(obj);
      return bos.toByteArray();
    } catch (final IOException ex) {
      throw new RemoteRuntimeException(ex);
    }
  }
648037
public void writeObject(Object obj, AbstractHessianOutput out) 
        throws IOException {
    	
        if (out.addRef(obj)) {
            return;
        }
	    
        Class< ? > cl = obj.getClass();
	    
        try {
            if (writeReplace != null) {
                Object repl = writeReplace.invoke(obj, new Object[0]);

                out.removeRef(obj);

                out.writeObject(repl);

                out.replaceRef(repl, obj);

                return;
            }
        } catch (Exception e) {
            log.log(Level.FINE, e.toString(), e);
        }

        int ref = out.writeObjectBegin(cl.getName());

        if (ref < -1) {
	    // Hessian 1.1 uses a map
	      
            for (int i = 0; i < localMethods.length; i++) {
                Object value = null;

                try {
                    value = localMethods[i].invoke(obj, (Object []) null);
                } catch (Exception e) {
                    log.log(Level.FINE, e.toString(), e);
                }
		
                if (!LazyUtil.isPropertyInitialized(value)) {
                    continue;
                }
		
                out.writeString(localNames[i]);
		
                out.writeObject(value);
            }
	      
            out.writeMapEnd();
        } else {
            if (ref == -1) {
                out.writeInt(localNames.length);
		
                for (int i = 0; i < localNames.length; i++) {
                    out.writeString(localNames[i]);
                }
                out.writeObjectBegin(cl.getName());
            }

            for (int i = 0; i < localMethods.length; i++) {
                Object value = null;

                try {
                    value = localMethods[i].invoke(obj, (Object []) null);
                } catch (Exception e) {
                    log.log(Level.FINER, e.toString(), e);
                }
		
                if (!LazyUtil.isPropertyInitialized(value)) {
                    continue;
                }
		
                out.writeObject(value);
            }
        }
    }
576437
@SuppressWarnings("unchecked")
  public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
    write(out, label, (O) object);
  }
1119495
public void writeObject(Object object)
        throws IOException
    {
        if (object == null) {
            writeNull();
            return;
        }

        Serializer serializer;

        serializer = _serializerFactory.getSerializer(object.getClass());

        serializer.writeObject(object, this);
    }
11324
public Message setObject(Object obj) {
        if(obj == null) return this;
        if(obj instanceof byte[])
            return setBuffer((byte[])obj);
        if(obj instanceof Buffer)
            return setBuffer((Buffer)obj);
        try {
            return setBuffer(Util.objectToByteBuffer(obj));
        }
        catch(Exception ex) {
            throw new IllegalArgumentException(ex);
        }
    }
814940
def writeObject(self, o):
        
        if self.writeReference(o) != -1:
            return

        self.context.addObject(o)
        alias = self.context.getClassAlias(o.__class__)

        alias.compile()

        if alias.amf3:
            self.writeAMF3(o)

            return

        if alias.anonymous:
            self.writeType(TYPE_OBJECT)
        else:
            self.writeType(TYPE_TYPEDOBJECT)
            self.serialiseString(alias.alias)

        attrs = alias.getEncodableAttributes(o, codec=self)

        if alias.static_attrs and attrs:
            for key in alias.static_attrs:
                value = attrs.pop(key)

                self.serialiseString(key)
                self.writeElement(value)

        if attrs:
            self._writeDict(attrs)

        self._writeEndObject()
393683
public static void write(Writer out, Object object) throws IOException {
        if (object instanceof String) {
            out.write((String) object);
        } else if (object instanceof Object[]) {
            out.write(toArrayString((Object[]) object));
        } else if (object instanceof Map) {
            out.write(toMapString((Map) object));
        } else if (object instanceof Collection) {
            out.write(toListString((Collection) object));
        } else if (object instanceof Writable) {
            Writable writable = (Writable) object;
            writable.writeTo(out);
        } else if (object instanceof InputStream || object instanceof Reader) {
            // Copy stream to stream
            Reader reader;
            if (object instanceof InputStream) {
                reader = new InputStreamReader((InputStream) object);
            } else {
                reader = (Reader) object;
            }

            try (Reader r = reader) {
                char[] chars = new char[8192];
                for (int i; (i = r.read(chars)) != -1; ) {
                    out.write(chars, 0, i);
                }
            }
        } else {
            out.write(toString(object));
        }
    }
162209
public static void writeObjectToStream(final Object o, OutputStream out) {
    out = new BufferedOutputStream(out);
    try {
      final ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(o);
      oos.flush();
    } catch (final IOException e) {
      e.printStackTrace();
    }
  }
330343
public void init(Object obj)
    {
        m_bookmark = null;
        m_objectID = null;
        m_dataSource = null;
        m_objectSource = null;
        m_buffer = null;
    }
673535
public void writeObject (ObjectOutputStream out)
        throws IOException
    {
        if (!classDefinesElementType()) {
            out.writeUTF(_elementType.getName());
        }
        out.write(_contents);
    }
322917
public void encodeValue(Writer writer, T obj) throws IOException {
		int count = 0;
		for (String key : map.keySet()) {
			JsonUtil.putKey(writer, key);
			JsonPropertyCoder<T, ?> enc = map.get(key);
			enc.encode(writer, obj);
			count++;
			if (count != map.size()) {
				JsonUtil.addSeparator(writer);
			}
		}
	}
92496
public void sendWithBulkProcessorAndObjectMapper(Object object,
            String index, String type) {
        sendWithBulkProcessorAndObjectMapper(object, index, type, null);
    }