コード例 #1
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Encodes {@code value}.
  *
  * @param value a finite value. May not be {@link Double#isNaN() NaNs} or {@link
  *     Double#isInfinite() infinities}.
  * @return this writer.
  */
 public JsonWriter value(double value) throws IOException {
   if (Double.isNaN(value) || Double.isInfinite(value)) {
     throw new IllegalArgumentException("Numeric values must be finite, but was " + value);
   }
   beforeValue(false);
   out.append(Double.toString(value));
   return this;
 }
コード例 #2
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Encodes {@code value}.
  *
  * @param value the literal string value, or null to encode a null literal.
  * @return this writer.
  */
 public JsonWriter value(String value) throws IOException {
   if (value == null) {
     return nullValue();
   }
   beforeValue(false);
   string(value);
   return this;
 }
コード例 #3
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
  /**
   * Encodes {@code value}.
   *
   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or {@link
   *     Double#isInfinite() infinities}.
   * @return this writer.
   */
  public JsonWriter value(Number value) throws IOException {
    if (value == null) {
      return nullValue();
    }

    String string = value.toString();
    if (!lenient
        && (string.equals("-Infinity") || string.equals("Infinity") || string.equals("NaN"))) {
      throw new IllegalArgumentException("Numeric values must be finite, but was " + value);
    }
    beforeValue(false);
    out.append(string);
    return this;
  }
コード例 #4
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Encodes {@code value}.
  *
  * @return this writer.
  */
 public JsonWriter value(long value) throws IOException {
   beforeValue(false);
   out.write(Long.toString(value));
   return this;
 }
コード例 #5
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Encodes {@code value}.
  *
  * @return this writer.
  */
 public JsonWriter value(boolean value) throws IOException {
   beforeValue(false);
   out.write(value ? "true" : "false");
   return this;
 }
コード例 #6
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Writes {@code value} literally
  *
  * @return this writer.
  */
 public JsonWriter value(JsonLiteral value) throws IOException {
   beforeValue(false);
   out.write(value.toString());
   return this;
 }
コード例 #7
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /**
  * Encodes {@code null}.
  *
  * @return this writer.
  */
 public JsonWriter nullValue() throws IOException {
   beforeValue(false);
   out.write("null");
   return this;
 }
コード例 #8
0
ファイル: JsonWriter.java プロジェクト: sangmin/jclouds
 /** Enters a new scope by appending any necessary whitespace and the given bracket. */
 private JsonWriter open(JsonScope empty, String openBracket) throws IOException {
   beforeValue(true);
   stack.add(empty);
   out.write(openBracket);
   return this;
 }