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

The following are Jave code examples for showing how to use iterator() 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: iot-plat   File: DBConnectionManager.java   View Source Code Vote up 8 votes
/**
 * 装载和注册所有JDBC 驱动程序
 *
 * @param props 属性
 */
private void loadDrivers(Vector driverBeans) {
	logger.debug("----------------------->");
	Iterator iterator = driverBeans.iterator();
	while (iterator.hasNext()) {
		DSConfigBean dsConfigBean = (DSConfigBean)iterator.next();
		try {
			if (dsConfigBean.getDriver() != null && !"".equals(dsConfigBean.getDriver())){
				Driver driver = (Driver) Class.forName(dsConfigBean.getDriver())
						.newInstance();
				DriverManager.registerDriver(driver);
				drivers.addElement(driver);
				logger.debug("成功注册JDBC 驱动程序" + dsConfigBean.getDriver());
			}
		} catch (Exception e) {
			logger.error("注册驱动程序出错,",e);
		}
	}
}
 
Example 2
Project: AgentWorkbench   File: ReflectClass.java   View Source Code Vote up 7 votes
/**
 * Constructor for this class.  
 * @param clazz the class out of the ontology
 * @param clazzSlots the list of slots defined in the vocabulary of an ontology
 */
public ReflectClass(Class<?> clazz, Hashtable<String, String> clazzSlots ){
	
	currClass = clazz;
	currClassSlots = clazzSlots;
	currSlotList = new Slot[currClassSlots.size()];
	int currSlotListCounter = -1;
	
	Vector<String> v = new Vector<String>(currClassSlots.keySet());
    Collections.sort(v);
	Iterator<String> it = v.iterator();
    while (it.hasNext()) {
    	// --- Slot der Klasse ermitteln und untersuchen ----- 
    	String key = it.next();
    	String word = currClassSlots.get(key);
    	
    	Slot currSlot = new Slot(word);
    	currSlotListCounter++;
    	currSlotList[currSlotListCounter] = currSlot;
    }
}
 
Example 3
Project: jmt   File: DistributionsEditor.java   View Source Code Vote up 6 votes
/**
 * Helper method to extract the probability components the dialog's
 * components. These components are the probability labels and the
 * probability TextFields.
 * 
 * @return a Vector of probability related components
 * @author Federico Dal Castello
 */
private Vector<Component> getProbabilityComponents() {
	Vector<Component> probabilityComponents = new Vector<Component>();

	Vector<Component> components = new Vector<Component>();
	components.addAll(Arrays.asList(intervalPanels[1].getComponents()));
	components.addAll(Arrays.asList(intervalPanels[2].getComponents()));

	Iterator<Component> it = components.iterator();

	while (it.hasNext()) {
		Component comp = it.next();

		if (comp instanceof JTextField) {
			if (comp.getName().equals(PROBABILITY_INTERVAL_A)
					|| comp.getName().equals(PROBABILITY_INTERVAL_B)) {
				probabilityComponents.add(comp);
			}
		}

		if (comp instanceof JLabel
				&& ((JLabel) comp).getText().equals(PROBABILITY)) {
			probabilityComponents.add(comp);
		}
	}

	return probabilityComponents;
}
 
Example 4
Project: munche_prog   File: dataBaseFunctions.java   View Source Code Vote up 6 votes
/**
 * 
 * @param myFilter get filter
 * @param dataBase to filter it
 * filtering the database with the filter
 */
public static void filterDataBase(filter myFilter,Vector<sameScanWifi> dataBase){
	for (Iterator<sameScanWifi> sameScanWifiIterator = dataBase.iterator(); sameScanWifiIterator.hasNext(); ) {
		if(!myFilter.filters(sameScanWifiIterator.next())){
			sameScanWifiIterator.remove();
		}
	}

}
 
Example 5
Project: openjdk-jdk10   File: SimpleRenderedImage.java   View Source Code Vote up 6 votes
/**
 * Returns an array of <code>String</code>s recognized as names by
 * this property source that begin with the supplied prefix.  If
 * no property names match, <code>null</code> will be returned.
 * The comparison is done in a case-independent manner.
 *
 * <p> The default implementation calls
 * <code>getPropertyNames()</code> and searches the list of names
 * for matches.
 *
 * @return an array of <code>String</code>s giving the valid
 * property names.
 */
public String[] getPropertyNames(String prefix) {
    String propertyNames[] = getPropertyNames();
    if (propertyNames == null) {
        return null;
    }

    prefix = prefix.toLowerCase();

    Vector<String> names = new Vector<String>();
    for (int i = 0; i < propertyNames.length; i++) {
        if (propertyNames[i].startsWith(prefix)) {
            names.addElement(propertyNames[i]);
        }
    }

    if (names.size() == 0) {
        return null;
    }

    // Copy the strings from the Vector over to a String array.
    String prefixNames[] = new String[names.size()];
    int count = 0;
    for (Iterator<String> it = names.iterator(); it.hasNext(); ) {
        prefixNames[count++] = it.next();
    }

    return prefixNames;
}
 
Example 6
Project: MaxSim   File: WinGammaPlatformVC10.java   View Source Code Vote up 6 votes
void tagV(Vector<String> v) {
    Iterator<String> i = v.iterator();
    while(i.hasNext()) {
        String name = i.next();
        String data = i.next();
        tagData(name, data);
    }
}
 
Example 7
Project: AgentWorkbench   File: ProjectWindow.java   View Source Code Vote up 6 votes
/**
 * This method removes all ProjectWindowTabs from the current display.
 */
private void removeAllProjectWindowTabsTemporary4Rebuilding() {

	Vector<ProjectWindowTab> pwtVector = new Vector<ProjectWindowTab>(this.tabVector);
	for (Iterator<ProjectWindowTab> it = pwtVector.iterator(); it.hasNext();) {

		ProjectWindowTab pwt = it.next();
		if (pwt.getCompForChildComp() != null) {
			pwt.getCompForChildComp().removeAll();
		}
	}
	this.getRootNode().removeAllChildren();
	this.projectViewRightTabs.removeAll();
}
 
Example 8
Project: logistimo-web-service   File: MachineProtocolMessageHandler.java   View Source Code Vote up 6 votes
private void storeResponseMessages(String address, String messageId, Vector<String> messages,
                                   String countryCode) throws MessageHandlingException {
  xLogger.fine("Entered storeResponseMessages");
  IMultipartMsg mmsg = JDOUtils.createInstance(IMultipartMsg.class);
  mmsg.setId(JDOUtils.createMultipartMsgKey(address, messageId));
  mmsg.setTimestamp(new Date());
  mmsg.setCountry(countryCode);
  Iterator<String> it = messages.iterator();
  while (it.hasNext()) {
    mmsg.addMessage(it.next());
  }
  com.logistimo.utils.MessageUtil.storeMultipartMsg(mmsg);
  xLogger.fine("Exiting storeResponseMessages");
}
 
Example 9
Project: ramus   File: GroupableTableColumnModel.java   View Source Code Vote up 6 votes
/**
 * Provides and iterator for accessing the ColumnGroups
 * associated with a column.
 *
 * @param col Column
 * @return ColumnGroup iterator
 */
@SuppressWarnings("unchecked")
public Iterator getColumnGroups(TableColumn col) {
    if (columnGroups.isEmpty()) return null;
    Iterator iter = columnGroups.iterator();
    while (iter.hasNext()) {
        ColumnGroup cGroup = (ColumnGroup) iter.next();
        Vector v_ret = cGroup.getColumnGroups(col, new Vector());
        if (v_ret != null) {
            return v_ret.iterator();
        }
    }
    return null;
}
 
Example 10
Project: AgentWorkbench   File: BaseLoadBalancing.java   View Source Code Vote up 6 votes
/**
 * start agents on their assigned locations.
 *
 * @param agentContainerList the agent container list
 * @param verbose the verbose
 * @return true, if successful
 */
protected boolean startAgentsOnContainers(Hashtable<Location, ArrayList<AgentClassElement4SimStart>> agentContainerList, boolean verbose){
	
	if(agentContainerList != null){
		/** all locations agents are mapped to*/
		Vector<Location> locations = new Vector<Location>(agentContainerList.keySet());
		/** iterator for locations*/
		Iterator<Location> loctionIterator = locations.iterator();
		
		while (loctionIterator.hasNext() == true) {		
			
			Location location = loctionIterator.next();	
			
			for (Iterator<AgentClassElement4SimStart> it = agentContainerList.get(location).iterator(); it.hasNext();) {
				
				// --- Get the agent, which has to be started ------------
				AgentClassElement4SimStart agent2Start = it.next();
				// --- Check for start arguments -------------------------
				Object[] startArgs = getStartArguments(agent2Start);	
				// --- finally start the agent -----------------------				
				boolean success = this.startAgent(agent2Start.getStartAsName(), agent2Start.getAgentClassReference(), startArgs, location);
				
				if(success && verbose){
					System.out.println("Agent "+ agent2Start.getStartAsName() + " started on "+ location.getName());
				}					
			}
		} // --- end while
		return true;
	}	
	return false;
}
 
Example 11
Project: openjdk-jdk10   File: NamespaceContextWrapper.java   View Source Code Vote up 6 votes
/**
 * 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 12
Project: MaxSim   File: WinGammaPlatform.java   View Source Code Vote up 6 votes
public boolean findString(Vector v, String s) {
    for (Iterator iter = v.iterator(); iter.hasNext(); ) {
        if (((String) iter.next()).equals(s)) {
            return true;
        }
    }

    return false;
}
 
Example 13
Project: unitimes   File: BaseCourseOfferingImport.java   View Source Code Vote up 6 votes
private String createPatternString(Vector<Calendar> startDates, Vector<Calendar> endDates){
	Iterator<Calendar> startDateIt = startDates.iterator();
	Iterator<Calendar> endDateIt = endDates.iterator();
			
	StringBuffer patternString = new StringBuffer();
	Calendar lastDate = null;
	while(startDateIt.hasNext() && endDateIt.hasNext()){
		Calendar startDate = Calendar.getInstance();
		startDate.setTime(((Calendar) startDateIt.next()).getTime());
		
		Calendar endDate = Calendar.getInstance();
		endDate.setTime(((Calendar) endDateIt.next()).getTime());
		

		if (lastDate != null){
			lastDate.add(Calendar.DAY_OF_MONTH, 1);
			while(getCalendarDateString(lastDate).compareTo(getCalendarDateString(startDate)) < 0){
				patternString.append("0");
				lastDate.add(Calendar.DAY_OF_MONTH, 1);
			}
		} 
		lastDate = endDate;
		
		while(getCalendarDateString(startDate).compareTo(getCalendarDateString(endDate)) <= 0) {
			patternString.append("1");
			startDate.add(Calendar.DAY_OF_MONTH, 1);				
		}
	}
	return(patternString.toString());
}
 
Example 14
Project: Dahlem_SER316   File: TaskListVersioning.java   View Source Code Vote up 6 votes
public static boolean upgradeTaskList(String publicId) {
    int vid = getIndexOfVersion(publicId);
    
    if (vid == (VERSIONS.length - 1)) {
        Util.debug("Version " + publicId + " is the latest version, skipping upgrade");
        return false;
    }
    else {
        // get all projects
        Vector projects = ProjectManager.getAllProjects();
        String[] projectIds = new String[projects.size()];
        int c = 0;
        for (Iterator iter = projects.iterator(); iter.hasNext();) {
            Project prj = (Project) iter.next();
            projectIds[c++] = prj.getID();
        }
        
        // keep upgrading until it's the current version
        while (vid < (VERSIONS.length - 1)) {
            if(vid == 0) {
                upgrade1_1d1(projectIds);
            }            
            vid++;
        }
        return true;
    }
}
 
Example 15
Project: SER316-Aachen   File: TaskListVersioning.java   View Source Code Vote up 6 votes
public static boolean upgradeTaskList(String publicId) {
    int vid = getIndexOfVersion(publicId);
    
    if (vid == (VERSIONS.length - 1)) {
        Util.debug("Version " + publicId + " is the latest version, skipping upgrade");
        return false;
    }
    else {
        // get all projects
        Vector projects = ProjectManager.getAllProjects();
        String[] projectIds = new String[projects.size()];
        int c = 0;
        for (Iterator iter = projects.iterator(); iter.hasNext();) {
            Project prj = (Project) iter.next();
            projectIds[c++] = prj.getID();
        }
        
        // keep upgrading until it's the current version
        while (vid < (VERSIONS.length - 1)) {
            if(vid == 0) {
                upgrade1_1d1(projectIds);
            }            
            vid++;
        }
        return true;
    }
}
 
Example 16
Project: SER316-Dresden   File: TaskListVersioning.java   View Source Code Vote up 6 votes
public static boolean upgradeTaskList(String publicId) {
    int vid = getIndexOfVersion(publicId);
    
    if (vid == (VERSIONS.length - 1)) {
        Util.debug("Version " + publicId + " is the latest version, skipping upgrade");
        return false;
    }
    else {
        // get all projects
        Vector projects = ProjectManager.getAllProjects();
        String[] projectIds = new String[projects.size()];
        int c = 0;
        for (Iterator iter = projects.iterator(); iter.hasNext();) {
            Project prj = (Project) iter.next();
            projectIds[c++] = prj.getID();
        }
        
        // keep upgrading until it's the current version
        while (vid < (VERSIONS.length - 1)) {
            if(vid == 0) {
                upgrade1_1d1(projectIds);
            }            
            vid++;
        }
        return true;
    }
}
 
Example 17
Project: routerapp   File: PropertyInteractionDialog.java   View Source Code Vote up 5 votes
/**
 * 
 */
private void buildFields() {
	Vector properties = component.getProperties().getAllProperties();
	GridLayout layout = new GridLayout(properties.size(),2,10,10);
	int cells = 0;
	
	Iterator i = properties.iterator();
	JPanel fieldsPane = new JPanel(layout);
	fieldsPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
	
	while (i.hasNext()) {
		try {
			InteractiveProperty property = (InteractiveProperty) i.next();
			
			final JTextField field = new JTextField(property.toString());
			field.addKeyListener(new KeyAdapter() {
				public void keyReleased(KeyEvent e) {
					if (e.getKeyCode() == KeyEvent.VK_ENTER) {
						applyChanges();
					}
					else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
						cancelChanges();
					}
				}
			});
			field.addFocusListener(new FocusAdapter() {
				
				public void focusGained(FocusEvent evt) {
					String text = field.getText();
					field.setSelectionStart(0);
					field.setSelectionEnd(text.length());
				}
			});
			field.setMaximumSize(new Dimension(150,30));
			fields.put(property,field);
			
			fieldsPane.add(new JLabel(property.getName()));
			fieldsPane.add(field);
			
			cells++;
		} catch (ClassCastException exc) {
			/* 
			 * caught to be ignored, so that non-interactive properties
			 * won't be shown in the GUI
			 */
		}
	}
	this.setSize(200,cells * CELL_HEIGHT);
	getContentPane().add(fieldsPane,BorderLayout.CENTER);
}
 
Example 18
Project: SER316-Aachen   File: AgendaGenerator.java   View Source Code Vote up 5 votes
static String generateEventsInfo(CalendarDate date) {
	String s =
			"<td width=\"34%\" valign=\"top\">"
					+ "<center><a href=\"memoranda:events\"><h1>"
					+ Local.getString("Events")
					+ "</h1></a></center>\n"
					+ "<table width=\"100%\" valign=\"top\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFF6\">\n";
	Vector v = (Vector) EventsManager.getEventsForDate(date);
	int n = 0;
	for (Iterator i = v.iterator(); i.hasNext();) {
		Event e = (Event) i.next();
		String txt = e.getText();
		String iurl =
				net
				.sf
				.memoranda
				.ui
				.AppFrame
				.class
				.getResource("resources/agenda/spacer.gif")
				.toExternalForm();
		if (date.equals(CalendarDate.today())) {
			if (e.getTime().after(new Date()))
				txt = "<b>" + txt + "</b>";
			if ((EventsScheduler.isEventScheduled())
					&& (EventsScheduler
							.getFirstScheduledEvent()
							.getTime()
							.equals(e.getTime()))) {
				iurl =
						net
						.sf
						.memoranda
						.ui
						.AppFrame
						.class
						.getResource("resources/agenda/arrow.gif")
						.toExternalForm();
			}
		}
		String icon =
				"<img align=\"right\" width=\"16\" height=\"16\" src=\""
						+ iurl
						+ "\" border=\"0\"  hspace=\"0\" vspace=\"0\" alt=\"\">";

		s += "<tr>\n<td>"
				+ icon
				+ "</td>"
				+ "<td nowrap class=\"eventtime\">"
				+ e.getTimeString()
				+ "</td>"
				+ "<td width=\"100%\" class=\"eventtext\">&nbsp;&nbsp;"
				+ txt
				+ "</td>\n"
				+ "</tr>";

	}
	return s + "</table>";
}
 
Example 19
Project: unitimes   File: BaseCourseOfferingImport.java   View Source Code Vote up 5 votes
private void addDistributionPref(Vector<String> classIds, Class_ clazz, DistributionType distributionType) throws Exception{
	if (classIds.size() <= 1){
		throw (new Exception("There must be at least two classes to have a meets with distribution preference: " + clazz.getClassLabel()));
	}
	Class_ c = null;
	Vector<String> tmpClassIds = new Vector<String>();
	tmpClassIds.addAll(classIds);
	Vector<Class_> classes = new Vector<Class_>();
	String externalId = null;
	for (Iterator<?> eIt = classIds.iterator(); eIt.hasNext();){
		externalId = (String) eIt.next();
		if (externalId.equals(getExternalUniqueId(clazz))){
			classes.add(clazz);
			tmpClassIds.remove(externalId);
		} else {
			 c = findClassForExternalUniqueId(externalId);
			 if (c == null){
				 break;
			 } else {
				 classes.add(c);
				 tmpClassIds.remove(externalId);
			 }
		}
	}
	if (!tmpClassIds.isEmpty()){
		addNote("\t not all classes for this meets with pref exist yet, will add it later:" + clazz.getClassLabel());
	} else {
		DistributionPref dp = new DistributionPref();
		dp.setDistributionType(distributionType);
		dp.setStructure(DistributionPref.Structure.AllClasses);
		dp.setPrefLevel(requiredPrefLevel);
		dp.setOwner(clazz.getSchedulingSubpart().getControllingDept());
		for (Iterator<Class_> cIt = classes.iterator(); cIt.hasNext();){
			c = (Class_) cIt.next();
			DistributionObject distObj = new DistributionObject();
			distObj.setDistributionPref(dp);
			distObj.setPrefGroup(c);
			dp.addTodistributionObjects(distObj);
			c.addTodistributionObjects(distObj);
		}
		getHibSession().save(dp);
		getHibSession().flush();
		getHibSession().refresh(dp);
        ChangeLog.addChange(getHibSession(), getManager(), session, dp, ChangeLog.Source.DATA_IMPORT_OFFERINGS, ChangeLog.Operation.CREATE, null, clazz.getSchedulingSubpart().getControllingDept());       
	}	
	
}
 
Example 20
Project: AgentWorkbench   File: OntologyClassTreeObject.java   View Source Code Vote up 5 votes
/**
 * This returns the 'DefaultTableModel' for a single
 * class out of the ontology-classes.
 *
 * @return the table model4 slot
 */
public DefaultTableModel getTableModel4Slot() {
	
	DefaultTableModel tm4s = new DefaultTableModel();
	tm4s.addColumn("Name");
	tm4s.addColumn("Cardinality");
	tm4s.addColumn("Type");
	tm4s.addColumn("Other Facets");		

	if (ontologySubClass == null) {
		return tm4s;
	}
	
	// --- Nach den entsprechenden Slots im Vokabular filtern ---
	Hashtable<String, String> ontoSlotHash = ontologyClass.ontologieVocabulary.getSlots(ontologySubClass);
	ReflectClass reflectedClass = new ReflectClass(ontologySubClass, ontoSlotHash);
	
	Vector<String> v = new Vector<String>( ontoSlotHash.keySet() );
    Collections.sort(v);
    Iterator<String> it = v.iterator();
    while (it.hasNext()) {
    	
    	// --- Get Word of the ontology ------------------------- 
    	String key = it.next();
    	String word = ontoSlotHash.get(key);
    	
    	// --- Get Slot... --------------------------------------
    	Slot currSlot = reflectedClass.getSlot(word);
    	
    	// --- Add table row ------------------------------------	    	
    	Vector<String> rowData = new Vector<String>(); 
    	rowData.add(word );
    	rowData.add(currSlot.Cardinality);
    	rowData.add(currSlot.VarType);
    	rowData.add(currSlot.OtherFacts);
    	tm4s.addRow(rowData);
    }	
    
    // ----------------------------------------------------------
    // --- Are there slots from the parent Node? ----------------
    // ----------------------------------------------------------
    if (parentOntologyClassTreeObject!=null) {
    	DefaultTableModel subTBmodel = parentOntologyClassTreeObject.getTableModel4Slot();
    	Vector<?> subDataVector = subTBmodel.getDataVector();
    	for (int i = 0; i < subDataVector.size(); i++) {
    		Vector<?> rowVector = (Vector<?>) subDataVector.get(i);
    		tm4s.addRow(rowVector);
		}
    	Sorter.sortTableModel(tm4s, 0);
    }
    // ----------------------------------------------------------
    return tm4s;		
}