List of usage examples for java.util Vector iterator
public synchronized Iterator<E> iterator()
From source file:org.kepler.objectmanager.repository.EcogridRepository.java
/** * Search the repository and return an iterator of EcogridRepositoryResults. * /*from w w w .j a v a2s. c o m*/ * @param queryDocument * - the query document to give the QueryServiceClient * @return * @throws RepositoryException * @throws AuthenticationException */ public Iterator<EcogridRepositoryResults> advancedSearch(Reader queryDocument, boolean authenticate) throws RepositoryException, AuthenticationException { Vector<EcogridRepositoryResults> resultsVector = new Vector<EcogridRepositoryResults>(); ResultsetType rst = arbitrarySearch(queryDocument, authenticate); if (rst == null) { // check to see if the resultsettype is null return null; } ResultsetTypeRecord[] records = rst.getRecord(); if (records == null || records.length == 0) { // check to see if // there are records return null; } if (isDebugging) { log.debug("There are " + records.length + " records"); } // create the EcogridRepositoryResult object and put it in the // vector for (int i = 0; i < records.length; i++) { try { // catch this here so one result can't hose the whole // resultset List<EcogridRepositoryResults> results = EcogridRepositoryResults .parseKarXml(records[i].getIdentifier(), name, i, authenticate); resultsVector.addAll(results); } catch (Exception e) { System.out .println("could not load result: " + records[i].toString() + " error: " + e.getMessage()); } // ResultsetTypeRecord currentRecord = records[i]; } return resultsVector.iterator(); }
From source file:org.kepler.objectmanager.repository.EcogridRepository.java
/** * Search the repository and return an iterator of EcogridRepositoryResults. * /*w w w. j a va2s .c o m*/ * @see EcogridRepositoryResults * @param queryString * a string to search for * @param authenticate * boolean * @return null if there are no results for the query. An iterator of * EcogridRepositoryResults if there are results. * @throws AuthenticationException */ public Iterator<EcogridRepositoryResults> search(String queryString, boolean authenticate) throws RepositoryException, AuthenticationException { if (isDebugging) { log.debug("search(\"" + queryString + "\")"); } Vector<EcogridRepositoryResults> resultsVector = new Vector<EcogridRepositoryResults>(); //System.out.println("EcogridRepository search(queryString,"+authenticate+") querying with queryString:" + // queryString); ResultsetType rst = arbitrarySearch(buildQueryDoc(queryString), authenticate); if (rst == null) { // check to see if the resultsettype is null return null; } ResultsetTypeRecord[] records = rst.getRecord(); if (records == null || records.length == 0) { // check to see if there are records return null; } if (isDebugging) { log.debug("There are " + records.length + " records"); } // create the EcogridRepositoryResult object and put it in the // vector for (int i = 0; i < records.length; i++) { try { // catch this here so one result can't hose the whole // resultset List<EcogridRepositoryResults> results = EcogridRepositoryResults .parseKarXml(records[i].getIdentifier(), name, i, authenticate); resultsVector.addAll(results); } catch (Exception e) { System.out .println("could not load result: " + records[i].toString() + " error: " + e.getMessage()); } // ResultsetTypeRecord currentRecord = records[i]; } return resultsVector.iterator(); }
From source file:com.globalsight.everest.webapp.pagehandler.edit.inctxrv.EditorPageHandler.java
/** * Initializes editor state from a job, i.e. when the editor is opened by an * Admin or PM./*from ww w .j a v a2 s . com*/ */ private void initializeFromJob(EditorState p_state, HttpServletRequest p_request, String p_jobId, String p_srcPageId, String p_trgPageId, Locale p_uiLocale, User p_user) throws EnvoyServletException { p_state.setUserIsPm(true); HttpSession session = p_request.getSession(); SessionManager sessionMgr = (SessionManager) session.getAttribute(WebAppConstants.SESSION_MANAGER); PermissionSet perms = (PermissionSet) p_request.getSession().getAttribute(WebAppConstants.PERMISSIONS); // Reset all options because the state may be inherited from a // previous page. EditorHelper.initEditorOptions(p_state, p_request.getSession()); // Initializes pages, target locales, excluded items, and termbases EditorHelper.initializeFromJob(p_state, p_jobId, p_srcPageId, p_uiLocale, p_user.getUserId(), perms); if (p_trgPageId != null && p_trgPageId.length() > 0) { // If the PM requests a specific target page... setCurrentPage(p_request.getSession(), p_state, p_srcPageId, p_trgPageId); EditorState.PagePair currentPage = p_state.getCurrentPage(); p_state.setTargetViewLocale(currentPage.getTargetPageLocale(new Long(p_trgPageId))); } else { // No target page/locale requested, find a suitable one. setCurrentPage(p_request.getSession(), p_state, p_srcPageId); // If no locale is set or the set locale doesn't exist in the // list of target locales in the job (fix for def_5545), // determine the default locale to display in target window. GlobalSightLocale viewLocale = p_state.getTargetViewLocale(); Vector trgLocales = p_state.getJobTargetLocales(); GlobalSightLocale local = (GlobalSightLocale) sessionMgr.getAttribute("targetLocale"); if (viewLocale == null || !trgLocales.contains(viewLocale)) { if (trgLocales.contains(local)) { Iterator it = trgLocales.iterator(); while (it.hasNext()) { GlobalSightLocale trgLocale = (GlobalSightLocale) it.next(); if (local.getLocale().equals(trgLocale.getLocale())) { p_state.setTargetViewLocale((GlobalSightLocale) trgLocale); } } } else { p_state.setTargetViewLocale((GlobalSightLocale) trgLocales.elementAt(0)); } } } // When coming from job page, target page is read only. // Fri Feb 20 20:18:44 2004 CvdL: Patch for HP: PMs can edit // all target pages any time at their own risk. if (s_pmCanEditTargetPages && EditorHelper.pmCanEditCurrentPage(p_state)) { p_state.setReadOnly(false); p_state.setAllowEditAll(true); p_state.setEditAllState(EDIT_ALL); } else { p_state.setReadOnly(true); } // Mon Jan 31 18:56:04 2005 CvdL: PM can edit snippets too (12665) p_state.setAllowEditSnippets(s_pmCanEditSnippets); // Indicate that main editor is in 'viewer' mode -- see // dispatchJsp for switching to review mode. // Comments are turned ON by default in popup editor from Job detail // page p_state.setReviewMode(); }
From source file:org.kepler.objectmanager.cache.CacheManager.java
/** * @param type/* w ww . j a v a2 s .co m*/ * @return all cache objects that are of the specified type * @throws CacheException */ public Iterator<CacheObjectInterface> getCacheObjectIterator(String type) throws CacheException { if (isDebugging) log.debug("getCacheObjectIterator(" + type + ")"); try { Vector<CacheObjectInterface> items = new Vector<CacheObjectInterface>(); String sql = "select name, lsid, file, type from " + CACHETABLENAME; if (!type.trim().equals("")) { sql += " WHERE type = '" + type + "'"; } if (isDebugging) log.debug(sql); ResultSet rs = _stmt.executeQuery(sql); while (rs.next()) { String name = rs.getString("name"); String file = rs.getString("file"); String lsidString = rs.getString("lsid"); String coType = rs.getString("type"); if (isDebugging) { log.debug("name: " + name); log.debug("file: " + file); log.debug("lsidString: " + lsidString); log.debug("type: " + coType); } CacheObjectInterface coi = (CacheObjectInterface) objectHash.get(lsidString); if (coi == null) { deserializeCacheObject(file); } items.add(coi); } rs.close(); return items.iterator(); } catch (Exception e) { e.printStackTrace(); throw new CacheException("Error creating CacheObjectInterface iterator. " + "Try removing the ~/.kepler directory?: " + e.getMessage()); } }
From source file:org.unitime.timetable.solver.TimetableSolver.java
public CSVFile export(boolean useAmPm) { Lock lock = currentSolution().getLock().readLock(); lock.lock();/* w ww. j av a 2s . c o m*/ try { CSVFile file = new CSVFile(); file.setSeparator(","); file.setQuotationMark("\""); file.setHeader(new CSVField[] { new CSVField("COURSE"), new CSVField("ITYPE"), new CSVField("SECTION"), new CSVField("SUFFIX"), new CSVField("DATE_PATTERN"), new CSVField("DAY"), new CSVField("START_TIME"), new CSVField("END_TIME"), new CSVField("ROOM"), new CSVField("INSTRUCTOR") }); Vector lectures = new Vector(currentSolution().getModel().variables()); Collections.sort(lectures); for (Iterator i = lectures.iterator(); i.hasNext();) { Lecture lecture = (Lecture) i.next(); Placement placement = currentSolution().getAssignment().getValue(lecture); String name = lecture.getName(); String itype = ""; String section = ""; if (name.indexOf(' ') >= 0) { section = name.substring(name.lastIndexOf(' ') + 1); name = name.substring(0, name.lastIndexOf(' ')).trim(); } String suffix = ""; while (section.charAt(section.length() - 1) >= 'a' && section.charAt(section.length() - 1) <= 'z') { suffix = section.charAt(section.length() - 1) + suffix; section = section.substring(0, section.length() - 1); } if (name.indexOf(' ') >= 0) { itype = name.substring(name.lastIndexOf(' ') + 1); name = name.substring(0, name.lastIndexOf(' ')).trim(); } try { Integer.parseInt(itype); itype = name.substring(name.lastIndexOf(' ') + 1) + " " + itype; name = name.substring(0, name.lastIndexOf(' ')).trim(); } catch (NumberFormatException e) { } file.addLine(new CSVField[] { new CSVField(name), new CSVField(itype), new CSVField(section), new CSVField(suffix), new CSVField(placement == null ? "" : placement.getTimeLocation().getDatePatternName()), new CSVField(placement == null ? "" : placement.getTimeLocation().getDayHeader()), new CSVField( placement == null ? "" : placement.getTimeLocation().getStartTimeHeader(useAmPm)), new CSVField( placement == null ? "" : placement.getTimeLocation().getEndTimeHeader(useAmPm)), new CSVField(placement == null ? "" : placement.getRoomName(",")), new CSVField(lecture.getInstructorName() == null ? "" : lecture.getInstructorName()) }); } return file; } finally { lock.unlock(); } }
From source file:org.apache.axis.message.MessageElement.java
/** * get an iterator of the prefixes. The iterator * does not get updated in response to changes in the namespace list. * @return an iterator over a vector of prefixes * @see javax.xml.soap.SOAPElement#getNamespacePrefixes() *//*from w w w . ja va 2 s .com*/ public Iterator getNamespacePrefixes() { Vector prefixes = new Vector(); for (int i = 0; namespaces != null && i < namespaces.size(); i++) { prefixes.add(((Mapping) namespaces.get(i)).getPrefix()); } return prefixes.iterator(); }
From source file:com.globalsight.everest.usermgr.UserManagerLocal.java
/** * @see UserManager.getUserIdsByFilter(String, Project) *//*from w ww .ja va 2s. co m*/ public String[] getUserIdsByFilter(String p_roleName, Project p_project) throws RemoteException, UserManagerException { String[] userIds = null; if (p_roleName != null) { // // check out a connection from the connection pool // DirContext dirContext = checkOutConnection(false); // setConnectionOptions(dirContext); // try // { // userIds = getUserIdsFromRole(p_roleName, dirContext); // } // catch (Exception e) // { // String[] errorMsgArg = new String[] // { UserManagerException.ARG_FAILED_TO_GET_USERS_ENTRIES }; // CATEGORY.error("UserManagerException is thrown from: " // + "UserManagerLocal::getUserNamesByRole(): " // + errorMsgArg[0], e); // throw new UserManagerException( // UserManagerException.MSG_GET_USERS_ERROR, errorMsgArg, // e); // } // finally // { // // return the connection to the pool // checkInConnection(dirContext); // } List<String> allIds = new ArrayList<String>(); ContainerRoleImpl c = RoleDatabaseHelper.getContainerRoleByName(p_roleName); if (c != null) { allIds.addAll(c.getUserIds()); } UserRoleImpl ur = RoleDatabaseHelper.getUserRoleByName(p_roleName); if (ur != null) { allIds.add(ur.getUser()); } userIds = new String[allIds.size()]; userIds = (String[]) allIds.toArray(userIds); } else { // role is null, so just get all users and then let the filter sort // it out Vector allUsers = getUsers(); userIds = new String[allUsers.size()]; Iterator userIter = allUsers.iterator(); int i = 0; while (userIter.hasNext()) { User u = (User) userIter.next(); userIds[i++] = u.getUserId(); } } // if project was specified then filter by it if (p_project != null) { return filterUsersByProject(userIds, p_project); } else // otherwise just return the ones found { return userIds; } }
From source file:org.apache.jetspeed.services.profiler.JetspeedProfilerService.java
/** * Merge role profiles to create default profile. Resulting psml will be a set * of tabs. If role's psml is a tab control, each tab is placed in the * resulting psml as is. Otherwise, a new tab is created and psml is placed * there. In this case, tab name will be derived from role's name. For * example, if role name is "news", the resulting profile name will be * "News Home"./*from w w w .j a v a2s . c om*/ * * @param data * @param profiles * Vector of profiles for all roles user is part of * @return Merged profile * @exception Exception */ private Profile mergeRoleProfiles(RunData data, Vector profiles) throws Exception { Profile result = null; // If merge feature is not turned on, return // profile for the first role (if any) if (!this.useRoleMerge) { if (profiles.size() > 0) { result = (Profile) profiles.get(0); } } // Proceed with merging all profiles else if (profiles.size() > 0) { try { // Create an empty portlet container Portlets portlets = new PsmlPortlets(); Control control = new PsmlControl(); control.setName(this.rolemergeControl); portlets.setControl(control); Controller controller = new PsmlController(); controller.setName(this.rolemergeController); portlets.setController(controller); // Set the skin Skin skin = new PsmlSkin(); skin.setName(PortalToolkit.getSkin((String) null).getName()); portlets.setSkin(skin); String mediaType = null; // Process each role profile int paneCount = 0; for (Iterator it = profiles.iterator(); it.hasNext();) { Profile roleProfile = (Profile) it.next(); mediaType = mediaType == null ? roleProfile.getMediaType() : mediaType; Profile tmpProfile = (Profile) roleProfile.clone(); Portlets tmpPortlets = tmpProfile.getDocument().getPortlets(); // If topmost control is a tab control, then add each tab to the // container Control paneControl = tmpPortlets.getControl(); if (paneControl != null && paneControl.getName().equals(this.rolemergeControl)) { for (int i = 0; i < tmpPortlets.getPortletsCount(); i++) { Portlets pane = tmpPortlets.getPortlets(i); pane.setLayout(null); portlets.addPortlets(pane); paneCount++; } } // Otherwise, add the contents of profile as a pane else { if (tmpPortlets.getTitle() == null) { String title = org.apache.turbine.util.StringUtils .firstLetterCaps(roleProfile.getRoleName()); tmpPortlets.setTitle(title + " Home"); } tmpPortlets.setLayout(null); portlets.addPortlets(tmpPortlets); paneCount++; } if (logger.isDebugEnabled()) { logger.debug("Profiler: Processing profile for role " + roleProfile.getRoleName()); } } // Create a new profile for the user ProfileLocator locator = createLocator(); locator.setUser((JetspeedUser) data.getUser()); locator.setMediaType(mediaType); locator.setName(this.resourceDefault + this.resourceExt); // Regenerate the portlet ids so they are unique org.apache.jetspeed.util.PortletUtils.regenerateIds(portlets); // Save the new profile to permament storage result = this.createProfile(locator, portlets); } catch (Exception e) { logger.error("Exception", e); } } return result; }
From source file:org.energy_home.jemma.ah.internal.zigbee.InstallationStatus.java
private void printTables() { Collection nodes = getNodes(); log.debug("devices (" + nodes.size() + "):"); for (Iterator iterator = nodes.iterator(); iterator.hasNext();) { Vector devices = (Vector) iterator.next(); for (Iterator iterator2 = devices.iterator(); iterator2.hasNext();) { ZigBeeDeviceImpl device = (ZigBeeDeviceImpl) iterator2.next(); if (enableDiscoveryLogs) log.debug("\t" + getIeeeAddressHex(device.getServiceDescriptor().getAddress())); }/*from ww w.j av a2s .c o m*/ } log.debug("inProcessNode (" + inProcessNode.size() + "):"); for (Iterator iterator = inProcessNode.iterator(); iterator.hasNext();) { log.debug("\t" + ((InstallationStatus) iterator.next()).toString()); } log.debug("discoveredNodesQueue(" + discoveredNodesQueue.size() + "):"); for (Iterator iterator = discoveredNodesQueue.iterator(); iterator.hasNext();) { log.debug("\t" + ((InstallationStatus) iterator.next()).toString()); } log.debug("devicesUnderInstallation (" + devicesUnderInstallation.size() + "):"); for (Iterator iterator = devicesUnderInstallation.values().iterator(); iterator.hasNext();) { log.debug("\t" + ((InstallationStatus) iterator.next()).toString()); } log.debug("installedDevices (" + installedDevices.size() + "):"); for (Iterator iterator = installedDevices.values().iterator(); iterator.hasNext();) { log.debug("\t" + ((InstallationStatus) iterator.next()).toString()); } }
From source file:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java
/** * Method for converting {@link WYSIYWYGProperty} to LayoutML XML. * * @param wysiwygProperty/*from www. j a v a2 s. co m*/ * @param blockDeep * @return {@link StringBuffer} with the LayoutML */ private synchronized StringBuffer getLayoutMLCollectableComponentProperty(WYSIYWYGProperty wysiwygProperty, int blockDeep) { LayoutMLBlock block = new LayoutMLBlock(blockDeep); Vector<WYSIYWYGPropertySet> vector = wysiwygProperty.getAllPropertyEntries(); for (Iterator<WYSIYWYGPropertySet> it = vector.iterator(); it.hasNext();) { WYSIYWYGPropertySet propertySet = it.next(); block.append("<" + ELEMENT_PROPERTY); block.append( " " + ATTRIBUTE_NAME + "=\"" + StringUtils.xmlEncode(propertySet.getPropertyName()) + "\""); block.append( " " + ATTRIBUTE_VALUE + "=\"" + StringUtils.xmlEncode(propertySet.getPropertyValue()) + "\""); block.append("/>"); if (it.hasNext()) block.linebreak(); } return block.getStringBuffer(); }