Write the bits corresponding to a symbol. The weight of the symbol will
be incremented.

@param value
The number of the symbol to write
@param bitwriter
The destination of the bits.
@throws JSONException
775518
public void write(int value, BitWriter bitwriter) throws JSONException {
        this.width = 0;
        write(this.symbols[value], bitwriter);
        tick(value);
        if (JSONzip.probe) {
            JSONzip.logchar(value, this.width);
        }
    }
432796
private void write(Kim kim, Huff huff, Huff ext) throws JSONException {
        for (int at = 0; at < kim.length; at += 1) {
            int c = kim.get(at);
            write(c, huff);
            while ((c & 128) == 128) {
                at += 1;
                c = kim.get(at);
                write(c, ext);
            }
        }
    }
815692
public JsonWriter value(String value) throws IOException {
        if (value == null) {
            return nullValue();
        }
        beforeValue(false);
        string(value);
        return this;
    }
30850
public JsonWriter value(Boolean value) throws IOException {
    if (value == null) {
      return nullValue();
    }
    writeDeferredName();
    beforeValue();
    out.write(value ? "true" : "false");
    return this;
  }
1318865
void write(Object value) throws IOException {
    if (clientInputSerializer != null) {
      clientInputSerializer.serialize(value);
      return;
    }

    byte[] bval;
    int valSize;
    if (value instanceof BytesWritable) {
      BytesWritable val = (BytesWritable) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else if (value instanceof Text) {
      Text val = (Text) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else {
      String sval = value.toString();
      bval = sval.getBytes("UTF-8");
      valSize = bval.length;
    }
    clientOut_.write(bval, 0, valSize);
  }
893874
public void writeStringLenenc(final String value) {
        if (Strings.isNullOrEmpty(value)) {
            byteBuf.writeByte(0);
            return;
        }
        writeIntLenenc(value.getBytes().length);
        byteBuf.writeBytes(value.getBytes());
    }
1119840
public void write(int bits, int width) throws IOException {
        if (bits == 0 && width == 0) {
            return;
        }
        if (width <= 0 || width > 32) {
            throw new IOException("Bad write width.");
        }
        while (width > 0) {
            int actual = width;
            if (actual > this.vacant) {
                actual = this.vacant;
            }
            this.unwritten |= ((bits >>> (width - actual)) &
                    ((1 << actual) - 1)) << (this.vacant - actual);
            width -= actual;
            nrBits += actual;
            this.vacant -= actual;
            if (this.vacant == 0) {
                this.out.write(this.unwritten);
                this.unwritten = 0;
                this.vacant = 8;
            }
        }
    }
1291375
protected void _writeSimpleObject(Object value) throws IOException, JsonGenerationException {
	    /* 31-Dec-2009, tatu: Actually, we could just handle some basic
	     *    types even without codec. This can improve interoperability,
	     *    and specifically help with TokenBuffer.
	     */
	    if (value == null) {
	        writeNull();
	        return;
	    }
	    if (value instanceof String) {
	        writeString((String) value);
	        return;
	    }
	    if (value instanceof Number) {
	        Number n = (Number) value;
	        if (n instanceof Integer) {
	            writeNumber(n.intValue());
	            return;
	        } else if (n instanceof Long) {
	            writeNumber(n.longValue());
	            return;
	        } else if (n instanceof Double) {
	            writeNumber(n.doubleValue());
	            return;
	        } else if (n instanceof Float) {
	            writeNumber(n.floatValue());
	            return;
	        } else if (n instanceof Short) {
	            writeNumber(n.shortValue());
	            return;
	        } else if (n instanceof Byte) {
	            writeNumber(n.byteValue());
	            return;
	        } else if (n instanceof BigInteger) {
	            writeNumber((BigInteger) n);
	            return;
	        } else if (n instanceof BigDecimal) {
	            writeNumber((BigDecimal) n);
	            return;
	            
	        // then Atomic types
	            
	        } else if (n instanceof AtomicInteger) {
	            writeNumber(((AtomicInteger) n).get());
	            return;
	        } else if (n instanceof AtomicLong) {
	            writeNumber(((AtomicLong) n).get());
	            return;
	        }
	    } else if (value instanceof Boolean) {
	        writeBoolean(((Boolean) value).booleanValue());
	        return;
	    } else if (value instanceof AtomicBoolean) {
	        writeBoolean(((AtomicBoolean) value).get());
	        return;
	    }
	    throw new IllegalStateException("No ObjectCodec defined for the generator, can only serialize simple wrapper types (type passed "
	            +value.getClass().getName()+")");
	}
242577
public JsonWriter value(Object value) throws IOException {
      Preconditions.checkArgument(inArray() || writeStack.peek() == JsonTokenType.NAME,
                                  "Expecting an array or a name, but found " + writeStack.peek());
      writeObject(value);
      popIf(JsonTokenType.NAME);
      return this;
   }
627453
@Override
    protected void write(JsonGenerator g, JacksonJrsTreeCodec codec) throws IOException
    {
        switch (numberType()) {
        case INT:
            g.writeNumber(_value.intValue());
            break;
        case LONG:
            g.writeNumber(_value.longValue());
            break;
        case BIG_INTEGER:
            g.writeNumber((BigInteger) _value);
            break;
        case FLOAT:
            g.writeNumber(_value.floatValue());
            break;
        case BIG_DECIMAL:
            g.writeNumber((BigDecimal) _value);
            break;
        case DOUBLE:
        default:
            g.writeNumber(_value.doubleValue());
            break;
        }
    }
1332526
@Override
  public void write(JsonWriter out, MarkTiming markTiming) throws IOException {
    out.beginArray();

    out.value(markTiming.getMark());
    out.value(markTiming.getTime());

    out.endArray();
    out.flush();
  }
525423
@Override 
  public void write(JsonWriterImpl out, Enum<?> value)
  {
    out.write(value.name());
  }
1064146
private void write(JSONObject jsonobject) throws JSONException {

// JSONzip has two encodings for objects: Empty Objects (zipEmptyObject) and
// non-empty objects (zipObject).

        boolean first = true;
        Iterator<String> keys = jsonobject.keys();
        while (keys.hasNext()) {
            if (probe) {
                log();
            }
            Object key = keys.next();
            if (key instanceof String) {
                if (first) {
                    first = false;
                    write(zipObject, 3);
                } else {
                    one();
                }
                writeName((String) key);
                Object value = jsonobject.get((String) key);
                if (value instanceof String) {
                    zero();
                    writeString((String) value);
                } else {
                    one();
                    writeValue(value);
                }
            }
        }
        if (first) {
            write(zipEmptyObject, 3);
        } else {
            zero();
        }
    }
611273
final void writeInt(int value)
    {
        byte writeBuffer[] = new byte[4];
        writeBuffer[0] = (byte) (value >>> 24);
        writeBuffer[1] = (byte) (value >>> 16);
        writeBuffer[2] = (byte) (value >>> 8);
        writeBuffer[3] = (byte) (value >>> 0);
        write(writeBuffer, 0, 4);
    }
450792
void writeString(String value) throws IOException {
        output.append('"');
        for (int i = 0; i < value.length(); i++) {
            char ch = value.charAt(i);
            if (ch < 128) {
                String replace = REPLACE[ch];
                if (replace != null) {
                    output.append(replace);
                } else {
                    output.append(ch);
                }
            } else if (ch == '\u2028') {
                output.append("\\u2028");  // match other JSON writers
            } else if (ch == '\u2029') {
                output.append("\\u2029");  // match other JSON writers
            } else {
                output.append(ch);
            }
        }
        output.append('"');
    }
1317325
public JsonWriter value(double value) {
        startValue();

        final long i = (long) value;
        if (value == (double) i) {
            writer.print(i);
        } else {
            writer.print(value);
        }
        return this;
    }
512818
public <T extends Enum<T>> void write(final Enum<T> value) throws IOException {
    final long ordinal = value.ordinal();
    this.write(new Bits(ordinal, 8));
  }