Class org.as2lib.env.reflect.PropertyInfo

org.as2lib.core.BasicClass
   +--org.as2lib.env.reflect.PropertyInfo

Implemented Interfaces

TypeMemberInfo

Description

PropertyInfo represents a property.

The term property means only properties added via Object.addProperty or the ones added with the get and set keywords, that are implicit getters and setters, not variables.

PropertyInfo instances for specific properties can be obtained using the methods ClassInfo#getProperties or ClassInfo#getProperty. That means you first have to get a class info for the class that declares or inherits the property. You can therefor use the ClassInfo#forObject, ClassInfo#forClass, ClassInfo#forInstance and ClassInfo#forName methods.

When you have obtained the property info you can use it to get information about the property. trace("Property name: " + propertyInfo.getName()); trace("Declaring type: " + propertyInfo.getDeclaringType().getFullName()); trace("Is Static?: " + propertyInfo.isStatic()); trace("Is Writable?: " + propertyInfo.isWritable()); trace("Is Readable?: " + propertyInfo.isReadable());

Method Index

new PropertyInfo()

getDeclaringType(), getFullName(), getGetter(), getName(), getSetter(), getStringifier(), isReadable(), isStatic(), isWritable(), setStringifier(), snapshot(), toString()

Constructor Detail

PropertyInfo

public function PropertyInfo(name:String, declaringType:TypeInfo, staticFlag:Boolean, setter:Function, getter:Function)

Constructs a new PropertyInfo instance.

All arguments are allowed to be null. But keep in mind that not all methods will function properly if one is.

If arguments setter or getter are not specified they will be resolved at run-time everytime asked for. Making use of this functionality you will always get the up-to-date setter or getter.

Parameters

namethe name of the property
declaringTypethe type declaring the property
staticFlagdetermines whether the property is static
setter(optional) the setter method of the property
getter(optional) the getter method of the property

Method Detail

getStringifier

static public function getStringifier(Void):Stringifier

Returns the stringifier used to stringify property infos.

If no custom stringifier has been set via the setStringifier method, an instance of the default PropertyInfoStringifier class is returned.

Return

the stringifier that stringifies property infos

setStringifier

static public function setStringifier(propertyInfoStringifier:PropertyInfoStringifier):Void

Sets the stringifier used to stringify property infos.

If propertyInfoStringifier is null or undefined the getStringifier method will return the default stringifier.

Parameters

propertyInfoStringifierthe stringifier that stringifies property infos

getName

public function getName(Void):String

Returns the name of this property.

If you want the getter or setter methods' name you must use the getName method of the getGetter or getSetter method respectively. The name of this getter or setter method is the prefix '__get__' or '__set__' plus the name of this property.

Return

the name of this property

getFullName

public function getFullName(Void):String

Returns the full name of this property.

The full name is the fully qualified name of the declaring type plus the name of this property.

Return

the full name of this property

Specified By

getFullName() in org.as2lib.env.reflect.TypeMemberInfo

getSetter

public function getSetter(Void):MethodInfo

Returns the setter method of this property.

The setter method of a property takes one argument, that is the new value that shall be assigned to the property. You can invoke it the same as every other method.

The name of this setter method is the prefix '__set__' plus the name of this property.

Property setter methods are also known under the name implicit setters.

Return

the setter method of this property

getGetter

public function getGetter(Void):MethodInfo

Returns the getter method of this property.

The getter method of a property takes no arguments, but returns the value of the property. You can invoke it the same as every other method.

The name of this getter method is the prefix '__get__' plus the name of this property.

Property getter methods are also known under the name implicit getters.

Return

the getter method of the property

getDeclaringType

public function getDeclaringType(Void):TypeInfo

Returns the type that declares this property.

At this time interfaces are not allowed to declare properties. The declaring type is thus allways an instance of type ClassInfo, a class.

Return

the type that declares this property

Specified By

getDeclaringType() in org.as2lib.env.reflect.TypeMemberInfo

isWritable

public function isWritable(Void):Boolean

Returns whether this property is writable.

This property is writable when its setter is not null.

Return

true if this property is writable else false

isReadable

public function isReadable(Void):Boolean

Returns whether this property is readable.

This property is readable when its getter is not null.

Return

true when this property is readable else false

isStatic

public function isStatic(Void):Boolean

Returns whether this property is static or not.

Static properties are properties per type.

Non-Static properties are properties per instance.

Return

true if this property is static else false

Specified By

isStatic() in org.as2lib.env.reflect.TypeMemberInfo

snapshot

public function snapshot(Void):PropertyInfo

Returns a property info that reflects the current state of this property info.

Return

a snapshot of this property info

toString

public function toString():String

Returns the string representation of this property.

The string representation is obtained via the stringifier returned by the static getStringifier method.

Return

the string representation of this property

Specified By

toString() in org.as2lib.core.BasicInterface

Overrides

toString() in org.as2lib.core.BasicClass