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());
    }
  }
Esempio n. 3
0
  public void execute() {
    validate();

    String val = value;
    if (val == null && ref != null) val = ref.getReferencedObject(project).toString();

    if (val == null)
      throw new BuildException("Either the 'Value' or 'Refid' attribute must be set.");

    StringTokenizer st = new StringTokenizer(val, delimiter);
    Vector vec = new Vector(st.countTokens());
    while (st.hasMoreTokens()) vec.addElement(st.nextToken());

    String propList[] = null;

    if (orderPropertyFile != null) {
      try {
        Vector sorted = sortByOrderPropertyFile(vec);
        propList = new String[sorted.size()];
        sorted.copyInto(propList);
      } catch (IOException e) {
        throw new BuildException(e);
      }
    } else {
      String s[] = (String[]) (vec.toArray(new String[vec.size()]));
      propList = new String[s.length];
      System.arraycopy(s, 0, propList, 0, s.length);
      mergeSort(s, propList, 0, s.length, casesensitive, numeric);
    }

    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < propList.length; i++) {
      if (i != 0) sb.append(delimiter);
      sb.append(propList[i]);
    }

    setPropertyValue(sb.toString());
  }