List of usage examples for java.util LinkedList addLast
public void addLast(E e)
From source file:org.gcaldaemon.core.ldap.ContactLoader.java
private static final GmailContact[] parseCSV(String csv) { // Parse lines if (csv == null) { return null; }//from www . ja va 2 s . co m LinkedList contactList = new LinkedList(); StringTokenizer st = new StringTokenizer(csv, "\r\n"); while (st.hasMoreTokens()) { GmailContact contact = parseLine(st.nextToken()); if (contact != null) { if (contact.name.length() == 0 && contact.email.length() == 0) { continue; } contactList.addLast(contact); } } // Convert list to array GmailContact[] array = new GmailContact[contactList.size()]; contactList.toArray(array); // Return contact array return array; }
From source file:org.openxdm.xcap.client.test.error.MethodNotAllowedTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list/>" + "</resource-lists>"; // send put request and get response Response putResponse = client.put(key, appUsage.getMimetype(), content, null); // check put response assertTrue("Put response must exists", putResponse != null); assertTrue("Put response code should be 201", putResponse.getCode() == 201); // create element selector LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("pre:resource-lists"); ElementSelectorStep step2 = new ElementSelectorStep("pre:list"); elementSelectorSteps.add(step1);//w ww . j av a 2s . c o m elementSelectorSteps.addLast(step2); // set namespace bindings to ask Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("pre", appUsage.getDefaultDocumentNamespace()); // create namespace bindings uri in a fake document uri key MethodNotAllowedTestFakeUserDocumentUriKey nsKey = new MethodNotAllowedTestFakeUserDocumentUriKey( appUsage.getAUID(), user, documentName, new ElementSelector(elementSelectorSteps), namespaces); // send put request and get response Response nsPutResponse = client.put(nsKey, appUsage.getMimetype(), content, null); // check put response, must be method not allowed assertTrue("Put response must exists", nsPutResponse != null); assertTrue("Put response code should be " + MethodNotAllowedException.RESPONSE_STATUS, nsPutResponse.getCode() == MethodNotAllowedException.RESPONSE_STATUS); // send delete request and get response Response nsDeleteResponse = client.delete(nsKey, null); // check delete response, must be method not allowed assertTrue("Put response must exists", nsDeleteResponse != null); assertTrue("Put response code should be " + MethodNotAllowedException.RESPONSE_STATUS, nsDeleteResponse.getCode() == MethodNotAllowedException.RESPONSE_STATUS); // clean up client.delete(key, null); }
From source file:org.openxdm.xcap.client.test.success.DeleteElementByAttrTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); // the doc to put String document = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list name=\"friends\"/>" + "<list name=\"enemies\"/>" + "</resource-lists>"; // send put request and get response Response initialPutResponse = client.put(key, appUsage.getMimetype(), document, null); // check put response assertTrue("Put response must exists", initialPutResponse != null); assertTrue("Put response code should be 201", initialPutResponse.getCode() == 201); // create uri LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("resource-lists"); ElementSelectorStep step2 = new ElementSelectorStepByAttr("list", "name", "enemies"); elementSelectorSteps.add(step1);/*from w ww . j ava 2s . c o m*/ elementSelectorSteps.addLast(step2); UserElementUriKey elemKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, new ElementSelector(elementSelectorSteps), null); // send delete request and get response Response elemDeleteResponse = client.delete(elemKey, null); // check delete response assertTrue("Delete response must exists", elemDeleteResponse != null); assertTrue("Delete response code should be 200", elemDeleteResponse.getCode() == 200); // send get request and get response Response elemGetResponse = client.get(elemKey, null); // check get response assertTrue("Get response must exists", elemGetResponse != null); assertTrue("Get response code should be 404", elemGetResponse.getCode() == 404); // clean up client.delete(key, null); }
From source file:org.openxdm.xcap.client.test.success.DeleteElementByAttrPosTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); // the doc to put String document = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list name=\"friends\"/>" + "<list name=\"enemies\"/>" + "</resource-lists>"; // send put request and get response Response initialPutResponse = client.put(key, appUsage.getMimetype(), document, null); // check put response assertTrue("Put response must exists", initialPutResponse != null); assertTrue("Put response code should be 201", initialPutResponse.getCode() == 201); // create uri LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("resource-lists"); ElementSelectorStep step2 = new ElementSelectorStepByPosAttr("list", 2, "name", "enemies"); elementSelectorSteps.add(step1);//from www .ja v a2 s . c o m elementSelectorSteps.addLast(step2); UserElementUriKey elemKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, new ElementSelector(elementSelectorSteps), null); // send delete request and get response Response elemDeleteResponse = client.delete(elemKey, null); // check delete response assertTrue("Delete response must exists", elemDeleteResponse != null); assertTrue("Delete response code should be 200", elemDeleteResponse.getCode() == 200); // send get request and get response Response elemGetResponse = client.get(elemKey, null); // check get response assertTrue("Get response must exists", elemGetResponse != null); assertTrue("Get response code should be 404", elemGetResponse.getCode() == 404); // clean up client.delete(key, null); }
From source file:org.batoo.jpa.core.pool.GenericKeyedPool.java
/** * {@inheritDoc}/*from ww w . j a va2s.c om*/ * */ @Override public V borrowObject(K key) throws Exception, NoSuchElementException, IllegalStateException { final LinkedList<V> pool = this.getPool(key); if (pool.size() <= GenericKeyedPool.MIN_SIZE) { synchronized (this) { while (pool.size() <= GenericKeyedPool.MIN_SIZE) { pool.addLast(this.factory.makeObject(key)); } } } return pool.pollFirst(); }
From source file:org.openxdm.xcap.client.test.error.NotValidXMLFragmentTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // exception for response codes NotValidXMLFragmentConflictException exception = new NotValidXMLFragmentConflictException(); // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); String documentContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list/>" + "</resource-lists>"; String goodElementContent = "<list xmlns=\"urn:ietf:params:xml:ns:resource-lists\" name=\"friends\"/>"; String badElementContent = "not valid xml fragment"; // send put request and get response Response response = client.put(key, appUsage.getMimetype(), documentContent, null); // check put response assertTrue("Put response must exists", response != null); assertTrue("Put response code should be 201", response.getCode() == 201); // create uri LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("resource-lists"); ElementSelectorStep step2 = new ElementSelectorStepByPos("list", 2); elementSelectorSteps.add(step1);/*from w w w . java2s . c om*/ elementSelectorSteps.addLast(step2); ElementSelector elementSelector = new ElementSelector(elementSelectorSteps); UserElementUriKey elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, elementSelector, null); // send put request and get response response = client.put(elementKey, ElementResource.MIMETYPE, badElementContent, null); // check put response assertTrue("Put response must exists", response != null); assertTrue( "Put response content must be the expected and the response code should be " + exception.getResponseStatus(), response.getCode() == exception.getResponseStatus() && response.getContent().equals(exception.getResponseContent())); // send put request and get response response = client.put(elementKey, ElementResource.MIMETYPE, goodElementContent, null); // check put response assertTrue("Put response must exists", response != null); assertTrue("Put response code should be 201", response.getCode() == 201); // send put request and get response response = client.put(elementKey, ElementResource.MIMETYPE, badElementContent, null); // check put response assertTrue("Put response must exists", response != null); assertTrue( "Put response content must be the expected and the response code should be " + exception.getResponseStatus(), response.getCode() == exception.getResponseStatus() && response.getContent().equals(exception.getResponseContent())); // clean up client.delete(key, null); }
From source file:org.openxdm.xcap.client.test.error.BadRequestTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list/>" + "<list name=\"enemies\"/>" + "</resource-lists>"; // send put request and get response Response response = client.put(key, appUsage.getMimetype(), content, null); // check put response assertTrue("Put response must exists", response != null); assertTrue("Put response code should be 201", response.getCode() == 201); // create element selector LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("pre1:resource-lists"); ElementSelectorStep step2 = new ElementSelectorStepByPos("pre2:list", 1); elementSelectorSteps.add(step1);/*from w w w . j a v a 2s . co m*/ elementSelectorSteps.addLast(step2); // set namespace bindings Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("pre1", appUsage.getDefaultDocumentNamespace()); // create attr put uri UserAttributeUriKey attrKey = new UserAttributeUriKey(appUsage.getAUID(), user, documentName, new ElementSelector(elementSelectorSteps), new AttributeSelector("name"), namespaces); // send put request and get response Response putResponse = client.put(attrKey, AttributeResource.MIMETYPE, "friends", null); // check put response, must be bad request assertTrue("Put response must exists", putResponse != null); assertTrue("Put response code should be " + BadRequestException.RESPONSE_STATUS, putResponse.getCode() == BadRequestException.RESPONSE_STATUS); // create attr delete & get uri elementSelectorSteps.removeLast(); step2 = new ElementSelectorStepByPos("pre2:list", 2); elementSelectorSteps.addLast(step2); UserAttributeUriKey anotherAttrKey = new UserAttributeUriKey(appUsage.getAUID(), user, documentName, new ElementSelector(elementSelectorSteps), new AttributeSelector("name"), null); // send get request and get response Response getResponse = client.get(anotherAttrKey, null); // check get response, must be bad request assertTrue("Delete response must exists", getResponse != null); assertTrue("Delete response code should be " + BadRequestException.RESPONSE_STATUS, getResponse.getCode() == BadRequestException.RESPONSE_STATUS); // send delete request and get response Response deleteResponse = client.delete(anotherAttrKey, null); // check put response, must be bad request assertTrue("Delete response must exists", deleteResponse != null); assertTrue("Delete response code should be " + BadRequestException.RESPONSE_STATUS, deleteResponse.getCode() == BadRequestException.RESPONSE_STATUS); // cleanup client.delete(key, null); }
From source file:com.commander4j.sys.JHostList.java
public LinkedList<JHost> getHosts() { final LinkedList<JHost> temphostlist = new LinkedList<JHost>(); temphostlist.clear();//from w ww . j a v a 2 s .com int s = hosts.size(); if (s > 0) { for (int x = 1; x <= s; x++) { temphostlist.addLast(hosts.get(String.valueOf(x))); } } return temphostlist; }
From source file:com.alibaba.citrus.turbine.util.CsrfToken.java
/** csrf token?token? */ public String getUniqueToken() { HttpSession session = request.getSession(); String key = getKey();/*from w w w .j a va 2s. c o m*/ String tokenOfRequest = (String) request.getAttribute(key); int maxTokens = getMaxTokens(); if (tokenOfRequest == null) { // token // ?session?token // tokentokensession // tokentoken LinkedList<String> tokens = getTokensInSession(session, key); tokenOfRequest = getGenerator().generateUniqueToken(); request.setAttribute(key, tokenOfRequest); tokens.addLast(tokenOfRequest); while (tokens.size() > maxTokens) { tokens.removeFirst(); } setTokensInSession(session, key, tokens); } return tokenOfRequest; }
From source file:com.linuxbox.enkive.statistics.consolidation.AbstractConsolidator.java
/** * this method recurses through a given template map to add consolidated * data to a new map as defined by each key's ConsolidationDefinition * //from w ww . j a va 2s.c o m * @param templateData * - the map used to trace * @param consolidatedMap * - the map being built * @param path * - the path to variables being used for trace * @param statKeys * - the list of a gatherer's consolidation definitions * @param gathererData * - all the data cooresponding to a given gatherer * @return returns the built consolidatedMap variable */ protected Map<String, Object> generateConsolidatedMap(Map<String, Object> templateData, Map<String, Object> consolidatedMap, LinkedList<String> path, List<ConsolidationKeyHandler> statKeys, List<Map<String, Object>> gathererData) { for (String key : templateData.keySet()) { path.addLast(key); ConsolidationKeyHandler matchingDef = findMatchingPath(path, statKeys); if (matchingDef != null) { consolidateMaps(consolidatedMap, gathererData, matchingDef, path); } else { if (templateData.get(key) instanceof Map) { generateConsolidatedMap((Map<String, Object>) templateData.get(key), consolidatedMap, path, statKeys, gathererData); } } path.removeLast(); } return consolidatedMap; }