public boolean setWards(Ward... newWards) { boolean wasSet = false; ArrayList<Ward> verifiedWards = new ArrayList<Ward>(); for (Ward aWard : newWards) { if (verifiedWards.contains(aWard)) { continue; } verifiedWards.add(aWard); } if (verifiedWards.size() != newWards.length || verifiedWards.size() < minimumNumberOfWards()) { return wasSet; } ArrayList<Ward> oldWards = new ArrayList<Ward>(wards); wards.clear(); for (Ward aNewWard : verifiedWards) { wards.add(aNewWard); if (oldWards.contains(aNewWard)) { oldWards.remove(aNewWard); } else { aNewWard.addEmployee(this); } } for (Ward anOldWard : oldWards) { anOldWard.removeEmployee(this); } wasSet = true; return wasSet; }
private void computeRemedyDetails(Remedy remedy) { ArrayList<String> updateIds = new ArrayList<String>(); for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) { for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) { if (removedIU.getId().equals(addedIU.getId())) { createModificationRemedyDetail(addedIU, removedIU, remedy); updateIds.add(addedIU.getId()); break; } } if (!updateIds.contains(addedIU.getId())) { createAdditionRemedyDetail(addedIU, remedy); } } for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) { if (!updateIds.contains(removedIU.getId())) { createRemovalRemedyDetail(removedIU, remedy); } } for (IInstallableUnit addedIUinOriginalRequest : originalRequest.getAdditions()) { boolean found = false; for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) { if (addedIU.getId().equals(addedIUinOriginalRequest.getId())) { found = true; break; } } if (!found) { createNotAddedRemedyDetail(addedIUinOriginalRequest, remedy); found = false; } } }
public static boolean anagram(String input) { int numOdd = 0; int count = 0; char[] chars = input.toLowerCase().toCharArray(); ArrayList<Character> letters = new ArrayList<Character>(); for (int i = 0; i < chars.length; i++) { for (int j = 0; j < chars.length; j++) { if (chars[i] == chars[j] && !letters.contains(chars[i])) { count++; } } if (!letters.contains(chars[i])) { letters.add(chars[i]); } if (count % 2 == 1) { numOdd++; } count = 0; } if (input.length() % 2 == 0 && numOdd > 0) { return false; } else if (numOdd > 1) { return false; } else { return true; } }
/** * Method to ignore all incoming messages from a user * * @param i the user to ignore * @param quite if true will not show confirmation * @return true on succes, false on failure */ private boolean ignore(String i, boolean quiet) { if (username.equals(i) || i.equals("server") || admins.contains(i)) { if (!quiet) { error("can't ignore that person"); } return false; } if (!users.contains(i)) { if (!quiet) { error("user does not exists"); } return false; } if (ignores.contains(i)) { if (!quiet) { error("already ignoring user"); } return false; } ignores.add(i); updateList(); if (!quiet) { serverMessage("ignoring " + i); } return true; }
public final boolean addToNetwork(final ABPortal portal, final int index) { final ArrayList<UUID> portals = getNetwork(portal.network, portal.color, portal.owner); if (portals.contains(portal.uid)) return false; portals.add(index, portal.uid); return portals.contains(portal.uid); }
public static boolean isBlockInList(HashMap<Integer, ArrayList<Integer>> map, int id, int meta) { ArrayList<Integer> list = map.get(id); if (list == null) { return false; } return list.contains(meta) || list.contains(-1); }
public ArrayList<String> collectLinks(String p) { ArrayList<String> PageLinks = new ArrayList<String>(); try { URL url = new URL(p); BufferedReader br3 = new BufferedReader(new InputStreamReader(url.openStream())); String str = ""; while (null != (str = br3.readLine())) { Pattern link = Pattern.compile( "<a target=\"_top\" href=\"/m/.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); Matcher match = link.matcher(str); while (match.find()) { String tmp = match.group(); int start = tmp.indexOf('/'); tmp = tmp.substring(start + 1, tmp.indexOf('\"', start + 1)); if (Crawl.contains("http://www.rottentomatoes.com/" + tmp) || ToCrawl.contains("http://www.rottentomatoes.com/" + tmp) || PageLinks.contains("http://www.rottentomatoes.com/" + tmp)) continue; PageLinks.add("http://www.rottentomatoes.com/" + tmp); // bw4.write("http://www.rottentomatoes.com/"+tmp+"\r\n"); } } br3.close(); } catch (Exception ex) { ex.printStackTrace(); } return PageLinks; }
/** * Returns a string of all the instructions used in this run. * * @return */ public String GetInstructionsString() { Object keys[] = _instructions.keySet().toArray(); ArrayList<String> strings = new ArrayList<String>(); String str = ""; for (int i = 0; i < keys.length; i++) { String key = (String) keys[i]; if (_randomGenerators.contains(_generators.get(key))) { strings.add(key); } } if (_randomGenerators.contains(_generators.get("float.erc"))) { strings.add("float.erc"); } if (_randomGenerators.contains(_generators.get("integer.erc"))) { strings.add("integer.erc"); } Collections.sort(strings); for (String s : strings) { str += s + " "; } return str.substring(0, str.length() - 1); }
/** * Simple algorithm to add or remove an edge from the selection Ideas: 1. Use one shape per quad * => easy, but can become very fast too big to fit in memory. => pb: flicker when adding / * removing because the scene is detached 2. Use only one shape, modify geometry TODO: pre-create * an empty shape to avoid initial flicker * * @param on * @param p * @param u * @param v * @param groupIdx2 */ protected void toggleSelectedEdge(boolean on, SelectionEdge se) { if (on) { // add the given edge to the list if (edgeSelection.contains(se)) return; // already in edgeSelection.add(se); } else { // remove the given edge from the list if (!edgeSelection.contains(se)) return; // not present edgeSelection.remove(se); if (edgeSelection.size() == 0) { LineArray la = (LineArray) edgeSelectionShape.getGeometry(); la.setValidVertexCount(0); return; } } // Use in-memory arrays instead of NIO because edgeSelection should not // be too big // => faster LineArray la = new LineArray( edgeSelection.size() * 2, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.BY_REFERENCE); double[] coords = new double[edgeSelection.size() * 2 * 3]; float[] colors = new float[edgeSelection.size() * 2 * 3]; for (int i = 0; i < coords.length; i += 6) { SelectionEdge edge = edgeSelection.get(i / 6); edge.updateCoords(grid, coords, i); edge.updateColors(colors, i); } la.setCoordRefDouble(coords); la.setColorRefFloat(colors); la.setCapability(GeometryArray.ALLOW_COUNT_WRITE); // update edgeSelection Shape with the new edgeSelection list if (edgeSelectionShape == null) { Appearance a = new Appearance(); // PolygonAttributes pa = new // PolygonAttributes(PolygonAttributes.POLYGON_LINE, // PolygonAttributes.CULL_NONE, 0); // pa.setPolygonOffset(1); // above edges // pa.setPolygonOffsetFactor(1); LineAttributes lat = new LineAttributes(); lat.setLineWidth(2.0f); lat.setLineAntialiasingEnable(true); a.setLineAttributes(lat); // a.setPolygonAttributes(pa); edgeSelectionShape = new Shape3D(la, a); edgeSelectionShape.setUserData(this); edgeSelectionShape.setPickable(false); edgeSelectionShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); edgeSelectionShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ); BranchGroup bg = new BranchGroup(); bg.addChild(edgeSelectionShape); addChild(bg); } else edgeSelectionShape.setGeometry(la); }
/** Values.toArray contains all values */ public void testDescendingValuesToArray() { ConcurrentNavigableMap map = dmap5(); Collection v = map.values(); Object[] ar = v.toArray(); ArrayList s = new ArrayList(Arrays.asList(ar)); assertEquals(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); assertTrue(s.contains("D")); assertTrue(s.contains("E")); }
@Test public void shouldGive3PositionsForP15_15() { center = new Position(15, 15); iter = Utility.get8NeighborhoodIterator(center); neighborhood = convertIteration2List(iter); assertTrue("Must contain (14,15)", neighborhood.contains(new Position(14, 15))); assertTrue("Must contain (14,14)", neighborhood.contains(new Position(14, 14))); assertTrue("Must contain (15,14)", neighborhood.contains(new Position(15, 14))); assertEquals("Should be 3 positions in the iterator", 3, neighborhood.size()); }
/** * Simple algorithm to add or remove a quad from the selection Ideas: 1. Use one shape per quad => * easy, but can become very fast too big to fit in memory. => pb: flicker when adding / removing * because the scene is detached 2. Use only one shape, modify geometry TODO: pre-create an empty * shape to avoid initial flicker * * @param on * @param p * @param u * @param v * @param groupIdx2 */ protected void toggleSelectedQuad(boolean on, SelectionQuad sq) { LOGGER.finest("on=" + on + " selectionQuad=" + sq); if (on) { // add the given quad to the list if (selection.contains(sq)) return; // already in selection.add(sq); } else { // remove the given quad from the list if (!selection.contains(sq)) return; // not present selection.remove(sq); if (selection.size() == 0) { QuadArray qa = (QuadArray) selectionShape.getGeometry(); qa.setValidVertexCount(0); return; } } // Use in-memory arrays instead of NIO because selection should not be // too big // => faster QuadArray qa = new QuadArray( selection.size() * 4, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.BY_REFERENCE); float[] coords = new float[selection.size() * 4 * 3]; float[] colors = new float[selection.size() * 4 * 3]; for (int i = 0; i < coords.length; i += 12) { SelectionQuad quad = selection.get(i / 12); quad.updateCoords(grid, coords, i); quad.updateColors(colors, i); } qa.setCoordRefFloat(coords); qa.setColorRefFloat(colors); qa.setCapability(GeometryArray.ALLOW_COUNT_WRITE); // update selection Shape with the new selection list if (selectionShape == null) { Appearance a = new Appearance(); PolygonAttributes pa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0); pa.setPolygonOffset(0.5f); // between faces and edges pa.setPolygonOffsetFactor(0.5f); a.setPolygonAttributes(pa); selectionShape = new Shape3D(qa, a); selectionShape.setUserData(this); selectionShape.setPickable(false); selectionShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); selectionShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ); BranchGroup bg = new BranchGroup(); bg.addChild(selectionShape); addChild(bg); } else selectionShape.setGeometry(qa); }
/** * removes a user from the user list * * @param un the name of the user to be removed */ public void userDel(String un) { users.remove(users.indexOf(un)); if (ignores.contains(un)) { ignores.remove(ignores.indexOf(un)); } if (afks.contains(un)) { afks.remove(afks.indexOf(un)); } if (admins.contains(un)) { admins.remove(admins.indexOf(un)); } updateList(); serverMessage(un + " has left " + server.channel); privates.serverMessage(un, un + " has left"); }
static ArrayList<Integer> panProds() { String[] strAr = genAll(); ArrayList<Integer> list = new ArrayList<Integer>(); for (String i : strAr) { if (Integer.parseInt(i.substring(0, 2)) * Integer.parseInt(i.substring(2, 5)) == Integer.parseInt(i.substring(5)) && !list.contains(Integer.parseInt(i.substring(5)))) list.add(Integer.parseInt(i.substring(5))); if (Integer.parseInt(i.substring(0, 1)) * Integer.parseInt(i.substring(1, 5)) == Integer.parseInt(i.substring(5)) && !list.contains(Integer.parseInt(i.substring(5)))) list.add(Integer.parseInt(i.substring(5))); } return list; }
private void removeProgress(@NotNull InlineProgressIndicator progress) { synchronized (myOriginals) { if (!myInline2Original.containsKey(progress)) return; final boolean last = myOriginals.size() == 1; final boolean beforeLast = myOriginals.size() == 2; myPopup.removeIndicator(progress); final ProgressIndicatorEx original = removeFromMaps(progress); if (myOriginals.contains(original)) return; if (last) { restoreEmptyStatus(); if (myShouldClosePopupAndOnProcessFinish) { hideProcessPopup(); } } else { if (myPopup.isShowing() || myOriginals.size() > 1) { buildInProcessCount(); } else if (beforeLast) { buildInInlineIndicator(createInlineDelegate(myInfos.get(0), myOriginals.get(0), true)); } else { restoreEmptyStatus(); } } runQuery(); } }
private void updateRecord(DataRecord r, ArrayList<String> fieldsInInport) { try { DataRecord rorig = (versionized ? dataAccess.getValidAt(r.getKey(), validAt) : dataAccess.get(r.getKey())); if (rorig == null) { logImportFailed( r, International.getString("Keine gültige Version des Datensatzes gefunden."), null); return; } // has the import record an InvalidFrom field? long invalidFrom = (versionized ? getInvalidFrom(r) : -1); if (invalidFrom <= rorig.getValidFrom()) { invalidFrom = -1; } boolean changed = false; for (int i = 0; i < fields.length; i++) { Object o = r.get(fields[i]); if ((o != null || fieldsInInport.contains(fields[i])) && !r.isKeyField(fields[i]) && !fields[i].equals(DataRecord.LASTMODIFIED) && !fields[i].equals(DataRecord.VALIDFROM) && !fields[i].equals(DataRecord.INVALIDFROM) && !fields[i].equals(DataRecord.INVISIBLE) && !fields[i].equals(DataRecord.DELETED)) { Object obefore = rorig.get(fields[i]); rorig.set(fields[i], o); if ((o != null && !o.equals(obefore)) || (o == null && obefore != null)) { changed = true; } } } if (invalidFrom <= 0) { long myValidAt = getValidFrom(r); if (!versionized || updMode.equals(UPDMODE_UPDATEVALIDVERSION) || rorig.getValidFrom() == myValidAt) { if (changed) { dataAccess.update(rorig); } setCurrentWorkDone(++importCount); } if (versionized && updMode.equals(UPPMODE_CREATENEWVERSION) && rorig.getValidFrom() != myValidAt) { if (changed) { dataAccess.addValidAt(rorig, myValidAt); } setCurrentWorkDone(++importCount); } } else { dataAccess.changeValidity(rorig, rorig.getValidFrom(), invalidFrom); setCurrentWorkDone(++importCount); } } catch (Exception e) { logImportFailed(r, e.toString(), e); } }
// specify input and out keys public void map( LongWritable key, Text value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String line = value.toString(); // define new variable to be string ArrayList<Integer> range = new ArrayList<Integer>(); for (int i = 2000; i <= 2010; i++) { range.add(i); } // String[] inputs = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); String[] inputs = line.split(","); try { int year = Integer.parseInt(inputs[165]); if (range.contains(year)) { String dur = inputs[3]; String artist_name = inputs[2]; String song_title = inputs[1]; String final_input = artist_name + ',' + dur + ',' + song_title; Final_Value.set(final_input); output.collect(Final_Value, dummy); } } catch (NumberFormatException e) { // do nothing } }
/** * Searches for additional phone numbers found in contact information * * @return additional phone numbers found in contact information; */ private List<UIContactDetail> getAdditionalNumbers(boolean onlyMobile) { List<UIContactDetail> telephonyContacts = new ArrayList<UIContactDetail>(); Iterator<Contact> contacts = getMetaContact().getContacts(); while (contacts.hasNext()) { Contact contact = contacts.next(); OperationSetServerStoredContactInfo infoOpSet = contact.getProtocolProvider().getOperationSet(OperationSetServerStoredContactInfo.class); Iterator<GenericDetail> details; ArrayList<String> phones = new ArrayList<String>(); if (infoOpSet != null) { details = infoOpSet.getAllDetailsForContact(contact); while (details.hasNext()) { GenericDetail d = details.next(); boolean process = false; if (onlyMobile) { if (d instanceof MobilePhoneDetail) process = true; } else if (d instanceof PhoneNumberDetail && !(d instanceof PagerDetail) && !(d instanceof FaxDetail)) { process = true; } if (process) { PhoneNumberDetail pnd = (PhoneNumberDetail) d; if (pnd.getNumber() != null && pnd.getNumber().length() > 0) { // skip phones which were already added if (phones.contains(pnd.getNumber())) continue; phones.add(pnd.getNumber()); UIContactDetail cd = new UIContactDetailImpl( pnd.getNumber(), pnd.getNumber() + " (" + getLocalizedPhoneNumber(d) + ")", null, new ArrayList<String>(), GuiActivator.getResources().getImage("service.gui.icons.EXTERNAL_PHONE"), null, null, pnd) { @Override public PresenceStatus getPresenceStatus() { return null; } }; telephonyContacts.add(cd); } } } } } return telephonyContacts; }
public boolean moveValid(Square candidateSquare) { if (piece == 0) { setListForKing(); } if (piece == 1) { setListForQueen(); } if (piece == 2) { moveList.clear(); setListForRook(); } if (piece == 3) { setListForKnight(); } if (piece == 4) { setListForBishop(); } if (piece == 5) { setListForPawn(); } if (moveList.contains(candidateSquare.getPosition())) { return true; } return false; }
// //////////////////////////////////// // DbRefreshListener SUPPORT // // Overridden public void refreshAfterDbUpdate(DbUpdateEvent evt) throws DbException { if (evt.metaField == DbObject.fComponents) { // add, remove, or move to // another parent if (evt.neighbor instanceof DbGraphicalObjectI) // optimization: // discard // immediately the // graphical objects return; if (evt.op == Db.REMOVE_FROM_RELN) { // DbObject removed or with a new parent: remove the node from // its old parent if loaded. DynamicNode node = getDynamicNode(evt.neighbor, Db.OLD_VALUE, false); if (node != null) removeNode(node); } else if (evt.op == Db.ADD_TO_RELN) { // DbObject added or with a new parent: if its new parent has // its chidren loaded, // add a node for the new child. getDynamicNode(evt.neighbor, false); } else { // Db.REINSERT_IN_RELN DynamicNode node = getDynamicNode(evt.neighbor, false); if ((node != null && !childrenAreSorted(evt.dbo)) || (node != null && !node.getGroupParams().sorted)) { DynamicNode parentNode = (DynamicNode) node.getParent(); updateInsertIndexInChildrenOfNode(parentNode); removeNodeFromParent(node); int index = getInsertionIndex(evt.dbo, evt.neighbor, parentNode, node); insertNodeInto(node, parentNode, index); } } } // name refresh else if (evt.metaField == DbSemanticalObject.fName || tooltipsFields.contains(evt.metaField)) { updateNode(evt.dbo); } }
/** * This method creates help entries based on callback from plugins. Current limits are 5 lines of * help text and 200 characters per line of help text. * * @param helpTrigger String trigger for the command. * @param flagRequired The {@link Flag} required to use the command, which will also be required * to view the help entry. * @param helpText String Variable Argument of help texts. */ public void addHelp(String helpTrigger, Flag flagRequired, String... helpText) { int maxHelpTextLength = 200; if (helpText.length > 5) { logger.error( "HelpPlugin does not accept more than 5 lines of text per trigger. '" + helpTrigger + "'"); } else { boolean approved = true; for (String text : helpText) { if (text.length() > maxHelpTextLength) { logger.error( "HelpPlugin does not accept more than " + maxHelpTextLength + " characters per line of help text. '" + helpTrigger + "'"); approved = false; } } if (approved) { HelpItem helpItem = new HelpItem(helpTrigger, flagRequired, helpText); if (helpItems.contains(helpItem)) { logger.error(String.format("Another help trigger already exists for %s", helpTrigger)); } else { helpItems.add(helpItem); } } } }
private void handleSetImportSelection(ArrayList<Object> newSelectionList) { if (newSelectionList.size() == 0) { handleRemoveAll(); pageChanged(); return; } TableItem[] items = fImportListViewer.getTable().getItems(); Object[] oldSelection = new Object[items.length]; for (int i = 0; i < items.length; i++) { oldSelection[i] = items[i].getData(); } // remove items that were in the old selection, but are not in the new one List<Object> itemsToRemove = new ArrayList<>(); for (int i = 0; i < oldSelection.length; i++) { if (newSelectionList.contains(oldSelection[i])) { newSelectionList.remove(oldSelection[i]); } else { itemsToRemove.add(oldSelection[i]); } } doRemove(itemsToRemove); // add items that were not in the old selection and are in the new one doAdd(newSelectionList); pageChanged(); }
private void checkIfSamplesFinished(List<AnalysisItem> resultItemList) { sampleUpdateList = new ArrayList<Sample>(); String currentSampleId = ""; boolean sampleFinished = true; for (AnalysisItem analysisItem : resultItemList) { String analysisSampleId = sampleDAO.getSampleByAccessionNumber(analysisItem.getAccessionNumber()).getId(); if (!analysisSampleId.equals(currentSampleId)) { currentSampleId = analysisSampleId; List<Analysis> analysisList = analysisDAO.getAnalysesBySampleId(currentSampleId); for (Analysis analysis : analysisList) { if (!sampleFinishedStatus.contains(Integer.parseInt(analysis.getStatusId()))) { sampleFinished = false; break; } } if (sampleFinished) { Sample sample = new Sample(); sample.setId(currentSampleId); sampleDAO.getData(sample); sample.setStatusId(StatusService.getInstance().getStatusID(OrderStatus.Finished)); sampleUpdateList.add(sample); } sampleFinished = true; } } }
private boolean processURL(URL url, String baseDir, StatusWindow status) throws IOException { if (processedLinks.contains(url)) { return false; } else { processedLinks.add(url); } URLConnection connection = url.openConnection(); InputStream in = new BufferedInputStream(connection.getInputStream()); ArrayList list = processPage(in, baseDir, url); if ((status != null) && (list.size() > 0)) { status.setMaximum(list.size()); } for (int i = 0; i < list.size(); i++) { if (status != null) { status.setMessage(Utils.trimFileName(list.get(i).toString(), 40), i); } if ((!((String) list.get(i)).startsWith("RUN")) && (!((String) list.get(i)).startsWith("SAVE")) && (!((String) list.get(i)).startsWith("LOAD"))) { processURL( new URL(url.getProtocol(), url.getHost(), url.getPort(), (String) list.get(i)), baseDir, status); } } in.close(); return true; }
public boolean addInput(Operator input) { String inName = input.getAttribute("id"); // get the id of input to add if (inName == null || inName.isEmpty()) { // make sure input has a valid name System.out.println("Input node has no id"); // no valid name, print warning and abort return false; } String inputString = this.getAttribute("input"); // get the input string for this op ArrayList<String> ins; // delcare an array list if (inputString == null || inputString.isEmpty()) { // if the input string is empty ins = new ArrayList<String>(); // make an empty array list } else { // input string is not empty // split input into ArrayList at spaces ins = new ArrayList<String>(Arrays.asList(this.getAttribute("input").split(" "))); } if (ins.contains(inName)) { // check if input is already present return false; // input already present, abort } else { // input is not yet present ins.add(inName); // add input to array list String allIns = ""; // empty string to hold list of inputs for (String s : ins) { // iterate over inputs allIns += s + " "; // append input name to string with space } allIns = allIns.trim(); // remove trailing space this.setAttribute("input", allIns); // set intput attribute to this string of inputs return true; // success! return true } }
public boolean removeInput(Operator input) { String inName = input.getAttribute("id"); // get the name if input to remove from this if (inName == null || inName.isEmpty()) { // no name of input to remove System.out.println("Input node has no id"); // warn return false; // no valid input name to remove, abort } String inputString = this.getAttribute("input"); // get string listing input names for this ArrayList<String> ins; // declare an array list if (inputString == null || inputString.isEmpty()) { // empty list to remove from return false; // nothing to remove, abort } else { // input string is not empty // split input string at spaces and make new array list ins = new ArrayList<String>(Arrays.asList(this.getAttribute("input").split(" "))); } if (!ins.contains(inName)) { // input is not present to be removed return false; // no input to remove, abort } else { // remove the input ins.remove(inName); // remove the desired input. // rebuild input string String allIns = ""; // empty string to hold list of inputs for (String s : ins) { // iterate over inputs allIns += s + " "; // append input name to string with space } allIns = allIns.trim(); // remove trailing space this.setAttribute("input", allIns); // set intput attribute to this string of inputs return true; // success! return true } }
/** * Adds the given <tt>FileTransferListener</tt> that would listen for file transfer requests and * created file transfers. * * @param listener the <tt>FileTransferListener</tt> to add */ public void addFileTransferListener(FileTransferListener listener) { synchronized (fileTransferListeners) { if (!fileTransferListeners.contains(listener)) { this.fileTransferListeners.add(listener); } } }
private void addParticipantToDistributionSet( HashSet<Participant> distributionSet, ArrayList<String> uniqueIDs, Participant p) { if (!uniqueIDs.contains(p.getID())) { uniqueIDs.add(p.getID()); distributionSet.add(p); } }
private void oddPoint(ArrayList<Integer> oddPoints, int from) { if (oddPoints.contains(from)) { oddPoints.remove(new Integer(from)); } else { oddPoints.add(from); } }
/** * Assign a given FloatingIP address to the given {@link Port} It will verify that the given * FloatingIP address is actually exists and it is not allocated to any of the port * * @param port the {@link Port} to which the given FloatingIP address to be assigned * @param ip predefined floating IP address to be assigned * @return assigned {@link FloatingIP} */ private FloatingIP assignPredefinedFloatingIP(Port port, String predefinedFloatingIP) { String invalidIPMsg = String.format("Invalid predefined floating IP %s", predefinedFloatingIP); assertValidIP(predefinedFloatingIP, invalidIPMsg); assertNotNull(port, "Invalid port. Port cannot be null"); FloatingIP floatingIP = getFloatingIPByIPAddress(predefinedFloatingIP); String floatingIPNullMsg = String.format("No such available floating IP %s found", predefinedFloatingIP); assertNotNull(floatingIP, floatingIPNullMsg); ArrayList<FloatingIP> availableFloatingIPs = getUnassignedFloatingIPs(); FloatingIP updatedFloatingIP = null; if (availableFloatingIPs.contains(floatingIP)) { updatedFloatingIP = updateFloatingIP(floatingIP, port); } else { String msg = String.format( "Predefined floating IP %s is either already allocated to another port %s or unavilable", predefinedFloatingIP, floatingIP.getPortId()); log.error(msg); throw new CloudControllerException(msg); } return updatedFloatingIP; }