List of usage examples for java.util HashSet iterator
public Iterator<E> iterator()
From source file:org.skb.util.cli.CliApache.java
public void setPropOptions(TSPropertyMap prop) { String optType;//w w w .j a v a 2 s .com String optShort; String optLong; String optDescr; String optArgName; HashSet<String> ts = new HashSet<String>(prop.getRows()); for (Iterator<String> i = ts.iterator(); i.hasNext(); i.hasNext()) { String current = i.next(); if (prop.get(current, TSPropertyMap.pmValCliOptionType) != null) { optType = prop.get(current, TSPropertyMap.pmValCliOptionType).toString(); if (!(prop.get(current, TSPropertyMap.pmValCliOptionShort)).tsIsType(TEnum.TS_NULL)) optShort = prop.get(current, TSPropertyMap.pmValCliOptionShort).toString(); else optShort = null; if (!(prop.get(current, TSPropertyMap.pmValCliOptionLong)).tsIsType(TEnum.TS_NULL)) optLong = prop.get(current, TSPropertyMap.pmValCliOptionLong).toString(); else optLong = null; optDescr = prop.get(current, TSPropertyMap.pmValCliUsageDescr).toString(); optArgName = prop.get(current, TSPropertyMap.pmValCliUsageDescrAdd).toString(); if (optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_STRING) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_INTEGER) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_DOUBLE) || optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_LONG)) { if (optShort != null && optLong != null) { OptionBuilder.hasArg(); OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); OptionBuilder.withArgName(optArgName); this.options.addOption(OptionBuilder.create(optShort.charAt(0))); this.optionList.put(current, optLong); } else if (optLong != null) { OptionBuilder.hasArg(); OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); OptionBuilder.withArgName(optArgName); this.options.addOption(OptionBuilder.create()); this.optionList.put(current, optLong); } } else if (optType.equals(TSRepository.TString.TS_ATOMIC_JAVA_BOOLEAN)) { if (optShort != null && optLong != null) { OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); this.options.addOption(OptionBuilder.create(optShort.charAt(0))); this.optionList.put(current, optLong); } else if (optLong != null) { OptionBuilder.withDescription(optDescr); OptionBuilder.withLongOpt(optLong); this.options.addOption(OptionBuilder.create()); this.optionList.put(current, optLong); } } } } }
From source file:org.hyperic.hq.ui.action.resource.common.monitor.alerts.config.RemoveUsersAction.java
/** * Handles the actual work of removing users from the action. *//*from ww w . j a v a 2 s.c o m*/ protected ActionForward handleRemove(ActionMapping mapping, HttpServletRequest request, Map<String, Object> params, Integer sessionID, ActionValue action, EmailActionConfig ea, EventsBoss eb, RemoveNotificationsForm rnForm) throws Exception { Integer[] users = rnForm.getUsers(); if (null != users) { log.debug("users.length=" + users.length); HashSet<Object> storedUsers = new HashSet<Object>(); storedUsers.addAll(ea.getUsers()); for (int x = 0; x < users.length; ++x) { storedUsers.remove(users[x]); } ea.setNames(StringUtil.iteratorToString(storedUsers.iterator(), ",")); action.setConfig(ea.getConfigResponse().encode()); eb.updateAction(sessionID.intValue(), action); } return returnSuccess(request, mapping, params); }
From source file:phonegraph.PhoneGraph.java
public void PrintResults(String ID) { FileWriter fstream1 = null;// w w w. j av a2 s . c om try { fstream1 = new FileWriter("phone_map" + ID + ".txt", false); BufferedWriter out = new BufferedWriter(fstream1); Iterator it = phonemaps.entrySet().iterator(); out.write("PhoneID\tPhone\n"); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); out.write(pairs.getValue() + "\t" + pairs.getKey() + "\n"); } out.close(); fstream1 = new FileWriter("phone2url" + ID + ".txt", false); out = new BufferedWriter(fstream1); it = phone2urls.entrySet().iterator(); out.write("PhoneID\turi_lists\n"); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); out.write(pairs.getKey().toString()); HashSet<String> newset = (HashSet<String>) pairs.getValue(); Iterator iterator = newset.iterator(); while (iterator.hasNext()) { out.write("\t" + iterator.next()); } out.write("\n"); //phone2urls.remove((Integer)pairs.getKey()); } out.close(); fstream1.close(); phone2urls.clear(); } catch (IOException ex) { Logger.getLogger(PhoneGraph.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.pentaho.reporting.libraries.css.resolver.values.ResolverFactory.java
public void registerDefaults() { final ArrayList handlerList = new ArrayList(); final HashMap autoHandlers = loadModules(AUTO_PREFIX); final HashMap compHandlers = loadModules(COMPUTED_PREFIX); final HashMap percHandlers = loadModules(PERCENTAGE_PREFIX); final HashSet keys = new HashSet(); keys.addAll(autoHandlers.keySet());/*from w w w.j a va 2 s . c o m*/ keys.addAll(compHandlers.keySet()); keys.addAll(percHandlers.keySet()); for (Iterator iterator = keys.iterator(); iterator.hasNext();) { final StyleKey key = (StyleKey) iterator.next(); final ResolveHandler autoHandler = (ResolveHandler) autoHandlers.get(key); final ResolveHandler compHandler = (ResolveHandler) compHandlers.get(key); final ResolveHandler percHandler = (ResolveHandler) percHandlers.get(key); handlerList.add(new ResolveHandlerModule(key, autoHandler, compHandler, percHandler)); } handlers = (ResolveHandlerModule[]) handlerList.toArray(new ResolveHandlerModule[handlerList.size()]); handlers = ResolveHandlerSorter.sort(handlers); // for (int i = 0; i < handlers.length; i++) // { // ResolveHandlerModule handler = handlers[i]; // Log.debug("Registered sorted handler (" + handler.getWeight() + ") " + handler.getKey()); // // } // Log.debug("Registered " + handlers.length + " modules."); }
From source file:org.gcaldaemon.gui.config.MainConfig.java
private static final boolean containsURL(HashSet set, String url) { int i = url.indexOf("/private"); if (i != -1) { url = url.substring(0, i);/* ww w. jav a 2 s .c om*/ Iterator urls = set.iterator(); String test; while (urls.hasNext()) { test = (String) urls.next(); if (test.startsWith(url)) { return true; } } } return false; }
From source file:org.gcaldaemon.gui.config.MainConfig.java
private static final boolean containsPath(HashSet set, String path) { int i = path.indexOf(':'); if (i != -1) { path = path.substring(i + 1);//from w ww . jav a2 s. c om } Iterator urls = set.iterator(); String test; while (urls.hasNext()) { test = (String) urls.next(); if (test.indexOf(path) != -1) { return true; } } return false; }
From source file:TreePrinter.java
public void print(PrintStream s, SceneGraphObject sgo) { printStream = s;/*from www . ja va 2s . co m*/ HashSet sharedGroups = new HashSet(); if (sgo == null) { printStream.println("null"); } else { printTree(sgo, 0, sharedGroups); Iterator iterator = sharedGroups.iterator(); while (iterator.hasNext()) { SharedGroup sg = (SharedGroup) iterator.next(); print(s, sg); } } }
From source file:cc.kave.commons.model.groum.SubGroum.java
private Node findRoot() { HashSet<Node> candidates = new HashSet<>(nodes); for (Node node : nodes) { Set<Node> successors = getSuccessors(node); candidates.removeAll(successors); }/*from w w w . j a va2s . co m*/ if (candidates.size() == 1) { return candidates.iterator().next(); } else { throw new IllegalStateException( "Groum has no uniquly identifiable root (candidates: " + candidates + ")"); } }
From source file:org.squale.squalix.tools.mccabe.McCabePCFFile.java
/** * Cre la liste des fichiers intgrer l'analyse. * /*from w w w . ja v a 2s .c o m*/ * @param pDirectory rpertoire */ private void setFilesList(File pDirectory) { LOGGER.debug(McCabeMessages.getString("logs.debug.listing_files") + mRoot.getAbsolutePath()); // Dtermine la liste des fichiers analyser McCabeFileFilter filter = new McCabeFileFilter(mRoot.getAbsolutePath(), mConfig.getExtensions()); HashSet fileList = new HashSet(); FileUtility.createRecursiveListOfFiles(pDirectory, filter, fileList); Iterator it = fileList.iterator(); String filename = null; int rootLength = mRoot.getAbsolutePath().length() + File.separator.length(); while (it.hasNext()) { filename = (String) it.next(); mFilesList.add(filename.substring(rootLength)); } }
From source file:org.cloudgraph.hbase.mutation.Update.java
@Override public void collect(DataGraph dataGraph, PlasmaDataObject dataObject, DistributedWriter graphWriter, TableWriter tableWriter, RowWriter rowWriter) throws IllegalAccessException, IOException { PlasmaType type = (PlasmaType) dataObject.getType(); CoreNode dataNode = (CoreNode) dataObject; // FIXME: get rid of cast - define instance properties in 'base type' Timestamp snapshotDate = (Timestamp) dataNode.getValue(CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP); if (snapshotDate == null) throw new RequiredPropertyException( "instance property '" + CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP + "' is required to update data object, " + dataObject); if (log.isDebugEnabled()) log.debug(dataObject + " timestamp: " + String.valueOf(snapshotDate)); Long sequence = (Long) dataNode.getValue(CloudGraphConstants.SEQUENCE); if (sequence == null) throw new RequiredPropertyException("instance property '" + CloudGraphConstants.SEQUENCE + "' is required to update data object, " + dataObject); if (log.isDebugEnabled()) log.debug(dataObject + " (seq: " + sequence + ")"); List<Setting> settingList = dataGraph.getChangeSummary().getOldValues(dataObject); HashSet<PlasmaProperty> properties = this.collectProperties(settingList); Iterator<PlasmaProperty> iter = properties.iterator(); while (iter.hasNext()) { PlasmaProperty property = iter.next(); if (property.getConcurrent() != null) return; // processed above if (property.isReadOnly()) throw new IllegalAccessException("attempt to modify read-only property, " + property); Object dataValue = dataObject.get(property); if (dataValue != null) if (log.isDebugEnabled()) log.debug("updating " + property.toString()); else if (log.isDebugEnabled()) log.debug("removing " + property.toString()); if (!property.getType().isDataType()) { SettingCollector<PlasmaDataObject> settingCollector = new SettingCollector<>(); HashSet<PlasmaDataObject> oldSettings = settingCollector.collect(property, settingList); HashSet<PlasmaDataObject> oldValues = new HashSet<>(oldSettings.size()); for (PlasmaDataObject oldSettingObject : oldSettings) { if (!oldSettingObject.getDataGraph().getChangeSummary().isCreated(oldSettingObject)) oldValues.add(oldSettingObject); }//from w w w. j av a 2 s. c o m EdgeWriter edgeWriter = rowWriter.getEdgeWriter(dataObject, property, sequence); if (!property.isMany()) { this.collectSingular(edgeWriter, dataObject, oldValues, property, dataValue); } else { this.collectMulti(edgeWriter, dataObject, oldValues, property, dataValue); } edgeWriter.write(); } else { Increment increment = property.getIncrement(); if (dataValue != null) { if (increment == null) { byte[] valueBytes = HBaseDataConverter.INSTANCE.toBytes(property, dataValue); rowWriter.writeRowData(dataObject, sequence, property, valueBytes); } else { // increment if (type.isConcurrent()) throw new GraphServiceException( "increment property, " + property + ", found on concurrent type, " + type + " - increment properties cannot coexist within a concurrent type"); DataType dataType = DataType.valueOf(property.getType().getName()); if (increment != null) { // user can increment/decrement by whatever // value if (dataType.ordinal() != DataType.Long.ordinal()) throw new GraphServiceException("property, " + property + ", must be datatype " + DataType.Long + " to support increment operations"); long longDataValue = DataConverter.INSTANCE.toLong(property.getType(), dataValue); rowWriter.incrementRowData(dataObject, sequence, property, longDataValue); } } } else { rowWriter.deleteRowData(dataObject, sequence, property); } } } }