Java Code Examples for java.util.Vector.removeElement()

The following are Jave code examples for showing how to use removeElement() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: parabuild-ci   File: ServletUnitTest.java   View Source Code Vote up 7 votes
protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
    Vector expectedItems = new Vector();
    Vector foundItems    = new Vector();

    for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[i] );
    for (int i = 0; i < found.length; i++) foundItems.addElement( found[i] );

    for (int i = 0; i < expected.length; i++) {
        if (!foundItems.contains( expected[i] )) {
            fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
        } else {
            foundItems.removeElement( expected[i] );
        }
    }

    for (int i = 0; i < found.length; i++) {
        if (!expectedItems.contains( found[i] )) {
            fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
        } else {
            expectedItems.removeElement( found[i] );
        }
    }

    if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
}
 
Example 2
Project: parabuild-ci   File: HttpUserAgentTest.java   View Source Code Vote up 7 votes
public static void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
    Vector foundItems = new Vector();
    for (int i = 0; i < found.length; i++) foundItems.addElement( found[ i ] );

    Vector expectedItems = new Vector();

    for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[ i ] );

    for (int i = 0; i < expected.length; i++) {
        if (!foundItems.contains( expected[ i ] )) {
            fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
        } else {
            foundItems.removeElement( expected[ i ] );
        }
    }

    for (int i = 0; i < found.length; i++) {
        if (!expectedItems.contains( found[ i ] )) {
            fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
        } else {
            expectedItems.removeElement( found[ i ] );
        }
    }

    if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) );
}
 
Example 3
Project: jdk8u-jdk   File: UIManager.java   View Source Code Vote up 7 votes
/**
 * Removes a <code>LookAndFeel</code> from the list of auxiliary look and feels.
 * The auxiliary look and feels tell the multiplexing look and feel what
 * other <code>LookAndFeel</code> classes for a component instance are to be used
 * in addition to the default <code>LookAndFeel</code> class when creating a
 * multiplexing UI.  The change will only take effect when a new
 * UI class is created or when the default look and feel is changed
 * on a component instance.
 * <p>Note these are not the same as the installed look and feels.
 * @return true if the <code>LookAndFeel</code> was removed from the list
 * @see #removeAuxiliaryLookAndFeel
 * @see #getAuxiliaryLookAndFeels
 * @see #setLookAndFeel
 * @see #getInstalledLookAndFeels
 */
static public boolean removeAuxiliaryLookAndFeel(LookAndFeel laf) {
    maybeInitialize();

    boolean result;

    Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
    if ((v == null) || (v.size() == 0)) {
        return false;
    }

    result = v.removeElement(laf);
    if (result) {
        if (v.size() == 0) {
            getLAFState().auxLookAndFeels = null;
            getLAFState().multiLookAndFeel = null;
        } else {
            getLAFState().auxLookAndFeels = v;
        }
    }
    laf.uninitialize();

    return result;
}
 
Example 4
Project: openjdk-jdk10   File: UIManager.java   View Source Code Vote up 6 votes
/**
 * Removes a <code>LookAndFeel</code> from the list of auxiliary look and feels.
 * The auxiliary look and feels tell the multiplexing look and feel what
 * other <code>LookAndFeel</code> classes for a component instance are to be used
 * in addition to the default <code>LookAndFeel</code> class when creating a
 * multiplexing UI.  The change will only take effect when a new
 * UI class is created or when the default look and feel is changed
 * on a component instance.
 * <p>Note these are not the same as the installed look and feels.
 *
 * @param laf the {@code LookAndFeel} to be removed
 * @return true if the <code>LookAndFeel</code> was removed from the list
 * @see #removeAuxiliaryLookAndFeel
 * @see #getAuxiliaryLookAndFeels
 * @see #setLookAndFeel
 * @see #getInstalledLookAndFeels
 */
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf) {
    maybeInitialize();

    boolean result;

    Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
    if ((v == null) || (v.size() == 0)) {
        return false;
    }

    result = v.removeElement(laf);
    if (result) {
        if (v.size() == 0) {
            getLAFState().auxLookAndFeels = null;
            getLAFState().multiLookAndFeel = null;
        } else {
            getLAFState().auxLookAndFeels = v;
        }
    }
    laf.uninitialize();

    return result;
}
 
Example 5
Project: gate-core   File: RelationSet.java   View Source Code Vote up 6 votes
public synchronized void removeRelationSetListener(RelationSetListener l) {
  if(listeners != null && listeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<RelationSetListener> v =
            (Vector<RelationSetListener>)listeners.clone();
    v.removeElement(l);
    listeners = v;
  }
}
 
Example 6
Project: gate-core   File: Factory.java   View Source Code Vote up 6 votes
public synchronized void removeCreoleListener(CreoleListener l) {
  if(creoleListeners != null && creoleListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<CreoleListener> v =
            (Vector<CreoleListener>)creoleListeners.clone();
    v.removeElement(l);
    creoleListeners = v;
  }// if
}
 
Example 7
Project: gate-core   File: SerialDataStore.java   View Source Code Vote up 6 votes
@Override
public synchronized void removeDatastoreListener(DatastoreListener l) {
  if (datastoreListeners != null && datastoreListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<DatastoreListener> v = (Vector<DatastoreListener>) datastoreListeners.clone();
    v.removeElement(l);
    datastoreListeners = v;
  }
}
 
Example 8
Project: gate-core   File: SerialControllerEditor.java   View Source Code Vote up 6 votes
public synchronized void removeStatusListener(StatusListener l) {
  if (statusListeners != null && statusListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<StatusListener> v = (Vector<StatusListener>) statusListeners.clone();
    v.removeElement(l);
    statusListeners = v;
  }
}
 
Example 9
Project: gate-core   File: AnnotationSetImpl.java   View Source Code Vote up 6 votes
@Override
public synchronized void removeAnnotationSetListener(AnnotationSetListener l) {
  if(annotationSetListeners != null && annotationSetListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<AnnotationSetListener> v = (Vector<AnnotationSetListener>)annotationSetListeners.clone();
    v.removeElement(l);
    annotationSetListeners = v;
  }
}
 
Example 10
Project: MARF-for-Android   File: Rule.java   View Source Code Vote up 6 votes
/**
 * Function that computes the first set of the right hand side of the current
 * grammar rule.
 *
 * @param poEpsilon what to consider a termination element
 * @return a collection of the elements in the first set
 */
public Vector getRHSFirstSet(final GrammarElement poEpsilon) {
    Vector oFirstSet = new Vector();

    boolean bAllEpsilon = true;

    //GrammarElement rhsElemOfProduction = null;

    for (int j = 0; j < oRHS.size() && bAllEpsilon; j++) {
        // Add the first set of each rhs elem to the set (as long as all the
        // previous ones contained epsilon).
        GrammarElement oProdElement = (GrammarElement) oRHS.elementAt(j);

        // Skip semantic tokens here
        if (oProdElement.isNonTerminal() == false && oProdElement.isTerminal() == false) {
            continue;
        }

        Vector oNextFirstSet = (Vector) oProdElement.getFirstSet().clone();

        for (int f = 0; f < oNextFirstSet.size(); f++) {
            Terminal oTerminal = (Terminal) oNextFirstSet.elementAt(f);
            oFirstSet.addElement(oTerminal);
        }

        if (oFirstSet.contains(poEpsilon)) {
            oFirstSet.removeElement(poEpsilon);
        } else {
            bAllEpsilon = false;
        }
    }

    // If a first set of every element of a RHS production
    // had epsilon in it, we add it to the FirstSet as well
    if (bAllEpsilon) {
        oFirstSet.addElement(poEpsilon);
    }

    return oFirstSet;
}
 
Example 11
Project: gate-core   File: DataStoreRegister.java   View Source Code Vote up 6 votes
/**
 * Removes a previously registered {@link gate.event.CreoleListener} from the
 * list of listeners for this DataStoreRegister. Normally the only listener
 * that is registered with the DataStoreRegister is the {@link CreoleRegister}
 * which can be obtained through {@link Gate#getCreoleRegister()}
 */
public synchronized void removeCreoleListener(CreoleListener l) {
  if (creoleListeners != null && creoleListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<CreoleListener> v = (Vector<CreoleListener>) creoleListeners.clone();
    v.removeElement(l);
    creoleListeners = v;
  }
}
 
Example 12
Project: gate-core   File: CorpusImpl.java   View Source Code Vote up 6 votes
@Override
public synchronized void removeCorpusListener(CorpusListener l) {
  if(corpusListeners != null && corpusListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<CorpusListener> v = (Vector<CorpusListener>)corpusListeners.clone();
    v.removeElement(l);
    corpusListeners = v;
  }
}
 
Example 13
Project: gate-core   File: SerialCorpusImpl.java   View Source Code Vote up 6 votes
@Override
public synchronized void removeCorpusListener(CorpusListener l) {
  if(corpusListeners != null && corpusListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<CorpusListener> v = (Vector<CorpusListener>)corpusListeners.clone();
    v.removeElement(l);
    corpusListeners = v;
  }
}
 
Example 14
Project: BiglyBT   File: TorrentStart.java   View Source Code Vote up 6 votes
@Override
public void execute(String commandName, ConsoleInput console, List<String> args) {
	startNow = false;
	Vector newargs = new Vector(args);
	if (!newargs.isEmpty() && newargs.contains("now") ) {
		newargs.removeElement("now");
		startNow = true;
	}
	super.execute(commandName, console, args);
}
 
Example 15
Project: BiglyBT   File: TorrentLog.java   View Source Code Vote up 6 votes
@Override
public void execute(String commandName, ConsoleInput ci, List<String> args) {
	mode = MODE_ON;
	Vector newargs = new Vector(args);
	if (newargs.isEmpty()) {
		mode = MODE_FLIP;
	} else if (newargs.contains("off")) {
		newargs.removeElement("off");
		mode = MODE_OFF;
	} else if (!newargs.contains("on")) {
		mode = MODE_FLIP;
	}
	super.execute(commandName, ci, args);
}
 
Example 16
Project: gate-core   File: AbstractProcessingResource.java   View Source Code Vote up 6 votes
/**
 * Removes a {@link gate.event.ProgressListener} from the list of listeners
 * for this processing resource.
 */
public synchronized void removeProgressListener(ProgressListener l) {
  if (progressListeners != null && progressListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<ProgressListener> v = (Vector<ProgressListener>)progressListeners.clone();
    v.removeElement(l);
    progressListeners = v;
  }
}
 
Example 17
Project: lams   File: HttpUserAgentTest.java   View Source Code Vote up 6 votes
private void assertMatchingSet( String comment, Object[] expected, Vector foundItems ) {
    Vector expectedItems = new Vector();
    for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[ i ] );
    for (int i = 0; i < expected.length; i++) {
        if (!foundItems.contains( expected[ i ] )) {
            fail( comment + ": expected " + asText( expected ) + " but missing " + expected[ i ] );
        } else {
            foundItems.removeElement( expected[ i ] );
        }
    }

    if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found superfluous" + foundItems.firstElement() );
}
 
Example 18
Project: gate-core   File: AbstractController.java   View Source Code Vote up 6 votes
/**
 * Removes a {@link gate.event.StatusListener} from the list of listeners for
 * this processing resource
 */
public synchronized void removeStatusListener(StatusListener l) {
  if(statusListeners != null && statusListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<StatusListener> v = (Vector<StatusListener>)statusListeners.clone();
    v.removeElement(l);
    statusListeners = v;
  }
}
 
Example 19
Project: gate-core   File: AbstractController.java   View Source Code Vote up 6 votes
/**
 * Removes a {@link gate.event.ProgressListener} from the list of listeners
 * for this processing resource.
 */
public synchronized void removeProgressListener(ProgressListener l) {
  if(progressListeners != null && progressListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<ProgressListener> v = (Vector<ProgressListener>)progressListeners.clone();
    v.removeElement(l);
    progressListeners = v;
  }
}
 
Example 20
Project: gate-core   File: AbstractController.java   View Source Code Vote up 6 votes
public synchronized void removeControllerListener(ControllerListener l) {
  if(controllerListeners != null && controllerListeners.contains(l)) {
    @SuppressWarnings("unchecked")
    Vector<ControllerListener> v = (Vector<ControllerListener>)controllerListeners.clone();
    v.removeElement(l);
    controllerListeners = v;
  }
}