List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:Main.java
public static <T> List<T> toList(Collection<T> c) { return Collections.list(Collections.enumeration(c)); }
From source file:Main.java
public static final <T> Enumeration<T> toEnumeration(final Collection<T> collection) { return Collections.enumeration(collection); }
From source file:Main.java
public static String toString(Collection c/*<String>*/, String separator) { return toString(Collections.enumeration(c), separator); }
From source file:Main.java
public static String dumpLuxLevel() { String result = ""; if (mLevelSet == null) mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET, null);/*from w w w . ja v a2 s . com*/ if (mLevelSet != null) { ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet)); Collections.sort(array, mComparator); result = array.toString(); } return result; }
From source file:Main.java
public static boolean getBoundaryLevel(Point bound) { if (mLevelSet == null) mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET, null);/*from w w w . ja v a 2 s .c o m*/ if (mLevelSet != null) { ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet)); Collections.sort(array, mComparator); bound.x = Integer.valueOf(array.get(0)); bound.y = Integer.valueOf(array.get(array.size() - 1)); return true; } return false; }
From source file:Main.java
public static boolean isLowestLevel(int level) { if (mLevelSet == null) mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET, null);/*www.ja v a 2 s. com*/ if (mLevelSet != null) { if (mLevelSet.size() < 5) // data is too few to judge lowest return false; ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet)); Collections.sort(array, mComparator); // TODO: may need check statistics to ensure the level is true lowest and not false alarm. if (level <= Integer.valueOf(array.get(0))) return true; } return false; }
From source file:io.github.tsabirgaliev.ZipperInputStreamTest.java
static Enumeration<ZipperInputStream.ZipEntryData> enumerate(ZipperInputStream.ZipEntryData... files) { return Collections.enumeration(Arrays.asList(files)); }
From source file:com.enonic.cms.core.localization.LocalizationResourceBundle.java
public Enumeration<String> getKeys() { HashSet<String> set = new HashSet<String>(); for (Object o : this.props.keySet()) { set.add((String) o);/*from ww w. ja v a2 s . c om*/ } return Collections.enumeration(set); }
From source file:Main.java
/** * Sorts <code>source</code> and adds the first n entries to * <code>dest</code>. If <code>source</code> contains less than n entries, * all of them are added to <code>dest</code>. * /* w w w . ja v a 2s . c om*/ * If adding an entry to <code>dest</code> does not increase the * collection's size, for example if <code>dest</code> is a set and already * contained the inserted contact, an additional entry of * <code>source</code> will be added, if available. This guarantees that * <code>n</code> new, distinct entries are added to collection * <code>dest</code> as long as this can be fulfilled with the contents of * <code>source</code>, and as <code>dest</code> does recognise duplicate * entries. Consequently, this guarantee does not hold for simple lists. * * Both collections may not be <code>null</code>. * * @param <T> * the entry type of the collections. * @param source * the source collection. * @param dest * the destination collection. * @param order * the order in which <code>source</code> is to be sorted. * @param n * the number of new entries that are to be added to * <code>dest</code>. */ public static <T> void copyNSorted(final Collection<? extends T> source, final Collection<? super T> dest, final Comparator<? super T> order, final int n) { final List<? extends T> src = Collections.list(Collections.enumeration(source)); Collections.sort(src, order); final Iterator<? extends T> it = src.iterator(); final int maxEntries = dest.size() + n; while (it.hasNext() && dest.size() < maxEntries) { dest.add(it.next()); } }
From source file:com.github.restdriver.clientdriver.unit.HttpRealRequestTest.java
@Test public void instantiationWithHttpRequestPopulatesCorrectly() throws IOException { HttpServletRequest mockRequest = mock(HttpServletRequest.class); String expectedPathInfo = "someUrlPath"; String expectedMethod = "GET"; Enumeration<String> expectedHeaderNames = Collections.enumeration(Arrays.asList("header1")); String bodyContent = "bodyContent"; String expectedContentType = "contentType"; when(mockRequest.getPathInfo()).thenReturn(expectedPathInfo); when(mockRequest.getMethod()).thenReturn(expectedMethod); when(mockRequest.getQueryString()).thenReturn("hello=world"); when(mockRequest.getHeaderNames()).thenReturn(expectedHeaderNames); when(mockRequest.getHeader("header1")).thenReturn("thisIsHeader1"); when(mockRequest.getInputStream())/*from w w w. java 2 s . c o m*/ .thenReturn(new DummyServletInputStream(IOUtils.toInputStream(bodyContent))); when(mockRequest.getContentType()).thenReturn(expectedContentType); RealRequest realRequest = new HttpRealRequest(mockRequest); assertThat((String) realRequest.getPath(), is(expectedPathInfo)); assertThat(realRequest.getMethod(), is(Method.GET)); assertThat(realRequest.getParams().size(), is(1)); assertThat((String) realRequest.getParams().get("hello").iterator().next(), is("world")); assertThat((String) realRequest.getHeaders().get("header1"), is("thisIsHeader1")); assertThat((String) realRequest.getBodyContentType(), is(expectedContentType)); }