Exemplo n.º 1
0
  /**
   * Adds this object on the object bench. If you pass null as instanceName the object will have a
   * predefined name. If the object is not a valid one nothing will happen.
   *
   * @param instanceName The name you want this object to have on the bench.
   * @throws ProjectNotOpenException if the project to which this object belongs has been closed by
   *     the user.
   * @throws PackageNotFoundException if the package to which this object belongs has been deleted
   *     by the user.
   */
  public void addToBench(String instanceName)
      throws ProjectNotOpenException, PackageNotFoundException {
    if (objectWrapper == null) {
      return;
    }

    // Not rational to add a null object, is it ?
    if (objectWrapper.getObject().isNullObject()) {
      return;
    }

    // If you want you may set the instance name here. Otherwise accept default
    if (instanceName != null) {
      objectWrapper.setName(instanceName);
    }

    // This should really always exists, no need to check
    Package aPackage = wrapperId.getBluejPackage();
    PkgMgrFrame aFrame = wrapperId.getPackageFrame();

    ObjectBench aBench = aFrame.getObjectBench();
    aBench.addObject(objectWrapper);

    // load the object into runtime scope
    aPackage
        .getDebugger()
        .addObject(aPackage.getId(), objectWrapper.getName(), objectWrapper.getObject());
  }
Exemplo n.º 2
0
  /**
   * Constructor for BObject.
   *
   * @param aWrapper Description of the Parameter
   */
  BObject(ObjectWrapper aWrapper) {
    objectWrapper = aWrapper;

    Package bluejPkg = objectWrapper.getPackage();
    Project bluejProj = bluejPkg.getProject();

    // It really seems that the translation between Java naming and Class is needed.
    // Also tryng to get the Class instead of just the name is a mess...
    String className = transJavaToClass(objectWrapper.getClassName());

    wrapperId = new Identifier(bluejProj, bluejPkg, className);
  }
Exemplo n.º 3
0
 public ObjectWrapper getWrapper(Class clazz) {
   ObjectWrapper ret;
   String classname = clazz.getName();
   if (handlers != null && handlers.containsKey(classname)) ret = initWrapper(classname, clazz);
   else {
     if (Map.class.isAssignableFrom(clazz)) ret = new DefaultMapWrapper(clazz);
     else if (Collection.class.isAssignableFrom(clazz)) ret = new DefaultCollectionWrapper(clazz);
     else if (clazz.isArray()) ret = new ArrayWrapper(clazz);
     else if (ReflectionUtil.isSimpleType(clazz)) return new DefaultSimpleTypeWrapper(clazz);
     else if (clazz.isEnum()) ret = new EnumWrapper(clazz);
     else ret = new DefaultBeanWrapper(clazz);
   }
   ret.setYamlConfig(this);
   return ret;
 }
Exemplo n.º 4
0
  /**
   * Return the name of this object on the object bench.
   *
   * @return The instance name if the object can be put into bench, null othervise
   */
  public String getInstanceName() {
    if (objectWrapper == null) {
      return null;
    }

    return objectWrapper.getName();
  }
Exemplo n.º 5
0
  /**
   * Returns a string representation of the Object
   *
   * @return Description of the Return Value
   */
  public String toString() {
    String className = "";
    if (objectWrapper != null) {
      className = objectWrapper.getClassName();
    }

    return "BObject instanceName=" + getInstanceName() + " Class Name=" + className;
  }
Exemplo n.º 6
0
  /**
   * Used by BField to get hold of the real Object
   *
   * @return The objectReference value
   */
  ObjectReference getObjectReference() {
    if (objectWrapper == null) {
      return null;
    }
    DebuggerObject obj = objectWrapper.getObject();

    if (obj == null) {
      return null;
    }
    return obj.getObjectReference();
  }
Exemplo n.º 7
0
 public ObjectWrapper getWrapper(Object obj) {
   ObjectWrapper wrapper = getWrapper(obj.getClass());
   wrapper.setObject(obj);
   return wrapper;
 }
Exemplo n.º 8
0
 void install(String classname, Object wrapperSpec) {
   if (wrapperSpec instanceof ObjectWrapper) ((ObjectWrapper) wrapperSpec).setYamlConfig(this);
   if (!handlers.containsKey(classname)) handlers.put(classname, wrapperSpec);
 }