Пример #1
0
  /**
   * Return the value of a simple property with the specified name.
   *
   * @param name Name of the property whose value is to be retrieved
   * @exception IllegalArgumentException if there is no property of the specified name
   */
  public Object get(String name) {

    if (!dynaClass.isReadable(name)) {
      return null;
    }
    Object value = null;
    try {
      value = PropertyUtils.getSimpleProperty(instance, name);
    } catch (Throwable t) {
      throw new RuntimeException("Failed getting property " + name, t);
    }
    return (value);
  }
Пример #2
0
  /**
   * Return the value of a mapped property with the specified name, or <code>null</code> if there is
   * no value for the specified key.
   *
   * @param name Name of the property whose value is to be retrieved
   * @param key Key of the value to be retrieved
   * @exception IllegalArgumentException if there is no property of the specified name
   * @exception IllegalArgumentException if the specified property exists, but is not mapped
   */
  public Object get(String name, String key) {

    if (!dynaClass.isReadable(name)) {
      return null;
    }

    Object value = null;
    try {
      value = PropertyUtils.getMappedProperty(instance, name, key);
    } catch (Throwable t) {
      throw new IllegalArgumentException("Property '" + name + "' has no mapped read method");
    }
    return (value);
  }
Пример #3
0
  /**
   * Return the value of an indexed property with the specified name.
   *
   * @param name Name of the property whose value is to be retrieved
   * @param index Index of the value to be retrieved
   * @exception IllegalArgumentException if there is no property of the specified name
   * @exception IllegalArgumentException if the specified property exists, but is not indexed
   * @exception IndexOutOfBoundsException if the specified index is outside the range of the
   *     underlying property
   * @exception NullPointerException if no array or List has been initialized for this property
   */
  public Object get(String name, int index) {

    if (!dynaClass.isReadable(name)) {
      return null;
    }

    Object value = null;
    try {
      value = PropertyUtils.getIndexedProperty(instance, name, index);
    } catch (IndexOutOfBoundsException e) {
      throw e;
    } catch (Throwable t) {
      throw new IllegalArgumentException("Property '" + name + "' has no indexed read method");
    }
    return (value);
  }