Example #1
0
    /**
     * Config from field.
     *
     * @param field the field
     * @see
     *     org.jnetpcap.packet.structure.AnnotatedFieldMethod#configFromField(org.jnetpcap.packet.structure.AnnotatedField)
     */
    @Override
    public final void configFromField(AnnotatedField field) {

      switch (function) {
        case VALUE:
          if (method == null) {
            throw new HeaderDefinitionError(
                field.getDeclaringClass(),
                "no method set for field value getter [" + field.getName() + "]");
          }
          break;

        default:
          throw new HeaderDefinitionError(
              field.getDeclaringClass(), "Invalid Dynamic function type " + function.toString());
      }

      if (method == null) {
        throw new FieldDefinitionException(
            field,
            "Missing field accessor '"
                + function.name().toLowerCase()
                + "' property. [@Dynamic(Property."
                + function.name()
                + ")]");
      }
    }
Example #2
0
 private String emitTypefaceField(String className, AnnotatedField field) {
   return "    (("
       + className
       + ")target)."
       + field.getName()
       + ".setTypeface(manager.getTypeface(\""
       + field.getTypefaceName()
       + "\"));\n";
 }
Example #3
0
  /**
   * Check annotation.
   *
   * @param method the method
   * @param fields the fields
   */
  public static void checkAnnotation(Method method, List<AnnotatedField> fields) {

    Dynamic runtime = method.getAnnotation(Dynamic.class);

    if (runtime.field().length() != 0) {

      boolean found = false;
      final String name = runtime.field();
      for (AnnotatedField f : fields) {
        if (f.getName().equals(name)) {
          found = true;
          break;
        }
      }

      if (!found) {
        throw new HeaderDefinitionError("field name defined in annotation ");
      }
    }
  }
Example #4
0
  /**
   * Instantiates a new annotated field method.
   *
   * @param field the field
   * @param function the function
   * @param method the method
   */
  public AnnotatedFieldMethod(AnnotatedField field, Field.Property function, Method method) {
    super(method);
    this.function = function;

    this.field = field.getName();
  }