Ejemplo n.º 1
0
 /**
  * Sets an integer field's value directly.
  *
  * <p>The field may also be an enumeration, in which case this method sets its underlying integer
  * definition's value.
  *
  * @param name Integer/enumeration field name
  * @param value Field value
  * @throws NoSuchFieldException If field doesn't exist
  */
 public void setIntFieldValue(String name, long value) throws NoSuchFieldException {
   IntegerDefinition fieldDef = this.lookupInteger(name);
   if (fieldDef == null) {
     throw new NoSuchFieldException(
         "Field \"" + name + "\" of this structure does not exist"); // $NON-NLS-1$ //$NON-NLS-2$
   }
   fieldDef.setValue(value);
 }
Ejemplo n.º 2
0
  /**
   * Gets an integer field's value directly.
   *
   * <p>The field may also be an enumeration, in which case its underlying integer definition's
   * value will be returned.
   *
   * @param name Integer/enumeration field name
   * @return Field value
   * @throws NoSuchFieldException If field doesn't exist
   */
  public long getIntFieldValue(String name) throws NoSuchFieldException {
    IntegerDefinition fieldDef = this.lookupInteger(name);
    if (fieldDef == null) {
      EnumDefinition enumDef = this.lookupEnum(name);
      if (enumDef == null) {
        throw new NoSuchFieldException(
            "Field \""
                + name
                + "\" of this structure is not an integer"); //$NON-NLS-1$ //$NON-NLS-2$
      }

      return enumDef.getIntegerValue();
    }

    return fieldDef.getValue();
  }