Ejemplo n.º 1
0
 /**
  * Assert that the elements in two vectors are equal. If they are not, throw an
  * AssertionFailedError. The order of the elements is ignored.
  *
  * @param message the error message
  * @param expected the expected value of an vector
  * @param actual the actual value of an vector
  */
 protected void assertUnorderedElementsEqual(String message, Vector expected, Vector actual) {
   if (expected == actual) {
     return;
   }
   if (expected.size() != actual.size()) {
     this.assertTrue(this.notEqualsMessage(message, expected, actual), false);
   }
   Vector temp = (Vector) actual.clone();
   for (int i = 0; i < expected.size(); i++) {
     Object e1 = expected.elementAt(i);
     if (e1 == null) { // avoid null pointer exception
       if (!this.removeNullElement(temp)) {
         this.assertTrue(this.notEqualsMessage(message, expected, actual), false);
       }
     } else {
       if (!temp.removeElement(e1)) {
         this.assertTrue(this.notEqualsMessage(message, expected, actual), false);
       }
     }
   }
 }
 public void removeHPubReqCompleteListener(HPubReqCompleteListener listenerToRemove) {
   listenerList.removeElement(listenerToRemove);
 }
Ejemplo n.º 3
0
  /**
   * Sets the TabularData to the AaplicationTable
   *
   * @param data The TabularData to be set to the AaplicationTable
   */
  public void setAlarmTable(TabularData data) throws Exception {
    AgentException ae = null;

    for (Enumeration e = data.enumerate(); e.hasMoreElements(); ) {
      Object[] index = (Object[]) e.nextElement();
      CompositeData comp = data.getRow(index);

      if (table != null)
        entry =
            (AlarmEntry)
                Utilities.getEntryFromCompositeData(table, comp, indexNames, instrClassName);
      else if (vec != null)
        entry =
            (AlarmEntry) Utilities.getEntryFromCompositeData(vec, comp, indexNames, instrClassName);

      if (comp.getOperationType().equals(CompositeData.CREATED)) { // create new entry

        if (entry != null)
          throw new AgentException("Row already exist", CommonUtils.ROWCREATIONFAILED); // no i18n
        entry = new AlarmEntry();

        if (table != null) table.put(index, entry);
        else if (vec != null) vec.addElement(entry);
        for (Enumeration ce = comp.enumerate(); ce.hasMoreElements(); ) {
          String key = (String) ce.nextElement();
          try {
            Utilities.setField(entry, instrClassName, key, comp.getDataItem(key));
          } catch (AgentException aexp) {
            ae = aexp;
          }
        }
      } else if (comp.getOperationType().equals(CompositeData.DELETED)) {

        if (table != null) {
          for (Enumeration en = table.keys(); en.hasMoreElements(); ) {
            Object keyObject = en.nextElement();
            if (entry.equals(table.get(keyObject))) table.remove(keyObject);
          }
        } else if (vec != null)
          if (!vec.removeElement(entry))
            throw new AgentException("Invalid Index", CommonUtils.INVALIDINDEX); // no i18n
        data.deleteRow(index);
      } else if (comp.getOperationType().equals(CompositeData.MODIFIED)) {

        for (Enumeration ce = comp.enumerate(); ce.hasMoreElements(); ) {
          String key = (String) ce.nextElement();
          if (!comp.isModified(key)) continue;
          try {

            Utilities.setField(entry, instrClassName, key, comp.getDataItem(key));
          } catch (AgentException aexp) {
            ae = aexp;
          }
        }
      }

      comp.setOperationType(CompositeData.NOCHANGES);
    }

    if (ae != null) throw ae;
  }