List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:org.melati.admin.Admin.java
/** * Prepares the context in preparation for serving a template to view a * selection of rows.//from ww w . ja va2 s. c o m * <p> * Any form fields in the context with names starting "field_" are assumed to * hold values that must be matched in selected rows (if not null). * <p> * An encoding of the resulting whereClause is added to the context. "AND" is * replaced by an & separator. * <p> * A form field with name "start" is assumed to hold the number of the start * row in the result set. The default is zero. The next 20 rows are selected * and added as to the context as "results". * * @return The prepared context. */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected static ServletTemplateContext selection(ServletTemplateContext context, Melati melati, boolean paged) { final Table<?> table = melati.getTable(); final Database database = table.getDatabase(); // sort out search criteria final Persistent criteria = table.newPersistent(); Vector<Object> whereClause = new Vector<Object>(); for (Enumeration<Column<?>> c = table.columns(); c.hasMoreElements();) { Column<?> column = c.nextElement(); String name = "field_" + column.getName(); String fieldValue = Form.getFieldNulled(context, name); if (fieldValue != null) { column.setRaw_unsafe(criteria, column.getType().rawOfString(fieldValue)); // FIXME Needs to work for dates whereClause.addElement(name + "=" + melati.urlEncode(fieldValue)); } } context.put("whereClause", EnumUtils.concatenated("&", whereClause.elements())); // sort out ordering ReferencePoemType searchColumnsType = getSearchColumnsType(database, table); Vector<Object> orderings = new Vector<Object>(); Vector<Object> orderQuery = new Vector<Object>(); for (int o = 0; o <= table.displayColumnsCount(DisplayLevel.summary); ++o) { String name = "field_order-" + o; String orderColumnIDString = Form.getFieldNulled(context, name); Integer orderColumnID; if (orderColumnIDString != null) { String toggleName = "field_order-" + o + "-toggle"; String orderColumnSortOrderToggle = Form.getFieldNulled(context, toggleName); Boolean toggle = new Boolean(orderColumnSortOrderToggle); orderColumnID = (Integer) searchColumnsType.rawOfString(orderColumnIDString); ColumnInfo info = (ColumnInfo) searchColumnsType.cookedOfRaw(orderColumnID); String desc = Boolean.TRUE.equals(info.getSortdescending()) ? (Boolean.TRUE.equals(toggle) ? "" : " DESC") : (Boolean.TRUE.equals(toggle) ? " DESC" : ""); orderings.addElement(database.quotedName(info.getName()) + desc); orderQuery.addElement(name + "=" + orderColumnIDString); } } String orderBySQL = null; if (orderings.elements().hasMoreElements()) orderBySQL = EnumUtils.concatenated(", ", orderings.elements()); context.put("orderClause", EnumUtils.concatenated("&", orderQuery.elements())); context.put("inclusionColumns", inclusionColumns(context, table)); int start = 0; String startString = Form.getFieldNulled(context, "start"); if (startString != null) { try { start = Math.max(0, Integer.parseInt(startString)); } catch (NumberFormatException e) { throw new MelatiBugMelatiException("How did you get that in there?", new FormParameterException("start", "Param must be an Integer")); } } if (paged) { final int resultsPerPage = 20; context.put("results", new CountedDumbPagedEnumeration(table.selection(criteria, orderBySQL, false, false), start, resultsPerPage, table.cachedCount(criteria, false, false).count())); } else { context.put("results", table.selection(criteria, orderBySQL, false, false)); } return context; }
From source file:org.apache.axis2.format.ElementHelperTest.java
public void testGetTextAsStreamWithoutCaching() throws Exception { DataSource ds = new RandomDataSource(654321, 64, 128, 20000000); Vector<InputStream> v = new Vector<InputStream>(); v.add(new ByteArrayInputStream("<a>".getBytes("ascii"))); v.add(ds.getInputStream());/*from w w w . j av a 2 s . c o m*/ v.add(new ByteArrayInputStream("</a>".getBytes("ascii"))); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); XMLStreamReader reader = factory.createXMLStreamReader(new SequenceInputStream(v.elements()), "ascii"); OMElement element = new StAXOMBuilder(reader).getDocumentElement(); Reader in = ElementHelper.getTextAsStream(element, false); compareStreams(new InputStreamReader(ds.getInputStream(), "ascii"), in); }
From source file:org.openflexo.foundation.resource.ResourceRepository.java
/** * Return an enumeration of all folders, by recursively explore the tree * /*from ww w .ja va2 s .c om*/ * @return an Enumeration of FlexoComponentFolder elements */ public Enumeration<RepositoryFolder<R>> allFolders() { Vector<RepositoryFolder<R>> temp = new Vector<RepositoryFolder<R>>(); addFolders(temp, getRootFolder()); return temp.elements(); }
From source file:net.wastl.webmail.xml.XMLGenericModel.java
/** * We need to synchronize that because it can cause problems with multiple threads *//*from w w w .java 2 s .co m*/ public synchronized void removeAllStateVars(String name) { NodeList nl = getNodeListXPath("//STATEDATA/VAR"); if (nl != null) { /* This suxx: NodeList Object is changed when removing children !!! I will store all nodes that should be deleted in a Vector and delete them afterwards */ int length = nl.getLength(); Vector<Element> v = new Vector<Element>(nl.getLength()); for (int i = 0; i < length; i++) { if (((Element) nl.item(i)).getAttribute("name").equals(name)) { v.addElement((Element) nl.item(i)); } } Enumeration enumVar = v.elements(); while (enumVar.hasMoreElements()) { Node n = (Node) enumVar.nextElement(); statedata.removeChild(n); } } invalidateCache(); }
From source file:org.apache.jetspeed.services.resources.VariableResourcesService.java
/** * The purpose of this method is to get the configuration resource * with the given name as a vector.//from ww w.ja va2 s . co m * * @param name The resource name. * @return The value of the resource as a vector. */ public Vector getVector(String name) { Vector std = (Vector) vectors.get(name); if (std == null) { std = super.getVector(name); if (std != null) { Vector newstd = new Vector(); Enumeration en = std.elements(); while (en.hasMoreElements()) { newstd.addElement(substituteString((String) en.nextElement())); } std = newstd; vectors.put(name, std); } } return std; }
From source file:com.monarchapis.driver.servlet.ApiRequestTest.java
@Before public void setup() throws IOException { when(serviceResolver.required(AuthenticationSettings.class)).thenReturn(authenticationSettings); authenticationSettings.setDelegateAuthorization(false); authenticationSettings.setBypassRateLimiting(false); ServiceResolver.setInstance(serviceResolver); when(request.getInputStream()).thenAnswer(new Answer<ServletInputStream>() { @Override//from ww w.j a v a2 s. co m public ServletInputStream answer(InvocationOnMock invocation) throws Throwable { return new ServletInputStreamWrapper("This is a test".getBytes()); } }); when(request.getProtocol()).thenReturn("http"); when(request.getServerName()).thenReturn("localhost"); when(request.getServerPort()).thenReturn(8080); when(request.getRequestURI()).thenReturn("/test"); when(request.getQueryString()).thenReturn("a=1&b=2"); when(request.getRemoteAddr()).thenReturn("127.0.0.1"); when(request.getMethod()).thenReturn("POST"); when(request.getRequestURL()).thenAnswer(new Answer<StringBuffer>() { @Override public StringBuffer answer(InvocationOnMock invocation) throws Throwable { return new StringBuffer("/test"); } }); final Vector<String> headerNames = new Vector<String>(); headerNames.add("name1"); headerNames.add("name2"); when(request.getHeaderNames()).thenAnswer(new Answer<Enumeration<String>>() { @Override public Enumeration<String> answer(InvocationOnMock invocation) throws Throwable { return headerNames.elements(); } }); when(request.getHeaders(anyString())).thenAnswer(new Answer<Enumeration<String>>() { @Override public Enumeration<String> answer(InvocationOnMock invocation) throws Throwable { String name = invocation.getArgumentAt(0, String.class); Vector<String> headerValues = new Vector<String>(); headerValues.add(name + "-value1"); headerValues.add(name + "-value2"); return headerValues.elements(); } }); apiRequest = new ApiRequest(request); }
From source file:org.apache.geode.internal.util.CollectionUtilsJUnitTest.java
@Test public void testAddAllCollectionEnumerationWithUnmodified() { final HashSet<String> set = new HashSet<>(); set.add("one"); set.add("two"); final Vector<String> v = new Vector<>(); v.add("one"); boolean modified = CollectionUtils.addAll(set, v.elements()); assertTrue(!modified);//w ww .j av a 2 s . c om assertEquals(2, set.size()); }
From source file:org.jasig.portal.security.provider.ChainingSecurityContext.java
public synchronized Enumeration getSubContextNames() { Vector scNames = new Vector(); for (int i = 0; i < mySubContexts.size(); i++) { Entry entry = (Entry) mySubContexts.get(i); if (entry.getKey() != null) { scNames.add(entry.getKey()); }/*from w w w . j av a 2s . c o m*/ } return scNames.elements(); }
From source file:weka.core.old.NoNeighboursLinearNNSearch.java
/** * Returns an enumeration describing the available options. * // w w w . j a v a2 s.c om * @return an enumeration of all the available options. */ public Enumeration listOptions() { Vector result = new Vector(); result.add(new Option("\tSkip identical instances (distances equal to zero).\n", "S", 1, "-S")); return result.elements(); }
From source file:org.opensc.pkcs11.spi.PKCS11KeyStoreSpi.java
@Override public Enumeration<String> engineAliases() { // Enumeration is efinitely a misconception, as you can see // by the code below... Set<String> keys = this.entries.keySet(); Vector<String> sv = new Vector<String>(keys.size()); sv.addAll(keys);//from w ww.j ava 2 s . co m return sv.elements(); }