/*
(non-Javadoc)

@see com.baidu.bjf.remoting.protobuf.Codec#writeTo(java.lang.Object,
com.google.protobuf.CodedOutputStream)
508526
@Override
	public void writeTo(T t, CodedOutputStream out) throws IOException {
		for (FieldInfo fieldInfo : fieldInfos) {
			Object value = FieldUtils.getField(t, fieldInfo.getField());
			if (value != null) {
				writeTo(fieldInfo, value, out);
			}
		}

	}
151034
void writeTo(OutputStream os) throws IOException
    {
        os.write(DocWriter.getISOBytes(String.valueOf(number)));
        os.write(' ');
        os.write(DocWriter.getISOBytes(String.valueOf(generation)));
        os.write(STARTOBJ);
        object.toPdf(writer, os);
        os.write(ENDOBJ);
    }
451903
public void writeTo(final PacketOutputStream pos) throws IOException {
    pos.write(BINARY_INTRODUCER);
    pos.writeBytesEscaped(bytes, bytes.length, noBackslashEscapes);
    pos.write(QUOTE);
  }
1355537
public void writeTo(final PacketOutputStream os) throws IOException {
    os.write(QUOTE);
    os.write(dateByteFormat());
    os.write(QUOTE);
  }
1025778
static <K, V> void writeTo(CodedOutputStream output, Metadata<K, V> metadata, K key, V value) throws IOException {
        CodedConstant.writeElement(output, metadata.keyType, KEY_FIELD_NUMBER, key);
        CodedConstant.writeElement(output, metadata.valueType, VALUE_FIELD_NUMBER, value);
    }
920702
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempOutputStream ts = new TempOutputStream();
    //ts.openWrite();
    //WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ts, out.getJavaClass());
    
    o2.writeShort(_maxStack);
    o2.writeShort(_maxLocals);
    o2.writeInt(_code.length);
    o2.write(_code, 0, _code.length);

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      ExceptionItem exn = _exceptions.get(i);

      o2.writeShort(exn.getStart());
      o2.writeShort(exn.getEnd());
      o2.writeShort(exn.getHandler());
      o2.writeShort(exn.getType());
    }

    o2.writeShort(_attributes.size());
    for (int i = 0; i < _attributes.size(); i++) {
      Attribute attr = _attributes.get(i);

      attr.write(o2);
    }
    
    //ws.close();
    
    out.writeInt(ts.getLength());
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.next())
      out.write(ptr.buffer(), 0, ptr.length());

    ts.destroy();
  }
1154664
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema)
            throws IOException
    {
        writeTo(out, message, schema, DEFAULT_OUTPUT_FACTORY);
    }
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();
    }
  }
1023441
@Override
    public void writeTo(final boolean quote, final String value) {
        char[] chs = Utility.charArray(value);
        writeTo(-1, quote, chs, 0, chs.length);
    }
967985
@Nonnull
  public ESuccess writeTo (@Nonnull final IWritableResource aRes)
  {
    return writeTo (aRes.getOutputStream (EAppend.TRUNCATE));
  }
120723
@Override
  public void write(TextWriterStream out, String label, TextWriteable obj) {
    obj.writeToText(out, label);
  }
863702
public void writeTo(OutputStream out) throws IOException {
        if (!(out instanceof DataOutput)) {
            out = new DataOutputStream(out);
        }

        writeTo((DataOutput)out);

        out.flush();
    }
622360
public void writeTo(String zoneID, OutputStream out) throws IOException {
        if (out instanceof DataOutput) {
            writeTo(zoneID, (DataOutput)out);
        } else {
            DataOutputStream dout = new DataOutputStream(out);
            writeTo(zoneID, (DataOutput)dout);
            dout.flush();
        }
    }
650818
public static void copyStream(InputStream copyFrom, File copyTo)
			throws IOException {
		copyStream(copyFrom, copyTo, null);
	}
175596
public static <T extends Message<T>> void writeTo(OutputStream out, T message, boolean numeric,
            LinkedBuffer buffer)
            throws IOException
    {
        writeTo(out, message, message.cachedSchema(), numeric, buffer);
    }
368553
public static void copyFile(File copyFrom, File copyTo) throws IOException {

		InputStream from = new FileInputStream(copyFrom);
		OutputStream to = new FileOutputStream(copyTo);

		copyStream(from, to);
	}
1038509
public void writeToOutputStream(OutputStream os) throws IOException {
		if(sb == null) {
			throw new IllegalStateException("No interal StringBuffer");
		}
		byte[] b;
		try {
			b = getBytes();
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
		os.write(b);
	}