Packageorg.granite.reflect
Classpublic class Field
InheritanceField Inheritance Member Inheritance DescribedElement
ImplementsIVisitableElement

A Field instance represents either a constant, a variable or an accessor (get/set), static or not, of a given ActionScript 3 class (only accessors for interfaces).

See also

Type.fields


Public Properties
 PropertyDefined by
 Inheritedannotations : Array
An array that contains all annotations directly attached to this IAnnotatedElement.
Member
 InheriteddeclaredBy : Type
The Type instance this described element belongs to.
DescribedElement
  name : String
[read-only] The name of this Field instance, ie.
Field
 Inheritedns : Namespace
The namespace of this Member.
Member
 InheritedpropertyKey : String
The String representation of this member (field or method qName, key of a dynamic property or dictionary, index of an array, etc.)
Member
 InheritedqName : QName
The qualified name of this Member.
Member
  type : Type
[read-only] The type of this Field instance, ie.
Field
  uri : String
[read-only] The namespace's uri of this field ("" for public fields).
Field
Public Methods
 MethodDefined by
  
Field(declaredBy:Type, desc:XML)
Constructs a new Field instance.
Field
 Inherited
equals(o:*):Boolean
Tells if this DescribedElement instance is equal to the supplied o parameter.
DescribedElement
  
getAnnotation(type:String, recursive:Boolean = false):Annotation
Returns the first Annotation whose name is equal to the supplied type parameter, attached to this IAnnotatedElement.
Field
  
getAnnotations(recursive:Boolean = false, pattern:String = "^_?[^_]"):Array
Returns an array (possibly empty) that contains all annotations attached to this IAnnotatedElement.
Field
  
getValue(instance:*):*
Returns the value of the field represented by this Field, on the specified instance.
Field
 Inherited
isAccessor():Boolean
Checks if this member is an accessor (get/set) field.
Member
  
isAnnotationPresent(type:String, recursive:Boolean = false):Boolean
Tests if an Annotation, whose name is equal to the supplied type parameter, is attached to this IAnnotatedElement.
Field
 Inherited
isConstant():Boolean
Checks if this member is a constant field.
Member
 Inherited
isConstructor():Boolean
Checks if this member is a constructor.
Member
 Inherited
Checks if this member is a dynamic property (always false for Member, always true for DynamicProperty).
Member
 Inherited
isInNamespace(ns:Namespace):Boolean
Tells if this Member instance is declared in the the suplied ns namespace parameter.
Member
 Inherited
isMethod():Boolean
Checks if this member is a method.
Member
 Inherited
isReadable():Boolean
Checks if this member is readable (fields only).
Member
 Inherited
isStatic():Boolean
Checks if this member is static.
Member
 Inherited
isVariable():Boolean
Checks if this member is a variable field.
Member
 Inherited
isWriteable():Boolean
Checks if this member is writeable (fields only).
Member
  
setValue(instance:*, value:*):void
Sets the field represented by this Field object on the specified instance argument to the specified new value.
Field
 Inherited
toString():String
Returns the a string (XML) representation of this described element.
DescribedElement
Property detail
nameproperty
name:String  [read-only]

The name of this Field instance, ie. the name of the underlying constant, variable or accessor.

Implementation
    public function get name():String
typeproperty 
type:Type  [read-only]

The type of this Field instance, ie. the type of the underlying constant, variable or accessor.

Implementation
    public function get type():Type
uriproperty 
uri:String  [read-only]

The namespace's uri of this field ("" for public fields).

Implementation
    public function get uri():String
Constructor detail
Field()constructor
public function Field(declaredBy:Type, desc:XML)

Constructs a new Field instance.

The declaredBy parameter is adjusted in order to match the actual type that declares this field, by introspecting superclasses (or superinterfaces for interface types). Hence, the returned value of the Field.declaredBy accessor may not return the declaredBy parameter value, but one of its superclasses.

Parameters
declaredBy:Type — the Type that declares this field.
 
desc:XML — the XML description of this annotation.
Method detail
getAnnotation()method
public override function getAnnotation(type:String, recursive:Boolean = false):Annotation

Returns the first Annotation whose name is equal to the supplied type parameter, attached to this IAnnotatedElement.

Parameters
type:String — the name of the annotation to look for.
 
recursive:Boolean (default = false) — should we look for annotations attached to overridden elements (non-static accessors or methods) or superclasses/superinterfaces ?

Returns
Annotation — an Annotation instance or null if it cannot be found.
getAnnotations()method 
public override function getAnnotations(recursive:Boolean = false, pattern:String = "^_?[^_]"):Array

Returns an array (possibly empty) that contains all annotations attached to this IAnnotatedElement.

Parameters
recursive:Boolean (default = false) — should we look for annotations attached to overridden elements (non-static accessors or methods) or superclasses/superinterfaces ?
 
pattern:String (default = "^_?[^_]") — a regexp expression used as a filter. Default is to eliminate all annotations prefixed with a double '_' character. You may use this parameter to find all annotations with a specific name.

Returns
Array — an array that contains all annotations attached to this IAnnotatedElement.
getValue()method 
public function getValue(instance:*):*

Returns the value of the field represented by this Field, on the specified instance.

Parameters
instance:* — object from which the represented field's value is to be extracted. This parameter may be null if this field represents a static member.

Returns
* — the value of the represented field in the instance parameter.

Throws
IllegalAccessError — if this field is not readable.
 
— if this field is an instance field and the supplied instance parameter is null, or if the instance parameter is not an instance of this field declaring class.
isAnnotationPresent()method 
public override function isAnnotationPresent(type:String, recursive:Boolean = false):Boolean

Tests if an Annotation, whose name is equal to the supplied type parameter, is attached to this IAnnotatedElement.

Parameters
type:String — the name of the annotation to look for.
 
recursive:Boolean (default = false) — should we look for annotations attached to overridden elements (non-static accessors or methods) or superclasses/superinterfaces ?

Returns
Booleantrue if the annotation can be found, false otherwise.
setValue()method 
public function setValue(instance:*, value:*):void

Sets the field represented by this Field object on the specified instance argument to the specified new value.

Parameters
instance:* — the object whose field should be modified. This parameter may be null if this field represents a static member.
 
value:* — the new value for the field of instance being modified.

Throws
IllegalAccessError — if this field is not writeable.
 
— if this field is an instance field and the supplied instance parameter is null, if the instance parameter is not an instance of this field declaring class, or if the supplied value cannot be converted to this field type.