Java Code Examples for java.util.Vector#iterator()

The following examples show how to use java.util.Vector#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessData.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
private static void printTexTableHeader(PrintWriter out, String rowHeading, Vector<String> columns){
	//out.println("\\begin{figure}[hbtp]");
	out.println("\\begin{table}[hbtp]");
	out.print("\\begin{tabular}{");

	for(int i =0;i<=columns.size();i++)
		out.print("|l");
	
	out.println("|}");
	out.println("\\hline");
	
	out.print(rowHeading+"   ");
	
	Iterator<String> it = columns.iterator();
	while(it.hasNext()){
		out.print("&"+it.next());
		if(it.hasNext())
			out.print("   ");
	}
	out.println("\\\\");
	
	out.println("\\hline");
}
 
Example 2
Source File: TinyObject.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static String commaSeparatedStringFor(Vector fields) {
  StringBuffer sb = new StringBuffer();
  for (Iterator i = fields.iterator(); i.hasNext();) {
    String field = (String) i.next();
    if (field.equals("*")) {
      return field;
    }
    else {
      sb.append(TinyObject.REGION_TABLE_SHORT_NAME + "." + field);
    }
    if (i.hasNext()) {
      sb.append(",");
    }
  }
  return sb.toString();
}
 
Example 3
Source File: JavaScriptEngine.java    From commons-bsf with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the engine. 
 * Put the manager into the context-manager
 * map hashtable too.
 */
public void initialize(BSFManager mgr, String lang, Vector declaredBeans)
    throws BSFException {
    
    super.initialize(mgr, lang, declaredBeans);

    // Initialize context and global scope object
    try {
        Context cx = Context.enter();
        global = new ImporterTopLevel(cx);
        Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
        global.put("bsf", global, bsf);

        for(Iterator it = declaredBeans.iterator(); it.hasNext();) {
            declareBean((BSFDeclaredBean) it.next());
        }
    } 
    catch (Throwable t) {

    } 
    finally {
        Context.exit();
    }
}
 
Example 4
Source File: Instrument.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static String commaSeparatedStringFor(Vector fields) {
  //Vector copy = (Vector)fields.clone();
  StringBuffer sb = new StringBuffer();
  for (Iterator i = fields.iterator(); i.hasNext();) {
    String field = (String) i.next();
    if (field.equals("*")) {
      return field;
    }
    else {
      sb.append(Instrument.REGION_TABLE_SHORT_NAME + "." + field);
    }
    if (i.hasNext()) {
      sb.append(",");
    }
  }
  return sb.toString();
}
 
Example 5
Source File: WrapperManager.java    From KEEL with GNU General Public License v3.0 6 votes vote down vote up
private static HashMap<String, Boolean> buildsTemporaryDTermsHashMap(
		Vector<TermConjunction> posTerms) {
	HashMap<String, Boolean> pTerms = new HashMap<String, Boolean>();
	Iterator<TermConjunction> posTIter = posTerms.iterator();
	while (posTIter.hasNext()) {
		TermConjunction tc = posTIter.next();
		Set<DiscriminativeTerm> discrTerm = tc.getTerms();
		Iterator<DiscriminativeTerm> discrTermIterator = discrTerm
				.iterator();
		while (discrTermIterator.hasNext()) {
			DiscriminativeTerm dt = discrTermIterator.next();
			String clearDTName = dt.getTermValue().replace("\"", "");
			pTerms.put(clearDTName, true);
		}
	}

	return pTerms;
}
 
Example 6
Source File: Discretizacion.java    From KEEL with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String toString() {
    String s = "";
    Iterator it = this.getCortes().iterator();
    int i = 0;
    while (it.hasNext()) {
        Vector v = (Vector) it.next();
        Iterator it2 = v.iterator();
        s += "\nAtributo: " + (String)this.getBd().getNombres().get(i) +
                "\n";
        s += "-----------------------------------------\n";

        while (it2.hasNext()) {
            Corte c = (Corte) it2.next();
            s += c.getCorte() + ", " + c.getClase() + ", " + c.getBondad() +
                    "\n";
        }
        i++;
    }
    return s;
}
 
Example 7
Source File: QueryPrms.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static List getObjectTypes() {
  Long key = objectTypes;
  Vector val = tasktab().vecAt(key, tab().vecAt(key));
  List vals = new ArrayList();
  for (Iterator i = val.iterator(); i.hasNext();) {
    vals.add(getObjectType(key, (String)i.next()));
  }
  return vals;
}
 
Example 8
Source File: Util.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static JLabel findLabel(JComponent comp, String labelText) {
    Vector allComponents = new Vector();
    getAllComponents(comp.getComponents(), allComponents);
    Iterator iterator = allComponents.iterator();
    while (iterator.hasNext()) {
        Component c = (Component) iterator.next();
        if (c instanceof JLabel) {
            JLabel label = (JLabel) c;
            if (label.getText().equals(labelText)) {
                return label;
            }
        }
    }
    return null;
}
 
Example 9
Source File: TbMatch.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 如果结果要区分大小写
 * @param terms
 * @param caseSensitive
 *            ;
 */
private void doWithQueryResultsCaseSensitive(Vector<Hashtable<String, String>> terms, String pureText) {
	Iterator<Hashtable<String, String>> iterator = terms.iterator();
	while(iterator.hasNext()){
		Hashtable<String, String> item = iterator.next();
		String srcWord = item.get("srcWord");
		if (!pureText.contains(srcWord)) {
			iterator.remove();
		}
	}
}
 
Example 10
Source File: Util.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static JLabel findLabel(JComponent comp, String labelText) {
    Vector allComponents = new Vector();
    getAllComponents(comp.getComponents(), allComponents);
    Iterator<Component> iterator = allComponents.iterator();
    while (iterator.hasNext()) {
        Component c = iterator.next();
        if (c instanceof JLabel) {
            JLabel label = (JLabel) c;
            if (label.getText().equals(labelText)) {
                return label;
            }
        }
    }
    return null;
}
 
Example 11
Source File: isSiteLocalAddress.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String[][] addrs =
    {{"9.255.255.255", "false"}, {"10.0.0.0", "true"},
     {"10.255.255.255", "true"}, {"11.0.0.0", "false"},
     {"172.15.255.255", "false"}, {"172.16.0.0", "true"},
     {"172.30.1.2", "true"}, {"172.31.255.255", "true"},
     {"172.32.0.0", "false"}, {"192.167.255.255", "false"},
     {"192.168.0.0", "true"}, {"192.168.255.255", "true"},
     {"192.169.0.0", "false"}};

    Vector v = new Vector();
    for (int i = 0; i < addrs.length; i++) {
        InetAddress addr = InetAddress.getByName(addrs[i][0]);
        boolean result = new Boolean(addrs[i][1]).booleanValue();
        if (addr.isSiteLocalAddress() != result) {
            v.add(addrs[i]);
        }
    }
    Iterator itr = v.iterator();
    while (itr.hasNext()) {
        String[] entry = (String[]) itr.next();
        System.out.println(entry[0] +" should return "+entry[1]
                           + " when calling isSiteLocalAddress()");
    }
    if (v.size() > 0) {
        throw new RuntimeException("InetAddress.isSiteLocalAddress() test failed");
    }
}
 
Example 12
Source File: isSiteLocalAddress.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String[][] addrs =
    {{"9.255.255.255", "false"}, {"10.0.0.0", "true"},
     {"10.255.255.255", "true"}, {"11.0.0.0", "false"},
     {"172.15.255.255", "false"}, {"172.16.0.0", "true"},
     {"172.30.1.2", "true"}, {"172.31.255.255", "true"},
     {"172.32.0.0", "false"}, {"192.167.255.255", "false"},
     {"192.168.0.0", "true"}, {"192.168.255.255", "true"},
     {"192.169.0.0", "false"}};

    Vector v = new Vector();
    for (int i = 0; i < addrs.length; i++) {
        InetAddress addr = InetAddress.getByName(addrs[i][0]);
        boolean result = new Boolean(addrs[i][1]).booleanValue();
        if (addr.isSiteLocalAddress() != result) {
            v.add(addrs[i]);
        }
    }
    Iterator itr = v.iterator();
    while (itr.hasNext()) {
        String[] entry = (String[]) itr.next();
        System.out.println(entry[0] +" should return "+entry[1]
                           + " when calling isSiteLocalAddress()");
    }
    if (v.size() > 0) {
        throw new RuntimeException("InetAddress.isSiteLocalAddress() test failed");
    }
}
 
Example 13
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public java.util.Iterator getPrefixes(String uri) {
    Vector prefixes = null;
    Iterator itr = null;

    if (uri != null) {
        uri = fSymbolTable.addSymbol(uri);
    }

    if (userContext != null) {
        itr = userContext.getPrefixes(uri);
    }

    if (internalContext != null) {
        prefixes = internalContext.getPrefixes(uri);
    }

    if ((prefixes == null) && (itr != null)) {
        return itr;
    } else if ((prefixes != null) && (itr == null)) {
        return new ReadOnlyIterator(prefixes.iterator());
    } else if ((prefixes != null) && (itr != null)) {
        String ob = null;

        while (itr.hasNext()) {
            ob = (String) itr.next();

            if (ob != null) {
                ob = fSymbolTable.addSymbol(ob);
            }

            if (!prefixes.contains(ob)) {
                prefixes.add(ob);
            }
        }

        return new ReadOnlyIterator(prefixes.iterator());
    }

    return fReadOnlyIterator;
}
 
Example 14
Source File: UserPluginMetadataFormatTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Iterator getImageTypes(int imageIndex) throws IOException {
    if (input == null)
        throw new IllegalStateException();
    if (imageIndex >= 5 || imageIndex < 0)
        throw new IndexOutOfBoundsException();

    Vector imageTypes = new Vector();
    imageTypes.add(ImageTypeSpecifier.createFromBufferedImageType
                   (BufferedImage.TYPE_BYTE_GRAY ));
    return imageTypes.iterator();
}
 
Example 15
Source File: UnitTestController.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 *  INITTASK executed in the unit test controller VM.
 */
public static void scheduleUnitTests() {

  // Initialize information about the hosts and all
  try {
    dunit.impl.HostImpl.initialize();
  } catch( RemoteException e ) {
    throw new HydraRuntimeException( "While initializing HostImpl...", e );
  }
  setUnitTestResult(Boolean.TRUE, false);
  // Run the unit tests
  boolean UnitTestResult = true;
  final Vector unitTests = TestConfig.getInstance().getUnitTests();
  observer.testTypeDetected(TestType.DUNIT);
  observer.totalTestCountDetected(unitTests.size());
  Log.getLogWriter().info("sssControllerUnitTestsCount:"+unitTests.size());
  for ( Iterator i = unitTests.iterator(); i.hasNext(); ) {
    TestTask unitTest = (TestTask) i.next();
    if (isTestAvailable(unitTest)) {
      UnitTestResult = scheduleUnitTest( unitTest ) && UnitTestResult;
      observer.incCurrentTestCount();
      Log.getLogWriter().info("sssCURRENT TEST COUNT:"+Swarm.getCurrentUnitTestCount()+"/"+Swarm.getTotalUnitTestCount());
    }
  }
  if ( ! UnitTestResult ) {
    if ( ! hasFailureOccured ) {
      hasFailureOccured = true;
      setUnitTestResult(Boolean.FALSE, true);
    }
  }
}
 
Example 16
Source File: DubboCommonPanel.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 5 votes vote down vote up
private List<MethodArgument> getMethodArgsData(Vector<Vector<String>> data) {
    List<MethodArgument> params = new ArrayList<MethodArgument>();
    if (!data.isEmpty()) {
        //处理参数
        Iterator<Vector<String>> it = data.iterator();
        while(it.hasNext()) {
            Vector<String> param = it.next();
            if (!param.isEmpty()) {
                params.add(new MethodArgument(param.get(0), param.get(1)));
            }
        }
    }
    return params;
}
 
Example 17
Source File: right_Modeller_1.135.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
     Called from the parser when an interface declaration is found.

     @param name The name of the interface.
     @param modifiers A sequence of interface modifiers.
     @param interfaces Zero or more strings with the names of extended
     interfaces. Can be fully qualified or just a
     simple interface name.
     @param javadoc The javadoc comment. "" if no comment available.
  */
  public void addInterface(String name,
                           short modifiers,
                           Vector interfaces,
                           String javadoc) {
      Object mInterface =
   addClassifier(Model.getCoreFactory().createInterface(),
	  name,
	  modifiers,
	  javadoc);

      // only do generalizations and realizations on the 2nd pass.
      Object level = this.getAttribute("level");
      if (level != null) {
          if (level.equals(new Integer(0))) {
              return;
          }
      }

      for (Iterator i = interfaces.iterator(); i.hasNext();) {
          String interfaceName = (String) i.next();
          try {
              Object parentInterface =
    getContext(interfaceName)
        .getInterface(getClassifierName(interfaceName));
              getGeneralization(currentPackage, parentInterface, mInterface);
          } catch (ClassifierNotFoundException e) {
// Currently if a classifier cannot be found in the
              // model/classpath then information will be lost from
              // source files, because the classifier cannot be
              // created on the fly.
              LOG.warn("Modeller.java: a classifier that was in the source"
	 + " file could not be generated in the model "
	 + "(to generate a generalization)- information lost",
	 e);
          }
      }
  }
 
Example 18
Source File: NamespaceContextWrapper.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * TODO: Namespace doesn't give information giving multiple prefixes for
 * the same namespaceURI.
 */
public java.util.Iterator getPrefixes(String namespaceURI) {
    if (namespaceURI == null) {
        throw new IllegalArgumentException("URI can't be null.");
    }
    else {
        Vector vector =
            ((NamespaceSupport) fNamespaceContext).getPrefixes(namespaceURI.intern());
        return vector.iterator();
    }
}
 
Example 19
Source File: BaseCourseOfferingImport.java    From unitime with Apache License 2.0 4 votes vote down vote up
private boolean addUpdateClassEvent(Class_ c, Vector<Meeting> meetings, TimePattern tp, DatePattern dp) {
	boolean changed = false;
	Date approvedTime = new Date();
	ClassEvent origEvent = c.getEvent();
	Meeting.Status status = (c.isCancelled() ? Meeting.Status.CANCELLED : Meeting.Status.APPROVED);
	if(meetings != null && !meetings.isEmpty() && origEvent==null){
		ClassEvent newEvent = new ClassEvent();
		newEvent.setClazz(c); c.setEvent(newEvent);
		newEvent.setMaxCapacity(c.getMaxExpectedCapacity());
		newEvent.setMinCapacity(c.getExpectedCapacity());
		newEvent.setEventName(c.getSchedulingSubpart().getInstrOfferingConfig().getCourseName() + " " + c.getSchedulingSubpart().getItype().getAbbv().trim() + " " + c.getClassSuffix());
		for(Iterator<Meeting> mIt = meetings.iterator(); mIt.hasNext(); ){
			Meeting meeting = (Meeting) mIt.next();
			meeting.setEvent(newEvent);
			meeting.setStatus(status);
			meeting.setApprovalDate(approvedTime);
			newEvent.addTomeetings(meeting);
		}
		getHibSession().save(newEvent);
		assignmentHelper.createAssignment(newEvent, tp, dp);
		changed = true; 
		addNote("\tdid not find matching event, added new event: " + c.getSchedulingSubpart().getInstrOfferingConfig().getCourseName() + " " + c.getSchedulingSubpart().getItype().getAbbv().trim() + " " + c.getClassSuffix());
		ChangeLog.addChange(getHibSession(), getManager(), session, newEvent, ChangeLog.Source.DATA_IMPORT_OFFERINGS, ChangeLog.Operation.CREATE, c.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea(), c.getSchedulingSubpart().getControllingCourseOffering().getDepartment());
	} else if (origEvent!=null) {
		if (!origEvent.getEventName().equals(c.getSchedulingSubpart().getInstrOfferingConfig().getCourseName() + " " + c.getSchedulingSubpart().getItype().getAbbv().trim() + " " + c.getClassSuffix())){
			origEvent.setEventName(c.getSchedulingSubpart().getInstrOfferingConfig().getCourseName() + " " + c.getSchedulingSubpart().getItype().getAbbv().trim() + " " + c.getClassSuffix());
			changed = true;
			addNote("\tevent name changed");
		}
		if (origEvent.getMinCapacity() != null && c.getExpectedCapacity() != null && !origEvent.getMinCapacity().equals(c.getExpectedCapacity())
				|| (origEvent.getMinCapacity() != null && c.getExpectedCapacity() == null)
				|| (origEvent.getMinCapacity() == null && c.getExpectedCapacity() != null)){
			origEvent.setMinCapacity(c.getExpectedCapacity());
			changed = true;
			addNote("\tevent minimum capacity changed.");
		}
		if (origEvent.getMaxCapacity() != null && c.getMaxExpectedCapacity() != null && !origEvent.getMaxCapacity().equals(c.getMaxExpectedCapacity())
				|| (origEvent.getMaxCapacity() != null && c.getMaxExpectedCapacity() == null)
				|| (origEvent.getMaxCapacity() == null && c.getMaxExpectedCapacity() != null)){
			origEvent.setMaxCapacity(c.getMaxExpectedCapacity());
			changed = true;
			addNote("\tevent maximum capacity changed.");
		}
           Set origMeetings = new TreeSet<Object>();
           origMeetings.addAll(origEvent.getMeetings());
           if (meetings != null){
               for(Iterator<Meeting> nmIt = meetings.iterator(); nmIt.hasNext(); ){
                   Meeting newMeeting = (Meeting) nmIt.next();
                   boolean found = false;
                   for(Iterator<?> omIt = origMeetings.iterator(); omIt.hasNext(); ){
                       Meeting origMeeting = (Meeting) omIt.next();
                       if(isSameMeeting(origMeeting, newMeeting)){
                           found = true;
                           origMeetings.remove(origMeeting);
                           if (status != origMeeting.getStatus()) {
                           	origMeeting.setStatus(status);
                           	changed = true;
                           }
                           break;
                       }
                   }
                   if (!found){
                       addNote("\tdid not find matching meeting, adding new meeting to event: " + c.getClassLabel());
                       newMeeting.setEvent(origEvent);
                       newMeeting.setStatus(status);
                       newMeeting.setApprovalDate(approvedTime);
                       origEvent.addTomeetings(newMeeting);
                       changed = true;
                   }
               }
           }
           if (!origMeetings.isEmpty()){
               addNote("\tsome existing meetings did not have matches in input, deleted them: " + c.getClassLabel());
               for(Iterator<?> mIt = origMeetings.iterator(); mIt.hasNext(); ){
                   Meeting m = (Meeting) mIt.next();
                   origEvent.getMeetings().remove(m);
                   m.setEvent(null);
                   ChangeLog.addChange(getHibSession(), getManager(), session, m, ChangeLog.Source.DATA_IMPORT_OFFERINGS, ChangeLog.Operation.DELETE, c.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea(), c.getSchedulingSubpart().getControllingCourseOffering().getDepartment());
                   getHibSession().delete(m);
                   changed = true;
               }
           }
           if (changed){
               assignmentHelper.createAssignment(origEvent, tp, dp);
               ChangeLog.addChange(getHibSession(), getManager(), session, origEvent, ChangeLog.Source.DATA_IMPORT_OFFERINGS, ChangeLog.Operation.UPDATE, c.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea(), c.getSchedulingSubpart().getControllingCourseOffering().getDepartment());   
               getHibSession().update(origEvent);
           }
	}
			
	return(changed);
}
 
Example 20
Source File: TestConfig.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private void setNumClients( Vector tasks, Map vms ) {
  for ( Iterator i = tasks.iterator(); i.hasNext(); ) {
    TestTask task = (TestTask) i.next();
    setNumClients( task, vms );
  }
}