Esempio n. 1
0
 public void setRefid(Reference r) {
   Object o = r.getReferencedObject();
   if (!(o instanceof ResourceCollection)) {
     throw new BuildException(r.getRefId() + " doesn\'t denote a ResourceCollection");
   }
   rc = (ResourceCollection) o;
 }
  /**
   * @return true if the reference exists and if type is set, if the reference is the same type
   * @exception BuildException if an error occurs
   */
  public boolean eval() throws BuildException {
    if (ref == null) {
      throw new BuildException("No reference specified for isreference " + "condition");
    }

    String key = ref.getRefId();
    if (!getProject().hasReference(key)) {
      return false;
    } else if (type == null) {
      return true;
    } else {
      Object o = getProject().getReference(key);
      Class typeClass = (Class) getProject().getDataTypeDefinitions().get(type);

      if (typeClass == null) {
        typeClass = (Class) getProject().getTaskDefinitions().get(type);
      }

      if (typeClass == null) {
        // don't know the type, should throw exception instead?
        return false;
      }

      return typeClass.isAssignableFrom(o.getClass());
    }
  }