コード例 #1
0
 /**
  * Looks up the given key in the given map, converting the result into a {@link Short}. First,
  * {@link #getNumber(Map,Object)} is invoked. If the result is null, then null is returned.
  * Otherwise, the short value of the resulting {@link Number} is returned.
  *
  * @param map the map whose value to look up
  * @param key the key whose value to look up in that map
  * @return a {@link Short} or null
  */
 public static Short getShort(Map map, Object key) {
   Number answer = getNumber(map, key);
   if (answer == null) {
     return null;
   } else if (answer instanceof Short) {
     return (Short) answer;
   }
   return new Short(answer.shortValue());
 }
コード例 #2
0
ファイル: DBR_CTRL_Short.java プロジェクト: epicsdeb/jca
 public void setUpperCtrlLimit(Number limit) {
   _ucl = new Short(limit.shortValue());
 }
コード例 #3
0
ファイル: DBR_CTRL_Short.java プロジェクト: epicsdeb/jca
 public void setLowerCtrlLimit(Number limit) {
   _lcl = new Short(limit.shortValue());
 }
コード例 #4
0
  /**
   * Helper method to try to call appropriate write method for given untyped Object. At this point,
   * no structural conversions should be done, only simple basic types are to be coerced as
   * necessary.
   *
   * @param value Non-null value to write
   */
  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 byte[]) {
      writeBinary((byte[]) value);
      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()
            + ")");
  }