コード例 #1
0
ファイル: HoolaiProxy.java プロジェクト: whg333/iTool
  public Object createInstance(String className, Class desiredClass) {
    Object instance;

    if (className == null || className.length() == 0) {
      instance = new ASObject();
    } else if (className.startsWith(">")) // Handle [RemoteClass] (no server alias)
    {
      instance = new ASObject();
      ((ASObject) instance).setType(className);
    } else {
      SerializationContext context = getSerializationContext();
      if ((context.instantiateTypes || className.startsWith("flex."))
          && className.indexOf("activity") == -1) {
        instance = ClassUtil.createDefaultInstance(desiredClass, null);
        //            	instance = createInstanceFromClassName(className);
      } else {
        // Just return type info with an ASObject...
        instance = new ASObject();
        ((ASObject) instance).setType(className);
      }
    }
    return instance;
  }
コード例 #2
0
 /**
  * Creates the default instance of the class and verifies that it matches with the expected class
  * type, if one passed in.
  *
  * @param cls The class to create.
  * @param expectedInstance The expected class type.
  * @return The default instance of the class.
  */
 public static Object createDefaultInstance(Class cls, Class expectedInstance) {
   return ClassUtil.createDefaultInstance(cls, expectedInstance, false /*validate*/);
 }