write simple type
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);
            }
        }
    }
1278946
function write_bstr_type(out, opts) {
	switch(opts.type) {
		case "base64": return Base64.encode(out);
		case "binary": return out;
		case "file": return _fs.writeFileSync(opts.file, out, 'binary');
		case "buffer": {
			if(has_buf) return new Buffer(out, 'utf8');
			else return out.split("").map(function(c) { return c.charCodeAt(0); });
		}
	}
	throw new Error("Unrecognized type " + opts.type);
}
611395
function write(s) {
		var err
		var args = Array.prototype.slice.call(arguments)
		var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
		var cbCounter = 1
		if (writeToStdoutEnabled) {
			cbCounter++
			process.stdout.write(s, stdWr)
		}
		if (writeStream) {
			cbCounter++
			writeStream.write(s, wRes)
		}
		end()

		function stdWr(e) {
			if (e) {
				if (!err) err = e
				writeToStdoutEnabled = false
				write('stdout error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function wRes(e) {
			if (e) {
				if (!err) err = e
				writeStream = false
				write('stream error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function end() {
			if (!--cbCounter)
				if (cb)
					if (err) cb(err)
					else cb()
		}
	}
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());
        }
171902
def write_string(self, value, length):
        """"""
        format = '!' + str(length) + 's'
        self.data.append(struct.pack(format, value))
        self.size += length
797296
def _cast_output_to_type(value, typ):
    ''''''
    if typ == 'b':
        return bool(value)
    if typ == 'i':
        return int(value)
    return value
1259934
protected void write(BufferedWriter out, String type, byte[] data) throws IOException
    {
        writeHeader(out, type);
        out.write(this.base64.encode(data, 64));
        out.newLine();
        writeFooter(out, type);
    }
256653
private void writeSimple(String currentIndent, String tagName, StringBuilder attrs, Class<?> declaredType, Object value) throws IOException {
        Class<?> effectiveType;
        if (declaredType == Object.class) {
            Class<?> realType = value.getClass();
            if (realType != String.class) {
                effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
                String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
                appendAttribute(attrs, TYPE, typeStr);
            } else {
                effectiveType = realType;
            }
        } else if (settings.getConverter().isConvertible(declaredType) == false) {
            effectiveType = settings.getConverter().findTypedConverter(value.getClass()).getEffectiveType();
            String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
            appendAttribute(attrs, TYPE, typeStr);
        } else {
            effectiveType = declaredType;
        }
        try {
            String converted = settings.getConverter().convertToString(effectiveType, value);
            if (converted == null) {
                throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
            }
            output.append(currentIndent).append('<').append(tagName).append(attrs).append('>');
            appendEncoded(converted);
            output.append('<').append('/').append(tagName).append('>').append(settings.getNewLine());
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
        }
    }
901840
def write_short(self, number):
        
        buf = pack(self.byte_order + "h", number)
        self.write(buf)
776811
def write(self,
        fout=None,
        fmt=SPARSE,
        schema_only=False,
        data_only=False):
        
        assert not (schema_only and data_only), 'Make up your mind.'
        assert fmt in FORMATS, 'Invalid format "%s". Should be one of: %s' % (fmt, ', '.join(FORMATS))
        close = False
        if fout is None:
            close = True
            fout = StringIO()
        if not data_only:
            print('% ' + re.sub("\n", "\n% ", '\n'.join(self.comment)), file=fout)
            print("@relation " + self.relation, file=fout)
            self.write_attributes(fout=fout)
        if not schema_only:
            print("@data", file=fout)
            for d in self.data:
                line_str = self.write_line(d, fmt=fmt)
                if line_str:
                    print(line_str, file=fout)
        if isinstance(fout, StringIO) and close:
            return fout.getvalue()
423790
def write_int(self, value):
        """"""
        format = '!I'
        self.data.append(struct.pack(format, int(value)))
        self.size += 4
286815
def _is_simple_type(value):
    '''
    
    '''
    return isinstance(value, six.string_types) or isinstance(value, int) or isinstance(value, float) or isinstance(value, bool)
446643
public void writeMapBegin(String type)
        throws IOException
    {
        if (SIZE < _offset + 32)
            flushBuffer();

        if (type != null) {
            _buffer[_offset++] = BC_MAP;

            writeType(type);
        }
        else
            _buffer[_offset++] = BC_MAP_UNTYPED;
    }
1276594
def _write_property(self, val, *args):
        """"""
        val_wid = val
        # 'finally' would be better here, but not supported in 2.4 :(
        try:
            totype = type(self._get_property(*args))
            if (totype is not type(None) and
                   (self._prop_cast or not self._prop_write)):
                val = self._cast_value(val, totype)

            if self._prop_write:
                val = self._prop_write(val)

            self._itsme = True
            self._set_property(val, *args)

        except ValueError:
            self._itsme = False
            if self._value_error:
                self._value_error(self, self._prop_name, val_wid)
            else:
                raise

        except:
            self._itsme = False
            raise

        self._itsme = False
1260587
protected void writeNull(Type type) {

        if (logMode == MODE_DELETE) {
            write(BYTES_IS);
        } else if (isWritten) {
            write(',');
        }

        isWritten = true;

        write(BYTES_NULL);
    }
1248429
protected static boolean writeCustomType(Output out, Object obj) {
        if (out.isCustom(obj)) {
            // Write custom data
            out.writeCustom(obj);
            return true;
        } else {
            return false;
        }
    }
989286
private void writeODataType(StructuredType structuredType) throws IOException {
        if (entitySet != null) {
            String typeName = entitySet.getTypeName();
            String type = typeName.substring(typeName.lastIndexOf(".") + 1, typeName.length());

            if (!type.equals(structuredType.getName())) {
                jsonGenerator.writeStringField(TYPE, String.format("#%s.%s",
                        structuredType.getNamespace(), structuredType.getName()));
            } else {
                LOG.trace("{} has root level. {} won't be written here", entitySet.getName(), TYPE);
            }
        }
    }