List of usage examples for java.io DataOutput writeUTF
void writeUTF(String s) throws IOException;
s
. From source file:org.apache.vxquery.runtime.functions.cast.CastToStringOperation.java
@Override public void convertDouble(DoublePointable doublep, DataOutput dOut) throws SystemException, IOException { abvsInner.reset();/*from w ww . j a va 2 s . c om*/ double value = doublep.getDouble(); if (Double.isInfinite(value)) { if (value == Double.NEGATIVE_INFINITY) { FunctionHelper.writeCharSequence("-", dOutInner); } FunctionHelper.writeCharSequence("INF", dOutInner); sendStringDataOutput(dOut); } else if (Double.isNaN(value)) { FunctionHelper.writeCharSequence("NaN", dOutInner); sendStringDataOutput(dOut); } else if (value == -0.0 || value == 0.0) { long bits = Double.doubleToLongBits(value); boolean negative = ((bits >> 63) == 0) ? false : true; if (negative) { FunctionHelper.writeChar('-', dOutInner); } FunctionHelper.writeCharSequence("0", dOutInner); sendStringDataOutput(dOut); } else if (Math.abs(value) >= 0.000001 && Math.abs(value) <= 10000000) { //the jdk (toString function) does not output number in desired format when //a number is between one and ten million, so we take care of this //case separately here. CastToDecimalOperation castToDecimal = new CastToDecimalOperation(); castToDecimal.convertDouble(doublep, dOutInner); XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable(); decp.set(abvsInner.getByteArray(), abvsInner.getStartOffset() + 1, XSDecimalPointable.TYPE_TRAITS.getFixedLength()); if (Math.abs(value) <= 1000000) { convertDecimal(decp, dOut); } else { decimalToScientificNotn(decp, dOut); } } else { dOut.write(returnTag); dOut.writeUTF(Double.toString(value)); } }