List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:mml.handler.get.MMLGetImgHandler.java
/** * Create the list of images// w w w . java 2 s . c om * @param req the http request * @param map the page reference to dimensions map * @return the images as a sequence of IMGs inside divs */ String createImgs(HttpServletRequest req, HashMap<String, String> map) { Element images = new Element("div"); images.addAttribute("id", "images"); Set<String> keys = map.keySet(); String[] names = new String[keys.size()]; keys.toArray(names); if (pageRefs == null) { ImageComparator comp = new ImageComparator(); Arrays.sort(names, comp); } else { names = sortByPageRefs(names); } for (String name : names) { String jDoc = map.get(name); JSONObject info = (JSONObject) JSONValue.parse(jDoc); Element wrap = new Element("div"); wrap.addAttribute("class", "image"); Element img = new Element("img"); String jDocId = (String) info.get(JSONKeys.DOCID); String src = "/" + jDocId; img.addAttribute("src", src); img.addAttribute("id", "image_" + name); //String mimetype = (String)info.get("mimetype"); int width = ((Number) info.get("width")).intValue(); int height = ((Number) info.get("height")).intValue(); img.addAttribute("style", "width: 100%; max-width: " + width + "px"); img.addAttribute("data-width", Integer.toString(width)); img.addAttribute("data-height", Integer.toString(height)); img.addAttribute("data-ref", name); wrap.addChild(img); images.addChild(wrap); } return images.toString(); }
From source file:org.n52.sos.service.it.MockHttpClient.java
private MockHttpServletRequest build() { try {//from w ww .j av a2s . c om final MockHttpServletRequest req = new MockHttpServletRequest(context); req.setMethod(method); for (String header : headers.keySet()) { for (String value : headers.get(header)) { req.addHeader(header, value); } } final StringBuilder queryString = new StringBuilder(); if (query != null && !query.isEmpty()) { boolean first = true; for (String key : query.keySet()) { final Set<String> values = query.get(key); req.addParameter(key, values.toArray(new String[values.size()])); if (first) { queryString.append("?"); first = false; } else { queryString.append("&"); } queryString.append(key).append("="); Iterator<String> i = values.iterator(); queryString.append(i.next()); while (i.hasNext()) { queryString.append(",").append(i.next()); } } req.setQueryString(queryString.toString()); } req.setRequestURI(path + queryString.toString()); if (path == null) { path = "/"; } req.setPathInfo(path); if (content != null) { req.setContent(content.getBytes(MockHttpExecutor.ENCODING)); } return req; } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } }
From source file:com.dianping.resource.io.util.ClassUtils.java
/** * Return all interfaces that the given class implements as array, * including ones implemented by superclasses. * <p>If the class itself is an interface, it gets returned as sole interface. * @param clazz the class to analyze for interfaces * @param classLoader the ClassLoader that the interfaces need to be visible in * (may be {@code null} when accepting all declared interfaces) * @return all interfaces that the given object implements as array *///from www .j av a 2s . c o m public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) { Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader); return ifcs.toArray(new Class<?>[ifcs.size()]); }
From source file:com.intel.databackend.datasources.hbase.DataHbaseDao.java
@Override public String[] scanForAttributeNames(String accountId, String componentId, long start, long stop) throws IOException { logger.debug("Scanning HBase: acc: {} cid: {} start: {} stop: {}", accountId, componentId, start, stop); Scan scan = new HbaseScanManager(accountId, componentId).create(start, stop) .setFilter(new ColumnPrefixFilter(Columns.BYTES_ATTRIBUTE_COLUMN_PREFIX)).getScan(); Set<String> attributeNames = retrieveAttributeNames(scan); return attributeNames.toArray(new String[attributeNames.size()]); }
From source file:org.grails.datastore.mapping.redis.engine.RedisPropertyValueIndexer.java
private void deleteKeys(Set<String> toDelete) { if (toDelete != null && !toDelete.isEmpty()) { template.del(toDelete.toArray(new String[toDelete.size()])); }/*w w w .j ava 2 s . c o m*/ }
From source file:com.retroduction.carma.resolvers.util.TestCaseInstantiationVerifier.java
private void reinitPrivateClassLoader() { Set<File> combinedClassPathSet = new HashSet<File>(); if (this.getClassPath() != null) { combinedClassPathSet.addAll(this.getClassPath()); }//from w w w . j a va 2 s .c o m if (this.getTestClassPath() != null) { combinedClassPathSet.addAll(this.getTestClassPath()); } if (this.getDependencyClassPath() != null) { for (URL url : this.getDependencyClassPath()) { File file = new File(url.getFile()); combinedClassPathSet.add(file); } } Set<URL> validURLs = this.filterInvalidURLs(combinedClassPathSet); this.setLoader(new URLClassLoader(validURLs.toArray(new URL[0]), this.getClass().getClassLoader())); }
From source file:org.opencredo.esper.config.xml.EsperConfigurationDrivenOneInnerStatementEsperTemplateParserTest.java
@Test public void testSendSampleEvent() { Set<EsperStatement> statements = template.getStatements(); assertEquals(1, statements.size());/*w w w . ja v a 2s. c o m*/ EsperStatement[] statementsArray = new EsperStatement[statements.size()]; statements.toArray(statementsArray); Set<UpdateListener> listeners = statementsArray[0].getListeners(); assertEquals(1, listeners.size()); UpdateListener[] listenersArray = new UpdateListener[listeners.size()]; listeners.toArray(listenersArray); CallRecordingListener listener = (CallRecordingListener) listenersArray[0]; template.sendEvent(new SampleEvent()); assertEquals(1, listener.getNumberOfTimesInvoked()); }
From source file:org.opencredo.esper.config.xml.MultipleInnerStatementEsperTemplateParserTest.java
@Test public void testSendSampleEvent() { Set<EsperStatement> statements = template.getStatements(); assertEquals(2, statements.size());/* www. j a v a 2 s . co m*/ EsperStatement[] statementsArray = new EsperStatement[statements.size()]; statements.toArray(statementsArray); Set<UpdateListener> listeners = statementsArray[0].getListeners(); assertEquals(1, listeners.size()); UpdateListener[] listenersArray = new UpdateListener[listeners.size()]; listeners.toArray(listenersArray); CallRecordingListener listener = (CallRecordingListener) listenersArray[0]; template.sendEvent(new SampleEvent()); assertEquals(1, listener.getNumberOfTimesInvoked()); }
From source file:com.freetmp.common.util.ClassUtils.java
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) { Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader); return ifcs.toArray(new Class<?>[ifcs.size()]); }
From source file:com.blocks.framework.utils.date.StringUtil.java
/** * ???Long[]//from ww w . j a va 2 s. c o m * * @param Long[] * * @return String ?? */ public static Long[] delRepeatData(Long[] intArr) { ArrayList<Long> al = new ArrayList<Long>(); if (intArr != null) { for (int i = 0; i < intArr.length; i++) { al.add(intArr[i]); } } Set<Long> set = new HashSet<Long>(al); return set.toArray(new Long[0]); }