1  /*
     2   * Copyright the original author or authors.
     3   * 
     4   * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   * 
     8   *      http://www.mozilla.org/MPL/MPL-1.1.html
     9   * 
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import org.as2lib.env.except.IllegalArgumentException;
    18  import org.as2lib.env.reflect.PropertyInfo;
    19  import org.as2lib.aop.joinpoint.PropertyJoinPoint;
    20  
    21  /**
    22   * {@code GetPropertyJoinPoint} is a join point matching get access to a property. It
    23   * represents the getter method of a property.
    24   * 
    25   * @author Simon Wacker
    26   */
    27  class org.as2lib.aop.joinpoint.GetPropertyJoinPoint extends PropertyJoinPoint {
    28  	
    29  	/**
    30  	 * Constructs a new {@code GetPropertyJoinPoint) instance.
    31  	 * 
    32  	 * @param info the property info of the represented property
    33  	 * @param thiz the logical this of the interception
    34  	 * @throws IllegalArgumentException if argument {@code info} is {@code null} or
    35  	 * {@code undefined}
    36  	 * @throws IllegalArgumentException if argument {@code info} reflects a not-readable
    37  	 * property
    38  	 * @see <a href="http://www.simonwacker.com/blog/archives/000068.php">Passing Context</a>
    39  	 */
    40  	public function GetPropertyJoinPoint(info:PropertyInfo, thiz) {
    41  		super(info, thiz);
    42  		if (!info.isReadable()) {
    43  			throw new IllegalArgumentException("Argument 'info' [" + info + "] reflects a not-readable property. Get access is not possible for this kind of property.", this, arguments);
    44  		}
    45  	}
    46  	
    47  	/**
    48  	 * Proceeds this join point by executing the getter of the represented property
    49  	 * with the given arguments and returning the result of the execution.
    50  	 * 
    51  	 * @param args the arguments to use for the execution
    52  	 * @return the result of the execution
    53  	 */
    54  	public function proceed(args:Array) {
    55  		return proceedMethod(this.info.getGetter(), args);
    56  	}
    57  	
    58  	/**
    59  	 * Returns the type of this property.
    60  	 * 
    61  	 * @return {@link AbstractJoinPoint#GET_PROPERTY}
    62  	 */
    63  	public function getType(Void):Number {
    64  		return GET_PROPERTY;
    65  	}
    66  	
    67  }