List of usage examples for java.util List remove
E remove(int index);
From source file:net.sourceforge.fenixedu.dataTransferObject.InfoExecutionDegree.java
public static List buildLabelValueBeansForList(List executionDegrees, MessageResources messageResources) { List copyExecutionDegrees = new ArrayList(); copyExecutionDegrees.addAll(executionDegrees); List result = new ArrayList(); Iterator iter = executionDegrees.iterator(); while (iter.hasNext()) { final InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) iter.next(); List equalDegrees = (List) CollectionUtils.select(copyExecutionDegrees, new Predicate() { @Override/*from ww w .j a va2 s . c o m*/ public boolean evaluate(Object arg0) { InfoExecutionDegree infoExecutionDegreeElem = (InfoExecutionDegree) arg0; if (infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getSigla().equals( infoExecutionDegreeElem.getInfoDegreeCurricularPlan().getInfoDegree().getSigla())) { return true; } return false; } }); if (equalDegrees.size() == 1) { copyExecutionDegrees.remove(infoExecutionDegree); String degreeType = null; if (messageResources != null) { degreeType = messageResources.getMessage(infoExecutionDegree.getInfoDegreeCurricularPlan() .getInfoDegree().getDegreeType().toString()); } if (degreeType == null) { degreeType = infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getDegreeType() .toString(); } result.add(new LabelValueBean( degreeType + " " + infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getNome(), infoExecutionDegree.getExternalId().toString())); } else { String degreeType = null; if (messageResources != null) { degreeType = messageResources.getMessage(infoExecutionDegree.getInfoDegreeCurricularPlan() .getInfoDegree().getDegreeType().toString()); } if (degreeType == null) { degreeType = infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getDegreeType() .toString(); } result.add( new LabelValueBean( degreeType + " " + infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree() .getNome() + " - " + infoExecutionDegree.getInfoDegreeCurricularPlan().getName(), infoExecutionDegree.getExternalId().toString())); } } return result; }
From source file:com.github.fge.jsonschema.main.cli.Main.java
private RetCode doValidation(final Reporter reporter, final List<File> files) throws IOException, ProcessingException { final File schemaFile = files.remove(0); final String uri = schemaFile.toURI().normalize().toString(); JsonNode node;//from w ww. j a va 2 s . c o m node = MAPPER.readTree(schemaFile); if (!syntaxValidator.schemaIsValid(node)) { System.err.println("Schema is invalid! Aborting..."); return SCHEMA_SYNTAX_ERROR; } final JsonSchema schema = factory.getJsonSchema(uri); RetCode ret = ALL_OK, retcode; for (final File file : files) { node = MAPPER.readTree(file); retcode = reporter.validateInstance(schema, file.toString(), node); if (retcode != ALL_OK) ret = retcode; } return ret; }
From source file:net.hydromatic.optiq.model.ModelHandler.java
private <T> void pop(List<T> stack, T element) { assert stack.get(stack.size() - 1) == element; stack.remove(stack.size() - 1); }
From source file:cpcc.vvrte.services.task.AcoTspSimpleTest.java
@Test(dataProvider = "pathDataProvider") public void shouldCalculateTspPath(List<CartesianCoordinate> path, List<Integer> expected) { int n = path.size(); double[][] costMatrix = new double[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { costMatrix[i][j] = path.get(j).subtract(path.get(i)).norm(); }//from www . j a v a 2s. c o m } List<Integer> bestPath = AcoTspSimple.calculateBestPath(costMatrix, 1000, 3); AcoTspSimple.fixPath(0, bestPath); bestPath.remove(0); assertThat(bestPath).has(new TspListCondition<Integer>(expected)); }
From source file:com.sworddance.util.UriFactoryImpl.java
/** * manually handle '..' path elements to ensure that the path cannot be used to access * a directory above its root./*from w w w .j a va 2s . c o m*/ * '.' and blank elements are removed. * * '../foo/./index.html' becomes '/foo/index.html' * '/foo/../../index.html' becomes '/index.html' * 'foo////bar.html' becomes 'foo/bar.html' * * @param filePath * @return the sanitized path with no blank, '..' or '.' components. */ public static String sanitizePath(Object filePath) { if (filePath != null) { //Let's make sure that filePath is really just path and nothing more. // TO_KOSTYA PATM 19 July 2011 -- // Please create comment as to why this necessary ( showing input ) //This was to prevent generation of links like following: //http://amplafi.net/http:/amplafi.net/rss/ampbp_2/ampmep_6.xml //Input.. I guess: http://amplafi.net/rss/ampbp_2/ampmep_6.xml // HACK we can't do this - because if we have any problems with uri path then we get an exception. // and then look at UriParser. // It looks like we should hook up UriParser soon rather than later. // Also Google guava has some uri validation code as well. // URI create = URI.create(filePath.toString()); String path = filePath.toString();//create.getRawPath(); // chop up path based on \ or / characters. String[] pathParts = path.split("[/\\\\]"); // and look for '..' and '.' and resolve the final path, // looking for attempts to navigate to the root directory of 'filePath' List<String> pathArr = new ArrayList<String>(); int index = -1; for (String pathPart : pathParts) { pathPart = pathPart.trim(); if (pathPart.isEmpty() || ".".equals(pathPart)) { // a '//' in the path or '/./' continue; } else if ("..".equals(pathPart)) { if (index >= 0) { pathArr.remove(index--); } else { // TODO: possible security violation } } else { // TODO: look for forbidden elements : "etc" "passwd" "shadow" a file name that starts with a "." like ".htaccess" pathArr.add(pathPart); index++; } } return join(pathArr, PATH_SEPARATOR); } else { return ""; } }
From source file:de.static_interface.sinkirc.IrcListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onIrcPrivateMessage(IrcPrivateMessageEvent event) { String[] args = event.getMessage().split(" "); String cmd = args[0];//from w w w .ja va 2 s . c o m List<String> tmp = new ArrayList<>(Arrays.asList(args)); tmp.remove(cmd); args = tmp.toArray(new String[tmp.size()]); if (event.getMessage().trim().equals(IrcUtil.getCommandPrefix())) { return; // no command } IrcUtil.handleCommand(cmd, args, event.getUser().getNick(), event.getUser(), event.getMessage()); }
From source file:com.baasbox.service.user.UserService.java
public static void registerDevice(HashMap<String, Object> data) throws SqlInjectionException { String username = DbHelper.getCurrentUserNameFromConnection(); String pushToken = (String) data.get(UserDao.USER_PUSH_TOKEN); String os = (String) data.get(UserDao.USER_DEVICE_OS); boolean found = false; com.baasbox.db.DbHelper.reconnectAsAdmin(); List<ODocument> sqlresult = (List<ODocument>) com.baasbox.db.DbHelper.genericSQLStatementExecute( "select from _BB_UserAttributes where login_info contains (pushToken = '" + pushToken + "') AND login_info contains (os = '" + os + "')", null);//from w w w . ja va 2 s .c om //prevents more users use the same os/token pair and duplications of os/token pairs for (ODocument record : sqlresult) { List<ODocument> login_Infos = record.field(UserDao.USER_LOGIN_INFO); for (ODocument login_Info : login_Infos) { if (login_Info.field(UserDao.USER_PUSH_TOKEN).equals(pushToken) && (login_Info.field(UserDao.USER_DEVICE_OS).equals(os))) { login_Infos.remove(login_Info); break; } } record.save(); } ODocument user = getUserProfilebyUsername(username); ODocument systemProps = user.field(UserDao.ATTRIBUTES_SYSTEM); ArrayList<ODocument> loginInfos = systemProps.field(UserDao.USER_LOGIN_INFO); for (ODocument loginInfo : loginInfos) { if (loginInfo.field(UserDao.USER_PUSH_TOKEN) != null && loginInfo.field(UserDao.USER_PUSH_TOKEN).equals(pushToken) && loginInfo.field(UserDao.USER_DEVICE_OS).equals(os)) { found = true; break; } } if (!found) { loginInfos.add(new ODocument(data)); systemProps.save(); } com.baasbox.db.DbHelper.reconnectAsAuthenticatedUser(); }
From source file:com.fizzed.stork.util.CopyFile.java
public String popNextArg(String argSwitch, List<String> argList) { if (argList.isEmpty()) { logger.error("argument switch [" + argSwitch + "] is missing value as next argument"); System.exit(1);/*from w ww. j a va 2s. co m*/ } return argList.remove(0); }
From source file:net.sourceforge.atunes.kernel.actions.AddToPlayListRemoteAction.java
/** * @return/*from w ww.j ava 2s . c o m*/ */ private boolean getPlayNow(final List<String> parameters) { boolean playNow = false; if (parameters.contains(NOW)) { playNow = true; parameters.remove(NOW); } return playNow; }
From source file:net.sourceforge.eclipsetrader.ats.core.internal.DailyMarketManager.java
public void removeBarListener(Security security, IBarListener l) { List list = (List) securityBarListeners.get(security); if (list != null) list.remove(l); }