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

The following are Jave code examples for showing how to use contains() 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: incubator-netbeans   File: MultiClassLoader.java   View Source Code Vote up 6 votes
@Override
protected Enumeration<URL> findResources(String name) throws IOException {
    Vector<URL> vector = new Vector<URL>();
    for (ClassLoader loader : loaders) {
        Enumeration<URL> enumeration = loader.getResources(name);
        while (enumeration.hasMoreElements()) {
            URL url = enumeration.nextElement();
            if (!vector.contains(url)) {
                vector.add(url);
            }
        }
    }
    return vector.elements();
}
 
Example 3
Project: gate-core   File: SerialControllerEditor.java   View Source Code Vote up 6 votes
public synchronized void addProgressListener(ProgressListener l) {
  @SuppressWarnings("unchecked")
  Vector<ProgressListener> v = progressListeners == null ?
    new Vector<ProgressListener>(2) : (Vector<ProgressListener>) progressListeners.clone();
  if (!v.contains(l)) {
    v.addElement(l);
    progressListeners = v;
  }
}
 
Example 4
Project: openjdk-jdk10   File: LdapCtxFactory.java   View Source Code Vote up 6 votes
private static void getClassesAux(Class<?> currentClass, Vector<String> v) {
    if (!v.contains(currentClass.getName())) {
        v.addElement(currentClass.getName());
    }
    currentClass = currentClass.getSuperclass();

    while (currentClass != null) {
        getTypeNames(currentClass, v);
        currentClass = currentClass.getSuperclass();
    }
}
 
Example 5
Project: AgentWorkbench   File: NetworkModel.java   View Source Code Vote up 6 votes
/**
 * Returns the neighbour NetworkComponent's based on a Vector of NetworkComponent's.
 *
 * @param networkComponents the network components
 * @return the neighbour network components
 */
public Vector<NetworkComponent> getNeighbourNetworkComponents(Vector<NetworkComponent> networkComponents) {
	Vector<NetworkComponent> neighbourNetworkComponents = new Vector<NetworkComponent>();
	for (NetworkComponent networkComponent : networkComponents) {
		Vector<NetworkComponent> neighboursFound = getNeighbourNetworkComponents(networkComponent);
		for (NetworkComponent neighbour : neighboursFound) {
			if (neighbourNetworkComponents.contains(neighbour)==false) {
				neighbourNetworkComponents.add(neighbour);	
			}
		}
	}
	return neighbourNetworkComponents;
}
 
Example 6
Project: OpenJSharp   File: SchemaParser.java   View Source Code Vote up 6 votes
public Enumeration prefixes() {
    Vector v = new Vector();
    for (PrefixMapping p = prefixMapping; p != null; p = p.next) {
        if (!v.contains(p.prefix)) {
            v.addElement(p.prefix);
        }
    }
    return v.elements();
}
 
Example 7
Project: openjdk-jdk10   File: XSDHandler.java   View Source Code Vote up 6 votes
private void addRelatedElement(XSElementDeclaration decl, Vector componentList, String namespace, Map<String, Vector> dependencies) {
    if (decl.getScope() == XSConstants.SCOPE_GLOBAL) {
        if (!componentList.contains(decl)) {
            Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
            addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces);
            componentList.add(decl);
        }
    }
    else {
        expandRelatedElementComponents(decl, componentList, namespace, dependencies);
    }
}
 
Example 8
Project: openjdk-jdk10   File: Util.java   View Source Code Vote up 6 votes
/**
 * Extract the global constants from the supplied integer expression
 * representation (string) and add them to the supplied import list.
 **/
static private void checkForGlobalConstants (String exprRep, Vector importTypes, Vector importList)
{
  // NOTE: Do not use '/' as a delimiter. Symbol table names use '/' as a
  // delimiter and would not be otherwise properly collected. Blanks and
  // arithmetic symbols do not appear in tokens, except for '/'.
  java.util.StringTokenizer st = new java.util.StringTokenizer (exprRep, " +-*()~&|^%<>");
  while (st.hasMoreTokens ())
  {
    String token = st.nextToken ();
    // When token contains '/', it represents the division symbol or
    // a nested type (e.g., I/x). Ignore the division symbol, and don't
    // forget constants declared within global interfaces!
    if (!token.equals ("/"))
    {
      SymtabEntry typeEntry = (SymtabEntry)symbolTable.get (token);
      if (typeEntry instanceof ConstEntry)
      {
        int slashIdx = token.indexOf ('/');
        if (slashIdx < 0)  // Possible global constant
        {
          if (importTypes.contains (typeEntry))
            addTo (importList, typeEntry.name ());
        }
        else  // Possible constant in global interface
        {
          SymtabEntry constContainer = (SymtabEntry)symbolTable.get (token.substring (0, slashIdx));
          if (constContainer instanceof InterfaceEntry && importTypes.contains (constContainer))
            addTo (importList, constContainer.name ());
        }
      }
    }
  }
}
 
Example 9
Project: jmt   File: AllStationsParametersPanel.java   View Source Code Vote up 6 votes
/**
 * Updates list of stations and selects last selected station
 */
@Override
public void gotFocus() {
	if (stationsList != null) {
		Vector stations = stationData.getStationKeys();
		stationsList.setListData(stations);
		// If old selected key exists selects it, otherwise select first station
		if (stations.contains(selectedKey)) {
			stationsList.setSelectedValue(selectedKey, true);
		} else if (stations.size() > 0) {
			stationsList.setSelectedIndex(0);
			selectedKey = stationsList.getSelectedValue();
		}
	}
}
 
Example 10
Project: gate-core   File: AbstractController.java   View Source Code Vote up 6 votes
/**
 * Adds a {@link gate.event.StatusListener} to the list of listeners for this
 * processing resource
 */
public synchronized void addStatusListener(StatusListener l) {
  @SuppressWarnings("unchecked")
  Vector<StatusListener> v =
    statusListeners == null ? new Vector<StatusListener>(2) : (Vector<StatusListener>)statusListeners.clone();
  if(!v.contains(l)) {
    v.addElement(l);
    statusListeners = v;
  }
}
 
Example 11
Project: javafx-3d-surface-chart   File: DelaunayTriangulation.java   View Source Code Vote up 6 votes
private void allTriangles(Triangle curr, Vector<Triangle> front, int mc) {
	if (curr != null && curr.getMc() == mc && !front.contains(curr)) {
		front.add(curr);
		allTriangles(curr.getAbTriangle(), front, mc);
		allTriangles(curr.getBcTriangle(), front, mc);
		allTriangles(curr.getCaTriangle(), front, mc);
	}
}
 
Example 12
Project: gate-core   File: DocumentImpl.java   View Source Code Vote up 6 votes
@Override
public synchronized void addDocumentListener(DocumentListener l) {
  @SuppressWarnings("unchecked")
  Vector<DocumentListener> v = documentListeners == null
          ? new Vector<DocumentListener>(2)
          : (Vector<DocumentListener>)documentListeners.clone();
  if(!v.contains(l)) {
    v.addElement(l);
    documentListeners = v;
  }
}
 
Example 13
Project: OpenJSharp   File: Util.java   View Source Code Vote up 6 votes
/**
 *
 **/
static private void addTo (Vector importList, String name)
{
  // REVISIT - <d62023-klr> was also importing ValueBaseHolder and Helper
  if (name.startsWith ("ValueBase"))  // don't import ValueBase*
    if ((name.compareTo ("ValueBase") == 0) ||
        (name.compareTo ("ValueBaseHolder") == 0) ||
            (name.compareTo ("ValueBaseHelper") == 0))
      return;
  if (!importList.contains (name))
    importList.addElement (name);
}
 
Example 14
Project: OpenJSharp   File: Skeleton.java   View Source Code Vote up 6 votes
/**
 *
 **/
private void buildIDList (InterfaceEntry entry, Vector list)
{
  if (!entry.fullName ().equals ("org/omg/CORBA/Object"))
  {
    String id = Util.stripLeadingUnderscoresFromID (entry.repositoryID ().ID ());
    if (!list.contains (id))
      list.addElement (id);
    Enumeration e = entry.derivedFrom ().elements ();
    while (e.hasMoreElements ())
      buildIDList ((InterfaceEntry)e.nextElement (), list);
  }
}
 
Example 15
Project: OpenJSharp   File: XSDHandler.java   View Source Code Vote up 6 votes
private void addNamespaceDependency(String namespace1, String namespace2, Vector list) {
    final String ns1 = null2EmptyString(namespace1);
    final String ns2 = null2EmptyString(namespace2);
    if (!ns1.equals(ns2)) {
        if (!list.contains(ns2)) {
            list.add(ns2);
        }
    }
}
 
Example 16
Project: incubator-netbeans   File: TableColumn.java   View Source Code Vote up 5 votes
/**
* Returns properties and it's values supported by this object.
* object.name		Name of the object; use setObjectName() 
* object.owner		Name of the object; use setObjectOwner() 
* column.size		Size of column 
* column.decsize	Deimal size of size 
* column.type		Type of column 
* default.value		Condition of column 
* Throws DDLException if object name is not specified.
*/
public Map getColumnProperties(AbstractCommand cmd) throws DDLException {
    DatabaseSpecification spec = cmd.getSpecification();
    Map args = super.getColumnProperties(cmd);
    String stype = spec.getType(type);
    Vector charactertypes = (Vector)spec.getProperties().get("CharacterTypes"); // NOI18N
    String strdelim = (String)spec.getProperties().get("StringDelimiter"); // NOI18N
    Vector sizelesstypes = (Vector)spec.getProperties().get("SizelessTypes"); // NOI18N
    String coldelim = (String)spec.getProperties().get("ArgumentListDelimiter"); // NOI18N

    // Decimal size for sizeless type
    if (sizelesstypes != null && size > 0) {
        if (!sizelesstypes.contains(stype)) {
            if (size > 0)
                args.put("column.size", String.valueOf(size)); // NOI18N
            if (decsize > 0)
                args.put("column.decsize", String.valueOf(decsize)); // NOI18N
        }
    }

    String qdefval = defval;

    if (qdefval != null && charactertypes.contains(spec.getType(type)) && !qdefval.startsWith(strdelim) && !qdefval.endsWith(strdelim))
        if (!qdefval.startsWith("(" + strdelim) && !qdefval.endsWith(strdelim + ")")) //hack for MSSQLServer, default value is encapsulated in () so I can't generate '()'
            qdefval = strdelim + defval + strdelim;
    
    String dbType = spec.getType(type);
    String dbTypeSuffix = null;
    Map suffixTypeMap = (Map)spec.getProperties().get("TypePrefixSuffixMap"); // NOI18N
    if (suffixTypeMap != null) {
        Map dbTypePrefixSuffix = (Map)suffixTypeMap.get(dbType);
        if (dbTypePrefixSuffix != null) {
            dbType = (String)dbTypePrefixSuffix.get("Prefix"); // NOI18N
            dbTypeSuffix = (String)dbTypePrefixSuffix.get("Suffix"); // NOI18N
        }
    }
    args.put("column.type", dbType);
    if (dbTypeSuffix != null) {
        args.put("column.type.suffix", dbTypeSuffix);
    }
    
    if (!nullable)
        args.put("column.notnull", ""); // NOI18N
    
    if (!(! nullable && qdefval != null && (qdefval.equalsIgnoreCase("null") || qdefval.equalsIgnoreCase("'null'") || qdefval.equalsIgnoreCase("\"null\"")))) // NOI18N
        if (defval != null && !defval.equals(""))
            args.put("default.value", qdefval); // NOI18N

    if (checke != null)
        args.put("check.condition", checke); // NOI18N
    if (constraintColumns != null) {
        String cols = "";
        Enumeration col_e = constraintColumns.elements();
        while (col_e.hasMoreElements()) {
            Object zrus = col_e.nextElement();
            Hashtable col = (Hashtable)zrus;
            boolean inscomma = col_e.hasMoreElements();
            String colname = (String)col.get("name");
            cols = cols + 
                (isNewColumn() ? colname : cmd.quote(colname)) + 
                (inscomma ? coldelim : "" ); //NOI18N
        }
        args.put("constraint.columns", cols); // NOI18N
    }
    return args;
}
 
Example 17
Project: openjdk-jdk10   File: XSGrammarBucket.java   View Source Code Vote up 5 votes
/**
 * put a schema grammar and any grammars imported by it (directly or
 * inderectly) into the registry. when a grammar with the same target
 * namespace is already in the bucket, and different from the one being
 * added, it's an error, and no grammar will be added into the bucket.
 *
 * @param grammar   the grammar to put in the registry
 * @param deep      whether to add imported grammars
 * @return          whether the process succeeded
 */
public boolean putGrammar(SchemaGrammar grammar, boolean deep) {
    // whether there is one with the same tns
    SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
    if (sg != null) {
        // if the one we have is different from the one passed, it's an error
        return sg == grammar;
    }
    // not deep import, then just add this one grammar
    if (!deep) {
        putGrammar(grammar);
        return true;
    }

    // get all imported grammars, and make a copy of the Vector, so that
    // we can recursively process the grammars, and add distinct ones
    // to the same vector
    Vector currGrammars = (Vector)grammar.getImportedGrammars();
    if (currGrammars == null) {
        putGrammar(grammar);
        return true;
    }

    Vector grammars = ((Vector)currGrammars.clone());
    SchemaGrammar sg1, sg2;
    Vector gs;
    // for all (recursively) imported grammars
    for (int i = 0; i < grammars.size(); i++) {
        // get the grammar
        sg1 = (SchemaGrammar)grammars.elementAt(i);
        // check whether the bucket has one with the same tns
        sg2 = getGrammar(sg1.fTargetNamespace);
        if (sg2 == null) {
            // we need to add grammars imported by sg1 too
            gs = sg1.getImportedGrammars();
            // for all grammars imported by sg2, but not in the vector
            // we add them to the vector
            if(gs == null) continue;
            for (int j = gs.size() - 1; j >= 0; j--) {
                sg2 = (SchemaGrammar)gs.elementAt(j);
                if (!grammars.contains(sg2))
                    grammars.addElement(sg2);
            }
        }
        // we found one with the same target namespace
        // if the two grammars are not the same object, then it's an error
        else if (sg2 != sg1) {
            return false;
        }
    }

    // now we have all imported grammars stored in the vector. add them
    putGrammar(grammar);
    for (int i = grammars.size() - 1; i >= 0; i--)
        putGrammar((SchemaGrammar)grammars.elementAt(i));

    return true;
}
 
Example 18
Project: QN-ACTR-Release   File: ArrivalRateParametricAnalysis.java   View Source Code Vote up 5 votes
/**
 * Checks if the PA model is still coherent with simulation model definition. If
 * the <code>autocorrect</code> variable is set to true, if the PA model is no more
 * valid but it can be corrected it will be changed.
 *
 * @param autocorrect if true the PA model will be autocorrected
 *
 * @return 0 - If the PA model is still valid <br>
 *         1 - If the PA model is no more valid, but it will be corrected <br>
 *         2 - If the PA model can be no more used
 */
@Override
public int checkCorrectness(boolean autocorrect) {
	int code = 0;
	ParametricAnalysisChecker checker = new ParametricAnalysisChecker(classDef, stationDef, simDef);
	Vector openClasses = classDef.getOpenClassKeys();
	Vector<Object> avaibleClasses = checker.checkForArrivalRatesParametricSimulationAvaibleClasses();
	if (avaibleClasses.isEmpty()) {
		code = 2;
	} else {
		//if is single class...
		if (isSingleClass()) {
			// ... and the selected close class is no more avaible
			if (!avaibleClasses.contains(classKey)) {
				code = 1;
				if (autocorrect) {
					classKey = openClasses.get(0); //change the reference class
					setDefaultInitialValue();
					setDefaultFinalValue();
				}
			} else {
				double refRate = 1 / (((Distribution) classDef.getClassDistribution(classKey)).getMean());
				//If the arrival rate of reference class was changed...
				if (initialValue != refRate) {
					code = 1;
					if (autocorrect) {
						initialValue = refRate;
						finalValue = refRate * INCREMENT_SINGLE;
					}
				}
			}
		} else {
			if ((avaibleClasses.size() < openClasses.size()) || (openClasses.size() == 1)) {
				code = 1;
				if (autocorrect) {
					classKey = avaibleClasses.get(0);
					singleClass = true;
					setDefaultInitialValue();
					setDefaultFinalValue();
				}
			}
		}
	}
	return code;
}
 
Example 19
Project: openjdk-jdk10   File: ImplementationType.java   View Source Code Vote up 5 votes
private static void copyRemoteMethods(InterfaceType type, Vector list) {

        if (type.isType(TYPE_REMOTE)) {

            // Copy all the unique methods from type...

            Method[] allMethods = type.getMethods();

            for (int i = 0; i < allMethods.length; i++) {
                Method theMethod = allMethods[i];

                if (!list.contains(theMethod)) {
                    list.addElement(theMethod);
                }
            }

            // Now recurse thru all inherited interfaces...

            InterfaceType[] allInterfaces = type.getInterfaces();

            for (int i = 0; i < allInterfaces.length; i++) {
                copyRemoteMethods(allInterfaces[i],list);
            }
        }
    }
 
Example 20
Project: Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud   File: Action.java   View Source Code Vote up 5 votes
private boolean getAvailable(Vector<String> path, String nei) {
	// TODO Auto-generated method stub
	return !path.contains(nei);
}