Пример #1
0
  /**
   * Indicates if have to add class name to get the stored value in {@link ByteArray}
   *
   * @param type Type to read
   * @return {@code true} if have to add class name to get the stored value in {@link ByteArray}
   */
  private static boolean needClassAsReadParameter(final Class<?> type) {
    if (type.isPrimitive() == true) {
      return false;
    }

    if (type.isEnum() == true) {
      return true;
    }

    if (Reflector.isInherit(type, String.class) == true) {
      return false;
    }

    if (Reflector.isInherit(type, Binarizable.class) == true) {
      return true;
    }

    if (type.isArray() == false) {
      return false;
    }

    return JHelpIDL.needClassAsReadParameter(type.getComponentType());
  }
Пример #2
0
  /**
   * Obtain read or write method ending to read a value in {@link ByteArray}
   *
   * @param type Type to read
   * @return Read or write extention
   */
  private static String obtainEndByteArrayMethodName(final Class<?> type) {
    if (type.isPrimitive() == true) {
      final String name = type.getName();

      if (Reflector.PRIMITIVE_BOOLEAN.equals(name) == true) {
        return "Boolean";
      }

      if (Reflector.PRIMITIVE_BYTE.equals(name) == true) {
        return "Byte";
      }

      if (Reflector.PRIMITIVE_CHAR.equals(name) == true) {
        return "Char";
      }

      if (Reflector.PRIMITIVE_DOUBLE.equals(name) == true) {
        return "Double";
      }

      if (Reflector.PRIMITIVE_FLOAT.equals(name) == true) {
        return "Float";
      }

      if (Reflector.PRIMITIVE_INT.equals(name) == true) {
        return "Integer";
      }

      if (Reflector.PRIMITIVE_LONG.equals(name) == true) {
        return "Long";
      }

      if (Reflector.PRIMITIVE_SHORT.equals(name) == true) {
        return "Short";
      }

      return null;
    }

    if (type.isEnum() == true) {
      return "Enum";
    }

    if (Reflector.isInherit(type, String.class) == true) {
      return "String";
    }

    if (Reflector.isInherit(type, Binarizable.class) == true) {
      return "Binarizable";
    }

    if (type.isArray() == false) {
      return null;
    }

    final String name = JHelpIDL.obtainEndByteArrayMethodName(type.getComponentType());

    if (name == null) {
      return null;
    }

    return name + "Array";
  }