Writes a type descriptor followed by unsigned integer value.
Does not check for sign.
Note that this does not do {@link #prepareValue()} or {@link #finishValue()}.
332803
private void writeTypedUInt(final int type, final long value)
    {
        if (value <= 0xFFL)
        {
            updateLength(2);
            buffer.writeUInt8(type | 0x01);
            buffer.writeUInt8(value);
        }
        else if (value <= 0xFFFFL)
        {
            updateLength(3);
            buffer.writeUInt8(type | 0x02);
            buffer.writeUInt16(value);
        }
        else if (value <= 0xFFFFFFL)
        {
            updateLength(4);
            buffer.writeUInt8(type | 0x03);
            buffer.writeUInt24(value);
        }
        else if (value <= 0xFFFFFFFFL)
        {
            updateLength(5);
            buffer.writeUInt8(type | 0x04);
            buffer.writeUInt32(value);
        }
        else if (value <= 0xFFFFFFFFFFL)
        {
            updateLength(6);
            buffer.writeUInt8(type | 0x05);
            buffer.writeUInt40(value);
        }
        else if (value <= 0xFFFFFFFFFFFFL)
        {
            updateLength(7);
            buffer.writeUInt8(type | 0x06);
            buffer.writeUInt48(value);
        }
        else if (value <= 0xFFFFFFFFFFFFFFL)
        {
            updateLength(8);
            buffer.writeUInt8(type | 0x07);
            buffer.writeUInt56(value);
        }
        else
        {
            updateLength(9);
            buffer.writeUInt8(type | 0x08);
            buffer.writeUInt64(value);
        }
    }
1300876
@Override
    public final void writeTypedElement(AsciiValueEncoder enc)
        throws IOException
    {
        if (mSurrogate != 0) {
            throwUnpairedSurrogate();
        }
        if (enc.bufferNeedsFlush(mOutputBuffer.length - mOutputPtr)) {
            flush();
        }
        while (true) {
            mOutputPtr = enc.encodeMore(mOutputBuffer, mOutputPtr, mOutputBuffer.length);
            // If no flushing needed, indicates that all data was encoded
            if (enc.isCompleted()) {
                break;
            }
            flush();
        }
    }
71517
@Override
    public final void writeTypedElement(AsciiValueEncoder enc)
        throws IOException
    {
        if (mOut == null) {
            return;
        }

        int free = mOutputBufLen - mOutputPtr;
        if (enc.bufferNeedsFlush(free)) {
            flush();
        }
        while (true) {
            mOutputPtr = enc.encodeMore(mOutputBuffer, mOutputPtr, mOutputBufLen);
            // If no flushing needed, indicates that all data was encoded
            if (enc.isCompleted()) {
                break;
            }
            flush();
        }
    }
421262
public static String writeInteger(Integer value) {
		if (value==null) return null;
		
		return Integer.toString(value);			
	}
1162460
public void encodeSelf(ObjectOutput buf) throws IOException {
    buf.writeByte((byte) type);
    switch (type) {
    case STRING:
      buf.writeUTF((String) value);
      return;
    case LONG:
      buf.writeLong(((Long) value).longValue()); // was NumericValue
      return;
    case DOUBLE:
      buf.writeDouble(((Double) value).doubleValue()); // was NumericValue
      return;
    case INT:
      buf.writeInt(((Integer) value).intValue()); // was NumericValue
      return;
    case FLOAT:
      buf.writeFloat(((Float) value).floatValue()); // was NumericValue
      return;
    case BOOLEAN:
      buf.writeBoolean(((Boolean) value).booleanValue()); // was BooleanValue
      return;
    case OBJECT:
      buf.writeObject(value);
    default:
      throw new IllegalStateException();
    }
  }
891608
public static void writeIntegerLittleEndian(IO.WritableByteStream io, int value) throws IOException {
		io.write((byte)(value & 0xFF));
		io.write((byte)((value >> 8) & 0xFF));
		io.write((byte)((value >> 16) & 0xFF));
		io.write((byte)((value >> 24) & 0xFF));
	}
1214165
public void writeInt(int value) throws IOException {
    if (4 > buf.length - pos) {
      //not enough space remaining
      byte[] arr = new byte[4];
      arr[0] = (byte) value;
      arr[1] = (byte) (value >> 8);
      arr[2] = (byte) (value >> 16);
      arr[3] = (byte) (value >> 24);
      write(arr, 0, 4);
      return;
    }

    buf[pos] = (byte) value;
    buf[pos + 1] = (byte) (value >> 8);
    buf[pos + 2] = (byte) (value >> 16);
    buf[pos + 3] = (byte) (value >> 24);
    pos += 4;
  }
536218
public static String classDescriptor(Type type, Types types) {
    SigGen sig = new SigGen(types);
    sig.assembleClassSig(types.erasure(type));
    return sig.toString();
  }
474844
public void writeInt64(final int fieldNumber, final long value)
                         throws IOException {
    writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
    writeInt64NoTag(value);
  }
1174169
public void writeGeneric( Object value )
    {
        if (value == null)
            write(NULL_VALUE);
        else
        {
            if (value instanceof String)
            {
                writeByte(TYPE_STRING);
                writeUTF((String)value);
            }
            else if (value instanceof Boolean)
            {
                writeByte(TYPE_BOOLEAN);
                writeBoolean(((Boolean)value).booleanValue());
            }
            else if (value instanceof Byte)
            {
                writeByte(TYPE_BYTE);
                writeByte(((Byte)value).byteValue());
            }
            else if (value instanceof Short)
            {
                writeByte(TYPE_SHORT);
                writeShort(((Short)value).shortValue());
            }
            else if (value instanceof Integer)
            {
                writeByte(TYPE_INT);
                writeInt(((Integer)value).intValue());
            }
            else if (value instanceof Long)
            {
                writeByte(TYPE_LONG);
                writeLong(((Long)value).longValue());
            }
            else if (value instanceof Float)
            {
                writeByte(TYPE_FLOAT);
                writeFloat(((Float)value).floatValue());
            }
            else if (value instanceof Double)
            {
                writeByte(TYPE_DOUBLE);
                writeDouble(((Double)value).doubleValue());
            }
            else if (value instanceof byte[])
            {
                writeByte(TYPE_BYTEARRAY);
                writeByteArray((byte[])value);
            }
            else if (value instanceof Character)
            {
                writeByte(TYPE_CHARACTER);
                writeChar(((Character)value).charValue());
            }
            else
                throw new IllegalArgumentException("Unsupported type : "+value.getClass().getName());
        }
351870
public static void writeUnsignedShortLittleEndian(ByteBuffer io, int value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
	}
1090446
private void writeType(String type)
        throws IOException
    {
        flushIfFull();

        int len = type.length();
        if (len == 0) {
            throw new IllegalArgumentException("empty type is not allowed");
        }

        if (_typeRefs == null)
            _typeRefs = new HashMap<String, Integer>();

        Integer typeRefV = (Integer) _typeRefs.get(type);

        if (typeRefV != null) {
            int typeRef = typeRefV.intValue();

            writeInt(typeRef);
        }
        else {
            _typeRefs.put(type, Integer.valueOf(_typeRefs.size()));

            writeString(type);
        }
    }
971706
def WriteUInt160(self, value):
        
        if type(value) is UInt160:
            value.Serialize(self)
        else:
            raise Exception("value must be UInt160 instance ")
728937
public void writeVarLong(final long value) throws IOException {
    final int bitLength = new Bits(value).bitLength;
    int type = Arrays.binarySearch(varLongDepths, bitLength);
    if (type < 0) {
      type = -type - 1;
    }
    this.write(new Bits(type, 2));
    this.write(new Bits(value, varLongDepths[type]));
  }
305142
public <T extends Object> void writeValue(T value) throws IOException {
        writeValue(value, (Class<T>) value.getClass());
    }
423790
def write_int(self, value):
        """"""
        format = '!I'
        self.data.append(struct.pack(format, int(value)))
        self.size += 4
180314
private Object writeSimple(Class<?> declaredType, Object value) {
        Class<?> realType = value.getClass();
        if (realType == Integer.class || realType == Long.class || realType == Short.class ||
                realType == Byte.class || realType == Float.class || realType == Double.class ||
                realType == Boolean.class) {
            return value;
        } else {
            // write as a string
            try {
                String converted = settings.getConverter().convertToString(realType, value);
                if (converted == null) {
                    throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
                }
                return converted;
            } catch (RuntimeException ex) {
                throw new IllegalArgumentException(
                        "Unable to convert type " + declaredType.getName() + " for real type: " + realType.getName(), ex);
            }
        }
    }