List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:ClassPath.java
/** * Checks for class path components in the following properties: * "java.class.path", "sun.boot.class.path", "java.ext.dirs" * /*from w w w. java 2 s. c om*/ * @return class path as used by default by BCEL */ public static final String getClassPath() { String class_path = System.getProperty("java.class.path"); String boot_path = System.getProperty("sun.boot.class.path"); String ext_path = System.getProperty("java.ext.dirs"); List list = new ArrayList(); getPathComponents(class_path, list); getPathComponents(boot_path, list); List dirs = new ArrayList(); getPathComponents(ext_path, dirs); for (Iterator e = dirs.iterator(); e.hasNext();) { File ext_dir = new File((String) e.next()); String[] extensions = ext_dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { name = name.toLowerCase(Locale.ENGLISH); return name.endsWith(".zip") || name.endsWith(".jar"); } }); if (extensions != null) { for (int i = 0; i < extensions.length; i++) { list.add(ext_dir.getPath() + File.separatorChar + extensions[i]); } } } StringBuffer buf = new StringBuffer(); for (Iterator e = list.iterator(); e.hasNext();) { buf.append((String) e.next()); if (e.hasNext()) { buf.append(File.pathSeparatorChar); } } return buf.toString().intern(); }
From source file:com.zenoss.jmx.ValueExtractor.java
/** * Traverses a TabularData or CompositeData structure to return nested data * //from w w w . jav a 2 s .co m * e.g. To get the the used perm gen memory before last garbage collection * value from the result of the lastGcInfo attribute of the * java.lang:type=GarbageCollector,name=Copy mbean the path used would be * * memoryUsageBeforeGc.[Perm Gen].used * * In general the non bracketed values are keys into CompositeData and the * bracketed values are indexes into TabularData. For TabularData indexes * with more than one value a comma separated list without spaces should be * used, spaces are treated as part of the values in the index array. * * e.g. [key1,key2] * * The brackets aren't mandatory for indexes but are included for clarity. * * Curly brackets can be used after a table index to specify a column name. * * e.g memoryUsageBeforeGc.[Perm Gen].{value}.used * * The column name is only necessary when the table has more than two * columns. If the table has two columns then the value is read from the * column not used for the index. * * @param obj * TabularData, CompositeData, or Map * @param path * dot separated string that represents a path through the object * @return Object the value at the end of the path * @throws JmxException * if a path element doesn't exist */ public static Object getDataValue(final Object obj, String path) throws JmxException { if (!(obj instanceof TabularData) && !(obj instanceof CompositeData) && !(obj instanceof Map)) { throw new IllegalArgumentException("Cannot process object of type " + obj.getClass().getName()); } _logger.debug("getDataValue: path is " + path); List<String> pathList = split(path); _logger.debug("getDataValue: pathList " + pathList); Object currentObj = obj; Iterator<String> pathElements = pathList.iterator(); try { while (pathElements.hasNext()) { _logger.debug("getDataValue: current object is " + obj); String currentKey = pathElements.next(); pathElements.remove(); _logger.debug("getDataValue: currentKey: " + currentKey); if (currentObj instanceof TabularData) { _logger.debug("getDataValue: dealing with tabularData"); TabularData tData = (TabularData) currentObj; String[] index = createTableIndex(currentKey); currentObj = getDataByTableIndex(tData, index); CompositeData cData = (CompositeData) currentObj; int columnCount = cData.values().size(); String nextKey = null; // look ahead and look for explicit column if (!pathList.isEmpty()) { nextKey = pathList.get(0); } if (nextKey != null && (isColumn(nextKey) || columnCount > 2)) { String columnKey = pathElements.next(); pathElements.remove(); if (isColumn(columnKey)) { _logger.debug("using explicit column key " + columnKey + " for tabular data"); // remove first and last char - should be curly // brackets columnKey = columnKey.substring(1, columnKey.length() - 1); } else { _logger.debug( "using column key " + columnKey + " for tabular data. No curly brackets found"); } currentObj = getData(cData, columnKey); } else if (cData.values().size() == 2) { currentObj = getTableRowData(cData, index); } } else if (currentObj instanceof CompositeData) { _logger.debug("getDataValue: dealing with CompositeData"); CompositeData cData = (CompositeData) currentObj; currentObj = getData(cData, currentKey); } else if (currentObj instanceof Map) { _logger.debug("getDataValue: dealing with Map"); Map mData = (Map) currentObj; currentObj = getData(mData, currentKey); } else { // we still have a path but the object isn't composite or // tabluar String remainingPath = currentKey; for (String val : pathList) { remainingPath += "."; remainingPath += val; } _logger.warn( "getDataValue: we still have a path but the " + "object isn't composite or tabluar"); _logger.warn("getDataValue: remaining path is " + remainingPath); throw new JmxException("we still have a path but the " + "object isn't composite or tabluar, remaining " + "" + "path is " + remainingPath); } } } catch (Exception e) { _logger.warn("could not get object for path " + path, e); throw new JmxException("could not get object for path " + path + "; " + e.getMessage(), e); } return currentObj; }
From source file:com.panet.imeta.core.fileinput.FileInputList.java
public static String getRequiredFilesDescription(List<FileObject> nonExistantFiles) { StringBuffer buffer = new StringBuffer(); for (Iterator<FileObject> iter = nonExistantFiles.iterator(); iter.hasNext();) { FileObject file = iter.next(); buffer.append(file.getName().getURI()); buffer.append(Const.CR);/* w w w . j a v a 2 s . co m*/ } return buffer.toString(); }
From source file:com.krawler.spring.authHandler.authHandler.java
public static JSONObject getVerifyLoginJson(List ll, HttpServletRequest request) { JSONObject jobj = new JSONObject(); try {/*from ww w. j a va 2 s . co m*/ Iterator ite = ll.iterator(); if (ite.hasNext()) { Object[] row = (Object[]) ite.next(); User user = (User) row[0]; UserLogin userLogin = (UserLogin) row[1]; Company company = (Company) row[2]; jobj.put("success", true); jobj.put("lid", userLogin.getUserID()); jobj.put("username", userLogin.getUserName()); jobj.put("companyid", company.getCompanyID()); jobj.put("company", company.getCompanyName()); Language lang = company.getLanguage(); if (lang != null) jobj.put("language", lang.getLanguageCode() + (lang.getCountryCode() != null ? "_" + lang.getCountryCode() : "")); jobj.put("roleid", user.getRoleID()); jobj.put("callwith", user.getCallwith()); jobj.put("timeformat", user.getTimeformat()); // KWLTimeZone timeZone = user.getTimeZone(); // if (timeZone == null) { // timeZone = company.getTimeZone(); // } // if (timeZone == null) { // timeZone = (KWLTimeZone) ll.get(1); // } KWLTimeZone timeZone = getTZforUser(user, company, (KWLTimeZone) ll.get(1)); jobj.put("timezoneid", timeZone.getTimeZoneID()); jobj.put("tzdiff", timeZone.getDifference()); jobj.put(Constants.SESSION_TZ_ID, timeZone.getTzID()); KWLDateFormat dateFormat = user.getDateFormat(); if (dateFormat == null) { dateFormat = (KWLDateFormat) ll.get(2); } jobj.put("dateformatid", dateFormat.getFormatID()); KWLCurrency currency = company.getCurrency(); if (currency == null) { currency = (KWLCurrency) ll.get(3); } jobj.put("currencyid", currency.getCurrencyID()); jobj.put("success", true); } else { jobj.put("failure", true); jobj.put("success", false); } } catch (Exception e) { System.out.println(e.getMessage()); } return jobj; }
From source file:eu.planets_project.tb.gui.backing.admin.wsclient.util.WSClient.java
/** * Test!!//w ww .j a v a2 s. c o m * * @param wsdl The WSDL to load and run! */ public static void test(String wsdl) { try { ComponentBuilder builder = new ComponentBuilder(); List components = builder.buildComponents(wsdl); Iterator iter = components.iterator(); while (iter.hasNext()) { ServiceInfo info = (ServiceInfo) iter.next(); Iterator iter2 = info.getOperations(); while (iter2.hasNext()) { OperationInfo oper = (OperationInfo) iter2.next(); invokeOperation(oper); } } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:net.sf.jasperreports.engine.util.JRFontUtil.java
/** * Returns font information containing the font family, font face and font style. * //from w ww .j ava 2 s. c o m * @param name the font family or font face name * @param locale the locale * @return a font info object */ public static FontInfo getFontInfo(String name, Locale locale) { //FIXMEFONT do some cache List<FontFamily> families = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(FontFamily.class); for (Iterator<FontFamily> itf = families.iterator(); itf.hasNext();) { FontFamily family = itf.next(); if (locale == null || family.supportsLocale(locale)) { if (name.equals(family.getName())) { return new FontInfo(family, null, Font.PLAIN); } FontFace face = family.getNormalFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.PLAIN); } face = family.getBoldFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.BOLD); } face = family.getItalicFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.ITALIC); } face = family.getBoldItalicFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.BOLD | Font.ITALIC); } } } //throw new JRRuntimeException("Font family/face named '" + name + "' not found."); return null; }
From source file:com.aurel.track.persist.TScreenPeer.java
public static List<ITab> loadFullChildren(Integer objectID, Connection con) throws TorqueException { LOGGER.debug("Getting children for screen:" + objectID + "..."); List<ITab> reasult = new ArrayList<ITab>(); Criteria critTabs = new Criteria(); critTabs.add(BaseTScreenTabPeer.PARENT, objectID); List tabs = BaseTScreenTabPeer.doSelect(critTabs, con); for (Iterator iterTabs = tabs.iterator(); iterTabs.hasNext();) { TScreenTab tab = (TScreenTab) iterTabs.next(); TScreenTabBean tabBean = tab.getBean(); List<IPanel> panels = TScreenTabPeer.loadFullChildren(tab.getObjectID(), con); tabBean.setPanels(panels);// w ww . java 2 s . c om reasult.add(tabBean); } return reasult; }
From source file:com.aurel.track.persist.TScreenPeer.java
/** * delete all children and then delete the object * @param objectID// ww w.ja v a 2s.c om * @param con * @throws TorqueException */ private static void deleteChildren(Integer objectID, Connection con) throws TorqueException { //delete also all children LOGGER.debug("Deleting children for screen:" + objectID + "..."); Criteria critTabs = new Criteria(); critTabs.add(BaseTScreenTabPeer.PARENT, objectID); List tabs = BaseTScreenTabPeer.doSelect(critTabs, con); for (Iterator iterTabs = tabs.iterator(); iterTabs.hasNext();) { TScreenTab tab = (TScreenTab) iterTabs.next(); //delete the children for the tab TScreenTabPeer.deleteChildren(tab.getObjectID(), con); //delete the tab BaseTScreenTabPeer.doDelete(SimpleKey.keyFor(tab.getObjectID()), con); } }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.Activator.java
/** * Return array of entry sub-paths in given path. */// w w w . j a va 2 s . c om public static String[] getEntriesPaths(String path) { List<String> entryPaths; { Enumeration<?> entryPathsEnumeration = m_plugin.getBundle().getEntryPaths(path); entryPaths = new ArrayList<String>(); CollectionUtils.addAll(entryPaths, entryPathsEnumeration); } // remove "CVS" files (far case when we use runtime workbench) for (Iterator<String> I = entryPaths.iterator(); I.hasNext();) { String entryPath = I.next(); if (entryPath.indexOf("CVS") != -1) { I.remove(); } } // convert to array return entryPaths.toArray(new String[entryPaths.size()]); }
From source file:com.app.util.SearchResultUtil.java
private static void _removePreviouslyNotifiedResults(int searchQueryId, List<SearchResult> newSearchResults) throws DatabaseConnectionException, SQLException { List<String> searchQueryPreviousResults = SearchQueryPreviousResultUtil .getSearchQueryPreviousResults(searchQueryId); if (!searchQueryPreviousResults.isEmpty()) { Iterator iterator = newSearchResults.iterator(); while (iterator.hasNext()) { SearchResult searchResult = (SearchResult) iterator.next(); if (searchQueryPreviousResults.contains(searchResult.getItemId())) { iterator.remove();/*from w w w.j av a 2 s . c o m*/ } } } }