List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java
private static List<String> horizonRequirementFields() { LinkedList<String> fields = new LinkedList<String>(); fields.add("id"); fields.add("name"); fields.add("release-backlog-item.release-id"); fields.add("release-backlog-item.team-id"); fields.add("release-backlog-item.sprint-id"); fields.add("release-backlog-item.owner"); fields.add("req-priority"); fields.add("description"); fields.add("comments"); return fields; }
From source file:com.zenoss.jmx.ValueExtractor.java
/** * split a string on dots but leave values within brackets ([,}) that have dots intact * for example the string "test.{bracket.stuff}" should be split to an array * [test, {bracket.stuff}]//from w w w . java 2 s . co m * * @param path * @return */ public static LinkedList<String> split(String path) { String[] splitPath = dotPattern.split(path); Iterator<String> pathElements = Arrays.asList(splitPath).iterator(); LinkedList<String> resultPath = new LinkedList<String>(); while (pathElements.hasNext()) { String pathElement = pathElements.next(); while (bracketStart.matcher(pathElement).matches() && notBracketEnd.matcher(pathElement).matches() && pathElements.hasNext()) { pathElement = pathElement + "." + pathElements.next(); } resultPath.add(pathElement); } return resultPath; }
From source file:org.quantumbadger.redreader.reddit.RedditAPI.java
private static URI prepareActionUri(final RedditAction action, final LinkedList<NameValuePair> postFields) { switch (action) { case DOWNVOTE: postFields.add(new BasicNameValuePair("dir", "-1")); return Constants.Reddit.getUri(Constants.Reddit.PATH_VOTE); case UNVOTE:/* w w w .jav a 2 s . c o m*/ postFields.add(new BasicNameValuePair("dir", "0")); return Constants.Reddit.getUri(Constants.Reddit.PATH_VOTE); case UPVOTE: postFields.add(new BasicNameValuePair("dir", "1")); return Constants.Reddit.getUri(Constants.Reddit.PATH_VOTE); case SAVE: return Constants.Reddit.getUri(Constants.Reddit.PATH_SAVE); case HIDE: return Constants.Reddit.getUri(Constants.Reddit.PATH_HIDE); case UNSAVE: return Constants.Reddit.getUri(Constants.Reddit.PATH_UNSAVE); case UNHIDE: return Constants.Reddit.getUri(Constants.Reddit.PATH_UNHIDE); case REPORT: return Constants.Reddit.getUri(Constants.Reddit.PATH_REPORT); default: throw new RuntimeException("Unknown post action"); } }
From source file:de.tu_dortmund.ub.data.dswarm.TaskProcessingUnit.java
private static void executeIngests(final String[] files, final String dataModelID, final String resourceID, final String projectName, final String serviceName, final Integer engineThreads, final Properties config) throws Exception { // create job list final LinkedList<Callable<String>> filesToPush = new LinkedList<>(); int cnt = 0;/*from w w w . j av a 2 s . c o m*/ for (final String file : files) { cnt++; filesToPush.add(new Ingest(config, file, dataModelID, resourceID, projectName, cnt)); } // work on jobs final ThreadPoolExecutor pool = new ThreadPoolExecutor(engineThreads, engineThreads, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); execute(serviceName, filesToPush, pool); }
From source file:org.lol.reddit.reddit.RedditAPI.java
private static URI prepareActionUri(final RedditSubredditAction action, final LinkedList<NameValuePair> postFields) { switch (action) { case SUBSCRIBE: postFields.add(new BasicNameValuePair("action", "sub")); return Constants.Reddit.getUri(Constants.Reddit.PATH_SUBSCRIBE); case UNSUBSCRIBE: postFields.add(new BasicNameValuePair("action", "unsub")); return Constants.Reddit.getUri(Constants.Reddit.PATH_SUBSCRIBE); default://from www .ja v a2 s . com throw new RuntimeException("Unknown subreddit action"); } }
From source file:edu.jhu.pha.vospace.storage.SwiftKeystoneStorageManager.java
public static List<FilesObject> listObjectsStartingWith(String container, String startsWith, String path, int limit, String marker, String end_marker, Character delimiter) throws IOException, FilesException { HttpGet method = null;/* www .j a va 2 s . c o m*/ LinkedList<NameValuePair> parameters = new LinkedList<NameValuePair>(); parameters.add(new BasicNameValuePair("format", "json")); if (startsWith != null) { parameters.add(new BasicNameValuePair(FilesConstants.LIST_CONTAINER_NAME_QUERY, startsWith)); } if (path != null) { parameters.add(new BasicNameValuePair("path", path)); } if (limit > 0) { parameters.add(new BasicNameValuePair("limit", String.valueOf(limit))); } if (marker != null) { parameters.add(new BasicNameValuePair("marker", marker)); } if (end_marker != null) { parameters.add(new BasicNameValuePair("marker", end_marker)); } if (delimiter != null) { parameters.add(new BasicNameValuePair("delimiter", delimiter.toString())); } String uri = parameters.size() > 0 ? makeURI(getFileUrl + "/" + sanitizeForURI(container), parameters) : getFileUrl; method = new HttpGet(uri); method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut); method.setHeader(FilesConstants.X_AUTH_TOKEN, strToken); FilesResponse response = new FilesResponse(client.execute(method)); if (response.getStatusCode() == HttpStatus.SC_OK) { ArrayList<FilesObject> objectList = new ArrayList<FilesObject>(); JsonFactory jsonFactory = new JsonFactory(); JsonParser jp = jsonFactory.createJsonParser(IOUtils.toString(response.getResponseBodyAsStream())); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); TypeReference ref = new TypeReference<List<FilesObject>>() { }; objectList = mapper.readValue(jp, ref); return objectList; } else if (response.getStatusCode() == HttpStatus.SC_NO_CONTENT) { logger.debug("Container " + container + " has no Objects"); return new ArrayList<FilesObject>(); } else if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) { throw new FilesNotFoundException("Container was not found", response.getResponseHeaders(), response.getStatusLine()); } else { throw new FilesException("Unexpected Server Result", response.getResponseHeaders(), response.getStatusLine()); } }
From source file:org.lol.reddit.reddit.RedditAPI.java
public static void newCaptcha(final CacheManager cm, final APIResponseHandler.NewCaptchaResponseHandler responseHandler, final RedditAccount user, final Context context) { final LinkedList<NameValuePair> postFields = new LinkedList<NameValuePair>(); postFields.add(new BasicNameValuePair("uh", user.modhash)); cm.makeRequest(new APIPostRequest(Constants.Reddit.getUri("/api/new_captcha"), user, postFields, context) { @Override/*from w w w .ja v a 2 s . c o m*/ public void onJsonParseStarted(JsonValue result, long timestamp, UUID session, boolean fromCache) { try { final APIResponseHandler.APIFailureType failureType = findFailureType(result); if (failureType != null) { responseHandler.notifyFailure(failureType); return; } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "JSON failed to parse"); } responseHandler.notifySuccess(findCaptchaId(result)); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { responseHandler.notifyFailure(type, t, status, readableMessage); } }); }
From source file:org.lol.reddit.reddit.RedditAPI.java
public static void comment(final CacheManager cm, final APIResponseHandler.ActionResponseHandler responseHandler, final RedditAccount user, final String parentIdAndType, final String markdown, final Context context) { final LinkedList<NameValuePair> postFields = new LinkedList<NameValuePair>(); postFields.add(new BasicNameValuePair("thing_id", parentIdAndType)); postFields.add(new BasicNameValuePair("uh", user.modhash)); postFields.add(new BasicNameValuePair("text", markdown)); cm.makeRequest(new APIPostRequest(Constants.Reddit.getUri("/api/comment"), user, postFields, context) { @Override/*from w ww. j a va2s . c om*/ public void onJsonParseStarted(JsonValue result, long timestamp, UUID session, boolean fromCache) { try { final APIResponseHandler.APIFailureType failureType = findFailureType(result); if (failureType != null) { responseHandler.notifyFailure(failureType); return; } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "JSON failed to parse"); } responseHandler.notifySuccess(); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { responseHandler.notifyFailure(type, t, status, readableMessage); } }); }
From source file:org.lol.reddit.reddit.RedditAPI.java
public static void editComment(final CacheManager cm, final APIResponseHandler.ActionResponseHandler responseHandler, final RedditAccount user, final String commentIdAndType, final String markdown, final Context context) { final LinkedList<NameValuePair> postFields = new LinkedList<NameValuePair>(); postFields.add(new BasicNameValuePair("thing_id", commentIdAndType)); postFields.add(new BasicNameValuePair("uh", user.modhash)); postFields.add(new BasicNameValuePair("text", markdown)); cm.makeRequest(new APIPostRequest(Constants.Reddit.getUri("/api/editusertext"), user, postFields, context) { @Override/* w w w . j a v a2 s . com*/ public void onJsonParseStarted(JsonValue result, long timestamp, UUID session, boolean fromCache) { try { final APIResponseHandler.APIFailureType failureType = findFailureType(result); if (failureType != null) { responseHandler.notifyFailure(failureType); return; } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "JSON failed to parse"); } responseHandler.notifySuccess(); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { responseHandler.notifyFailure(type, t, status, readableMessage); } }); }
From source file:org.lol.reddit.reddit.RedditAPI.java
public static void action(final CacheManager cm, final APIResponseHandler.ActionResponseHandler responseHandler, final RedditAccount user, final String idAndType, final RedditAction action, final Context context) { final LinkedList<NameValuePair> postFields = new LinkedList<NameValuePair>(); postFields.add(new BasicNameValuePair("id", idAndType)); postFields.add(new BasicNameValuePair("uh", user.modhash)); final URI url = prepareActionUri(action, postFields); cm.makeRequest(new APIPostRequest(url, user, postFields, context) { @Override/*w w w . j a v a 2 s . c om*/ protected void onCallbackException(final Throwable t) { BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { responseHandler.notifyFailure(type, t, status, readableMessage); } @Override public void onJsonParseStarted(final JsonValue result, final long timestamp, final UUID session, final boolean fromCache) { try { final APIResponseHandler.APIFailureType failureType = findFailureType(result); if (failureType != null) { responseHandler.notifyFailure(failureType); return; } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "JSON failed to parse"); } responseHandler.notifySuccess(); } }); }