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.reflect.PackageMemberInfo; 18 import org.as2lib.env.reflect.MethodInfo; 19 import org.as2lib.env.reflect.TypeMemberFilter; 20 import org.as2lib.env.reflect.PackageInfo; 21 22 /** 23 * {@code TypeInfo} represents a type a ActionScript type, that is either a class 24 * or an interface. 25 * 26 * <p>Note that it is not possible right now to distinguish between classes and 27 * interfaces at run-time. Therefore are both classes and interfaces represented by 28 * {@link ClassInfo} instances. This is going to change as soon is a differentiation 29 * is possible. 30 * 31 * @author Simon Wacker 32 */ 33 interface org.as2lib.env.reflect.TypeInfo extends PackageMemberInfo { 34 35 /** 36 * Returns the type this instance represents. 37 * 38 * @return the type represented by this instance 39 */ 40 public function getType(Void):Function; 41 42 /** 43 * Returns the super type of this type. 44 * 45 * <p>Talking of classes the super-type is the class's super-class, that means the 46 * class it extends and with interfaces it is the interface's super-interface, that 47 * means the interface it extends. 48 * 49 * <p>A super-type is not an implemented interface. Note the difference between 50 * extending and implementing. 51 * 52 * @return the super types of this type 53 */ 54 public function getSuperType(Void):TypeInfo; 55 56 /** 57 * Returns the package this type is a member of. 58 * 59 * @return the package this type is a member of 60 */ 61 public function getPackage(Void):PackageInfo; 62 63 /** 64 * Returns whether this type or any super-type has a method with the passed-in 65 * {@code methodName}. 66 * 67 * <p>Static methods are not filtered by default. This means {@code filterStaticMethods} 68 * is by default set to {@code false}. 69 * 70 * @param methodName the name of the method to search for 71 * @param filterStaticMethods (optional) determines whether static methods are 72 * filtered, this means excluded from the search 73 * @return {@code true} if the method exists else {@code false} 74 */ 75 public function hasMethod(methodName:String, filterStaticMethods:Boolean):Boolean; 76 77 /** 78 * @overload #getMethodsByFlag 79 * @overload #getMethodsByFilter 80 */ 81 public function getMethods():Array; 82 83 /** 84 * Returns an array containing the methods represented by {@code MethodInfo} instances 85 * this type declares and maybe the ones of the super types. 86 * 87 * <p>The super types' methods are included if you pass-in {@code false}, {@code null} 88 * or {@code undefined} and excluded/filtered if you pass-in {@code true}. This means 89 * super-types are by default included. 90 * 91 * <p>Note that methods of interfaces cannot be evaluated at run-time. They thus 92 * have no methods for the Reflection API. 93 * 94 * @param filterSuperTypes (optional) determines whether to filter/exclude the super 95 * types' methods 96 * @return an array containing the methods represented by {@code MethodInfo} instances 97 */ 98 public function getMethodsByFlag(filterSuperTypes:Boolean):Array; 99 100 /** 101 * Returns an array containing the methods represented by {@code MethodInfo} instances 102 * this type and super types' declare that are not filtered/excluded. 103 * 104 * <p>The {@link TypeMemberFilter#filter} method of the passed-in {@code methodFilter} 105 * is invoked for every method to determine whether it shall be contained in the 106 * result. 107 * 108 * <p>If the passed-in {@code methodFilter} is {@code null} or {@code undefined} the 109 * result of an invocation of the {@link #getMethodsByFlag} method with argument 110 * {@code false} will be returned. 111 * 112 * <p>Note that methods of interfaces cannot be evaluated at run-time. They thus 113 * have no methods for the Reflection API. 114 * 115 * @param methodFilter the filter that filters unwanted methods out 116 * @return an array containing the remaining methods represented by {@code MethodInfo} 117 * instances 118 */ 119 public function getMethodsByFilter(methodFilter:TypeMemberFilter):Array; 120 121 /** 122 * @overload #getMethodByName 123 * @overload #getMethodByMethod 124 */ 125 public function getMethod():MethodInfo; 126 127 /** 128 * Returns the method info corresponding to the passed-in {@code methodName}. 129 * 130 * <p>{@code null} will be returned if: 131 * <ul> 132 * <li>The passed-in {@code methodName} is {@code null} or {@code undefined}.</li> 133 * <li>The method does not exist in the represented type or any super-type.</li> 134 * </ul> 135 * 136 * <p>Note that methods of interfaces cannot be evaluated at run-time. They thus 137 * have no methods for the Reflection API. 138 * 139 * @param methodName the name of the method you wanna obtain 140 * @return the method info correspoinding to the passed-in {@code methodName} 141 */ 142 public function getMethodByName(methodName:String):MethodInfo; 143 144 /** 145 * Returns the method info corresponding to the passed-in {@code concreteMethod}. 146 * 147 * <p>{@code null} will be returned if: 148 * <ul> 149 * <li>The passed-in {@code concreteMethod} is {@code null} or {@code undefined}.</li> 150 * <li>The method does not exist in the represented type or any super-type.</li> 151 * </ul> 152 * 153 * <p>Note that methods of interfaces cannot be evaluated at run-time. They thus 154 * have no methods for the Reflection API. 155 * 156 * @param concreteMethod the method you wanna obtain the corresponding method info 157 * for 158 * @return the method info correspoinding to the passed-in {@code concreteMethod} 159 */ 160 public function getMethodByMethod(concreteMethod:Function):MethodInfo; 161 162 }