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

The following are Jave code examples for showing how to use elements() 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: OpenJSharp   File: SnmpMibAgent.java   View Source Code Vote up 8 votes
/**
 * This method creates a new Vector which does not contain the first
 * element up to the specified limit.
 *
 * @param original The original vector.
 * @param limit The limit.
 */
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {

    int max= original.size();
    Vector<SnmpVarBind> result= new Vector<>(max - limit);
    int i= limit;

    // Ok the loop looks a bit strange. But in order to improve the
    // perf, we try to avoid reference to the limit variable from
    // within the loop ...
    //
    for(Enumeration<SnmpVarBind> e= original.elements(); e.hasMoreElements(); --i) {
        SnmpVarBind var= e.nextElement();
        if (i >0)
            continue;
        result.addElement(new SnmpVarBind(var.oid, var.value));
    }
    return result;
}
 
Example 2
Project: lams   File: AcceptLanguage.java   View Source Code Vote up 8 votes
private static void extractLocales(Hashtable languages, Vector q,Vector l)
{
    // XXX We will need to order by q value Vector in the Future ?
    Enumeration e = q.elements();
    while (e.hasMoreElements()) {
        Vector v =
            (Vector)languages.get(((Double)e.nextElement()).toString());
        Enumeration le = v.elements();
        while (le.hasMoreElements()) {
	        String language = (String)le.nextElement();
     	String country = "";
    		int countryIndex = language.indexOf("-");
            if (countryIndex > -1) {
                country = language.substring(countryIndex + 1).trim();
                language = language.substring(0, countryIndex).trim();
            }
            l.addElement(new Locale(language, country));
        }
    }
}
 
Example 3
Project: openjdk-jdk10   File: Crossings.java   View Source Code Vote up 7 votes
public static Crossings findCrossings(Vector<? extends Curve> curves,
                                      double xlo, double ylo,
                                      double xhi, double yhi)
{
    Crossings cross = new EvenOdd(xlo, ylo, xhi, yhi);
    Enumeration<? extends Curve> enum_ = curves.elements();
    while (enum_.hasMoreElements()) {
        Curve c = enum_.nextElement();
        if (c.accumulateCrossings(cross)) {
            return null;
        }
    }
    if (debug) {
        cross.print();
    }
    return cross;
}
 
Example 4
Project: dev-courses   File: TestDataStructures.java   View Source Code Vote up 7 votes
/** Tells whether the given list contains the same data as the vector */
private boolean equalsVector(HsqlList list, Vector vector) {

    if (list.size() != vector.size()) {
        return false;
    }

    Iterator listElements   = list.iterator();
    Enumeration             vectorElements = vector.elements();
    Object                  listObj        = null;
    Object                  vectorObj      = null;

    while (listElements.hasNext()) {
        listObj   = listElements.next();
        vectorObj = vectorElements.nextElement();

        if (!listObj.equals(vectorObj)) {
            return false;
        }
    }

    return true;
}
 
Example 5
Project: Yass   File: YassAlbumFilter.java   View Source Code Vote up 7 votes
/**
 * Gets the genericRules attribute of the YassAlbumFilter object
 *
 * @param data Description of the Parameter
 * @return The genericRules value
 */
public String[] getGenericRules(Vector<YassSong> data) {
    Vector<String> albums = new Vector<>();
    for (Enumeration<?> e = data.elements(); e.hasMoreElements(); ) {
        YassSong s = (YassSong) e.nextElement();
        String album = s.getAlbum();
        if (album == null || album.length() < 1) {
            continue;
        }
        if (!albums.contains(album)) {
            albums.addElement(album);

        }
    }
    Collections.sort(albums);

    return albums.toArray(new String[albums.size()]);
}
 
Example 6
Project: OpenJSharp   File: SnmpAcl.java   View Source Code Vote up 7 votes
/**
 * Returns an enumeration of inform communities for a given host.
 *
 * @param i The address of the host.
 *
 * @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>).
 */
public Enumeration<String> getInformCommunities(InetAddress i) {
    Vector<String> list = null;
    if ((list = informDestList.get(i)) != null ) {
        if (SNMP_LOGGER.isLoggable(Level.FINER)) {
            SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
                "getInformCommunities", "["+i.toString()+"] is in list");
        }
        return list.elements();
    } else {
        list = new Vector<>();
        if (SNMP_LOGGER.isLoggable(Level.FINER)) {
            SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
                "getInformCommunities", "["+i.toString()+"] is not in list");
        }
        return list.elements();
    }
}
 
Example 7
Project: logistimo-web-service   File: MachineProtocolMessageHandler.java   View Source Code Vote up 7 votes
private void replaceIdsWithShortcodes(Vector<Hashtable<String, String>> materials) {
  xLogger.fine("Entered replaceIdsWithShortcodes");
  if (materials == null || materials.isEmpty()) {
    return;
  }
  Enumeration<Hashtable<String, String>> en = materials.elements();
  while (en.hasMoreElements()) {
    Hashtable<String, String> ht = en.nextElement();
    Long materialId = Long.valueOf(ht.get(JsonTagsZ.MATERIAL_ID));
    try {
      IMaterial m = mcs.getMaterial(materialId);
      String shortCode = m.getShortCode();
      String shortName = m.getShortName();
      if (shortCode != null) {
        ht.put(JsonTagsZ.MATERIAL_ID, shortCode);
        xLogger.fine("replaceIdsWithShortcodes: replaced {0} with {1}", materialId, shortCode);
      }
      if (shortName != null && !shortName.isEmpty()) {
        ht.put(JsonTagsZ.NAME, shortName);
      }
    } catch (ServiceException e) {
      xLogger.warn("Unable to get material with ID: {0}", materialId);
    }
  }
  xLogger.fine("Exiting replaceIdsWithShortcodes");
}
 
Example 8
Project: unitimes   File: ExamConflictStatisticsInfo.java   View Source Code Vote up 7 votes
private Vector filter(Collection counters, double limit) {
	Vector cnt = new Vector(counters);
	Collections.sort(cnt);
	int total = 0;
	for (Enumeration e=cnt.elements();e.hasMoreElements();)
		total += ((Counter)e.nextElement()).getCounter();
	
	int totalLimit = (int)Math.ceil(limit*total);
	int current = 0;
	
	Vector ret = new Vector();
	for (Enumeration e=cnt.elements();e.hasMoreElements();) {
		Counter c = (Counter)e.nextElement();
		ret.addElement(c);
		current += c.getCounter();
		if (current>=totalLimit) break;
	}
	
	return ret;
}
 
Example 9
Project: NBANDROID-V2   File: ReadOnlyFileObject.java   View Source Code Vote up 6 votes
@Override
public Enumeration<? extends FileObject> getFolders(boolean rec) {
    Enumeration<? extends FileObject> datas = original.getFolders(rec);
    Vector<FileObject> tmp = new Vector<>();
    while (datas.hasMoreElements()) {
        FileObject nextElement = datas.nextElement();
        tmp.add(findOrCreate(nextElement));
    }
    return tmp.elements();
}
 
Example 10
Project: jdk8u-jdk   File: SourceMember.java   View Source Code Vote up 6 votes
void createArgumentFields(Vector argNames) {
    // Create a list of arguments
    if (isMethod()) {
        args = new Vector();

        if (isConstructor() || !(isStatic() || isInitializer())) {
            args.addElement(((SourceClass)clazz).getThisArgument());
        }

        if (argNames != null) {
            Enumeration e = argNames.elements();
            Type argTypes[] = getType().getArgumentTypes();
            for (int i = 0 ; i < argTypes.length ; i++) {
                Object x = e.nextElement();
                if (x instanceof LocalMember) {
                    // This should not happen, but it does
                    // in cases of vicious cyclic inheritance.
                    args = argNames;
                    return;
                }
                Identifier id;
                int mod;
                long where;
                if (x instanceof Identifier) {
                    // allow argNames to be simple Identifiers (deprecated!)
                    id = (Identifier)x;
                    mod = 0;
                    where = getWhere();
                } else {
                    IdentifierToken token = (IdentifierToken)x;
                    id = token.getName();
                    mod = token.getModifiers();
                    where = token.getWhere();
                }
                args.addElement(new LocalMember(where, clazz, mod,
                                               argTypes[i], id));
            }
        }
    }
}
 
Example 11
Project: monarch   File: ClassPathLoaderTest.java   View Source Code Vote up 6 votes
@Override
protected Enumeration<URL> findResources(String name) throws IOException {
  URL url = null;
  try {
    url = getTempFile().getAbsoluteFile().toURI().toURL();
    System.out.println("GeneratingClassLoader#findResources returning " + url);
  } catch (IOException e) {
  }
  Vector<URL> urls = new Vector<URL>();
  urls.add(url);
  return urls.elements();
}
 
Example 12
Project: AntIDE   File: BreakpointManager.java   View Source Code Vote up 6 votes
private boolean compareArgTypes(RemoteField method, Vector nameVector) {
  String nameString = method.getTypedName();

  // Skip to the argument types and tokenize them
  int index = nameString.indexOf("(");
  if (index == -1) {
    throw new IllegalArgumentException("Method expected");
  }
  StringTokenizer tokens = new StringTokenizer(nameString.substring(index),
                                               "(,) \t\n\r");

  // If argument counts differ, we can stop here
  if (tokens.countTokens() != nameVector.size()) {
    return false;
  }

  // Compare each argument type's name
  Enumeration enum = nameVector.elements();
  while (tokens.hasMoreTokens()) {
    String comp1 = (String)enum.nextElement();
    String comp2 = tokens.nextToken();
    if (! comp1.equals(comp2)) {
      return false;
    }
  }

  return true;
}
 
Example 13
Project: dev-courses   File: TestBench.java   View Source Code Vote up 5 votes
void oneRound(String url, String user,
              String password) throws InterruptedException, SQLException {

    Vector      vClient  = new Vector();
    Thread      Client   = null;
    Enumeration e        = null;
    Connection  guardian = null;

    //
    start_time = System.currentTimeMillis();

    for (int i = 0; i < n_clients; i++) {
        if (useStoredProcedure) {
            Client = new ClientThreadProcedure(
                n_txn_per_client, url, user, password,
                Connection.TRANSACTION_READ_COMMITTED);
        } else {
            Client =
                new ClientThread(n_txn_per_client, url, user, password,
                                 Connection.TRANSACTION_READ_COMMITTED);
        }

        Client.start();
        vClient.addElement(Client);
    }

    /*
     ** Barrier to complete this test session
     */
    e = vClient.elements();

    while (e.hasMoreElements()) {
        Client = (Thread) e.nextElement();

        Client.join();
    }

    vClient.removeAllElements();
    reportDone();

    guardian = connect(url, user, password);

    if (count_results) {
        checkSums(guardian);
    }

    connectClose(guardian);
}
 
Example 14
Project: parabuild-ci   File: Transfer.java   View Source Code Vote up 5 votes
private boolean SchemaToSelect() {

        Vector result = null;

        try {
            lTable.removeAll();

            if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
                result = sourceDb.getSchemas();
            } else if (iSelectionStep == Transfer.SELECT_DEST_SCHEMA) {
                result = targetDb.getSchemas();
            } else {
                exit();
            }

            if (result.size() > 1) {
                lTable.setMultipleMode(true);

                if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
                    bStart.setLabel("Select Schema: Source");
                } else {
                    bStart.setLabel("Select Schema: Destination");
                }

                bStart.invalidate();
                bStart.setEnabled(true);

                for (Enumeration e =
                        result.elements(); e.hasMoreElements(); ) {
                    lTable.add(e.nextElement().toString());
                }

                lTable.repaint();
                trace("Select correct Schema or load Settings file");
            } else {
                if (result.size() == 1) {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
                        sSourceSchemas    = new String[1];
                        sSourceSchemas[0] = (String) result.firstElement();
                    } else {
                        sDestSchema = (String) result.firstElement();
                    }
                } else {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
                        sSourceSchemas = null;
                    } else {
                        sDestSchema = null;
                    }
                }

                if (iTransferMode == TRFM_DUMP) {
                    iSelectionStep = Transfer.SELECT_SOURCE_TABLES;
                } else {
                    iSelectionStep++;
                }

                ProcessNextStep();

                return false;
            }
        } catch (Exception exp) {
            lTable.removeAll();
            trace("Exception reading schemas: " + exp);
            exp.printStackTrace();
        }

        return (lTable.getItemCount() > 0);
    }
 
Example 15
Project: whackpad   File: HttpServletRequestFactory.java   View Source Code Vote up 5 votes
public Enumeration<String> getHeaders(String name) { 
    Vector<String> v = new Vector<String>();
    v.add(getHeader(name));
    return v.elements();
}
 
Example 16
Project: sstore-soft   File: Transfer.java   View Source Code Vote up 5 votes
private boolean CatalogToSelect() {

        Vector result = null;

        try {
            lTable.removeAll();

            if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                result = sourceDb.getCatalog();
            } else if (iSelectionStep == Transfer.SELECT_DEST_CATALOG) {
                result = targetDb.getCatalog();
            } else {
                exit();
            }

            if (result.size() > 1) {
                lTable.setMultipleMode(true);

                if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                    bStart.setLabel("Select Catalog: Source");
                } else {
                    bStart.setLabel("Select Catalog: Destination");
                }

                bStart.invalidate();
                bStart.setEnabled(true);

                for (Enumeration e =
                        result.elements(); e.hasMoreElements(); ) {
                    lTable.add(e.nextElement().toString());
                }

                lTable.repaint();
                trace("Select correct Catalog");
            } else {
                if (result.size() == 1) {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                        sSourceCatalog = (String) result.firstElement();
                        sSourceSchemas = null;
                    } else {
                        sDestCatalog = (String) result.firstElement();
                        sDestSchema  = null;
                    }
                } else {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                        sSourceCatalog = null;
                        sSourceSchemas = null;
                    } else {
                        sDestCatalog = null;
                        sDestSchema  = null;
                    }
                }

                if ((iSelectionStep == Transfer.SELECT_DEST_CATALOG)
                        && (sDestCatalog != null)) {
                    try {
                        targetDb.setCatalog(sDestCatalog);
                    } catch (Exception ex) {
                        trace("Catalog " + sSourceCatalog
                              + " could not be selected in the target database");

                        sSourceCatalog = null;
                    }
                }

                iSelectionStep++;

                ProcessNextStep();

                return false;
            }
        } catch (Exception exp) {
            lTable.removeAll();
            trace("Exception reading catalog: " + exp);
            exp.printStackTrace();
        }

        return (lTable.getItemCount() > 0);
    }
 
Example 17
Project: logistimo-web-service   File: JsonUtil.java   View Source Code Vote up 5 votes
public static void addBatchErrorData(JSONObject errorJSON, Vector batches) throws JSONException {
  if (batches == null || batches.isEmpty()) {
    return;
  }
  JSONArray batchesJson = new JSONArray();
  Enumeration en = batches.elements();
  while (en.hasMoreElements()) {
    Hashtable batch = (Hashtable) en.nextElement();
    JSONObject batchJson = new JSONObject();
    String value = null;
    if ((value = (String) batch.get(JsonTagsZ.BATCH_ID)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.BATCH_ID, batch.get(JsonTagsZ.BATCH_ID));
    }
    if ((value = (String) batch.get(JsonTagsZ.QUANTITY)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.QUANTITY, batch.get(JsonTagsZ.QUANTITY));
    }
    if ((value = (String) batch.get(JsonTagsZ.BATCH_EXPIRY)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.BATCH_EXPIRY, batch.get(JsonTagsZ.BATCH_EXPIRY));
    }
    if ((value = (String) batch.get(JsonTagsZ.BATCH_MANUFACTUER_NAME)) != null && !value
        .equals("")) {
      batchJson
          .put(JsonTagsZ.BATCH_MANUFACTUER_NAME, batch.get(JsonTagsZ.BATCH_MANUFACTUER_NAME));
    }
    if ((value = (String) batch.get(JsonTagsZ.BATCH_MANUFACTURED_DATE)) != null && !value
        .equals("")) {
      batchJson
          .put(JsonTagsZ.BATCH_MANUFACTURED_DATE, batch.get(JsonTagsZ.BATCH_MANUFACTURED_DATE));
    }
    if ((value = (String) batch.get(JsonTagsZ.TIMESTAMP)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.TIMESTAMP, batch.get(JsonTagsZ.TIMESTAMP));
    }
    if ((value = (String) batch.get(JsonTagsZ.MESSAGE)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.MESSAGE, batch.get(JsonTagsZ.MESSAGE));
    }
    if ((value = (String) batch.get(JsonTagsZ.ERROR_CODE)) != null && !value.equals("")) {
      batchJson.put(JsonTagsZ.ERROR_CODE, batch.get(JsonTagsZ.ERROR_CODE));
    }
    batchesJson.put(batchJson);
  }
  errorJSON.put(JsonTagsZ.BATCHES, batchesJson);
}
 
Example 18
Project: parabuild-ci   File: Transfer.java   View Source Code Vote up 5 votes
private boolean CatalogToSelect() {

        Vector result = null;

        try {
            lTable.removeAll();

            if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                result = sourceDb.getCatalog();
            } else if (iSelectionStep == Transfer.SELECT_DEST_CATALOG) {
                result = targetDb.getCatalog();
            } else {
                exit();
            }

            if (result.size() > 1) {
                lTable.setMultipleMode(true);

                if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                    bStart.setLabel("Select Catalog: Source");
                } else {
                    bStart.setLabel("Select Catalog: Destination");
                }

                bStart.invalidate();
                bStart.setEnabled(true);

                for (Enumeration e =
                        result.elements(); e.hasMoreElements(); ) {
                    lTable.add(e.nextElement().toString());
                }

                lTable.repaint();
                trace("Select correct Catalog");
            } else {
                if (result.size() == 1) {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                        sSourceCatalog = (String) result.firstElement();
                        sSourceSchemas = null;
                    } else {
                        sDestCatalog = (String) result.firstElement();
                        sDestSchema  = null;
                    }
                } else {
                    if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
                        sSourceCatalog = null;
                        sSourceSchemas = null;
                    } else {
                        sDestCatalog = null;
                        sDestSchema  = null;
                    }
                }

                if ((iSelectionStep == Transfer.SELECT_DEST_CATALOG)
                        && (sDestCatalog != null)) {
                    try {
                        targetDb.setCatalog(sDestCatalog);
                    } catch (Exception ex) {
                        trace("Catalog " + sSourceCatalog
                              + " could not be selected in the target database");

                        sSourceCatalog = null;
                    }
                }

                iSelectionStep++;

                ProcessNextStep();

                return false;
            }
        } catch (Exception exp) {
            lTable.removeAll();
            trace("Exception reading catalog: " + exp);
            exp.printStackTrace();
        }

        return (lTable.getItemCount() > 0);
    }
 
Example 19
Project: rapidminer   File: MultipleLinesLabel.java   View Source Code Vote up 5 votes
private void updateTextVector() {
	this.vector = new Vector<String>();

	int w = this.getWidth();
	if (w > 6) {
		w -= 4;
	}

	int counter = 0;

	char[] ca = this.text.toCharArray();
	String tempStr = "";
	Vector<String> sentVec = new Vector<String>();
	char lastChar;

	lastChar = ca[0];
	tempStr += lastChar;

	for (int i = 1; i < ca.length; i++) {
		if (lastChar == ' ') {
			if (ca[i] == ' ') {
				tempStr += ca[i];
			} else {
				sentVec.add(tempStr);
				tempStr = String.valueOf(ca[i]);
			}
		} else {
			if (ca[i] == ' ') {
				sentVec.add(tempStr);
				tempStr = String.valueOf(ca[i]);
			} else {
				tempStr += ca[i];
			}
		}
		lastChar = ca[i];
	}
	if (!tempStr.equals("")) {
		sentVec.add(tempStr);
	}

	Enumeration els = sentVec.elements();

	StringBuffer lineStr = new StringBuffer();
	while (els.hasMoreElements()) {
		String str = els.nextElement().toString();
		counter++;

		if (this.fontMetrics.stringWidth(str) <= w) {
			if ((this.fontMetrics.stringWidth(lineStr + str) <= w)) {
				lineStr.append(str);
			} else {
				if (lineStr.length() > 0) {
					this.vector.add(lineStr.toString());
					lineStr = new StringBuffer();
				}
				lineStr = new StringBuffer(str);
			}
		} else {
			if (lineStr.length() > 0) {
				this.vector.add(lineStr.toString());
				lineStr = new StringBuffer();
			}

			ca = str.toCharArray();
			int first = 0;
			for (int i = 0; i < ca.length; i++) {
				if (this.fontMetrics.stringWidth(str.substring(first, i)) > w) {
					this.vector.add(str.substring(first, i - 1));
					first = i - 1;
				}
			}
			lineStr = new StringBuffer(str.substring(first, str.length()));
		}
	}

	if (lineStr.length() > 0) {
		this.vector.add(lineStr.toString());
	}
}
 
Example 20
Project: whackpad   File: HttpServletRequestFactory.java   View Source Code Vote up 5 votes
public Enumeration<java.util.Locale> getLocales() {
    Vector<java.util.Locale> v = new Vector<java.util.Locale>();
    v.add(java.util.Locale.US);
    return v.elements();
}