List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:es.caib.sgtsic.util.Zips.java
public static DataHandler generateZip(Map<String, DataHandler> documents) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(baos); for (String key : documents.keySet()) { InputStream is = new ByteArrayInputStream(DataHandlers.dataHandlerToByteArray(documents.get(key))); ZipEntry zipEntry = new ZipEntry(key); zip.putNextEntry(zipEntry);//from w w w . ja v a 2s . c om IOUtils.copy(is, zip); zip.closeEntry(); is.close(); } zip.close(); baos.close(); return DataHandlers.byteArrayToDataHandler(baos.toByteArray(), "application/zip"); }
From source file:com.rdsic.pcm.service.impl.ReportImpl.java
/** * Execute a stored procedure in DB by providing parameter list in format: * par1=val1#par2=val2#.../*from ww w .j av a 2 s .c om*/ * * @param proc * @param parameter * @return */ private static String execProc(String proc, String parameter) throws PCMException { String param = prepareParameter(proc, parameter); System.out.println(String.format("Calling proc [%s] with parameter [%s]", proc, parameter)); List<Map<String, Object>> data = GenericHql.INSTANCE.querySQL(String.format(" CALL %s(:param) ", proc), -1, "param", param); // this setting for all null object to empty string to advoid item missing in output json for (Map<String, Object> m : data) { for (String k : m.keySet()) { if (m.get(k) == null) { m.put(k, ""); } } } JSONObject json = new JSONObject(); json.put("items", data); return json.toString(); }
From source file:Main.java
static public String assemblyUrlByCommon(String url, Map<String, String> params) { if (params == null && params.size() == 0) { return url; } else {/*from ww w . j ava 2 s.c o m*/ StringBuilder sb = new StringBuilder(url); sb.append("?"); Set<String> keys = params.keySet(); int i = 0; for (String key : keys) { String value = params.get(key); sb.append(key).append("=").append(value); if (i != keys.size() - 1) { sb.append("&"); } i++; } return sb.toString(); } }
From source file:org.jongo.mocks.UserMock.java
public static UserMock instanceOf(final Map<String, String> columns) { UserMock instance = new UserMock(); for (String k : columns.keySet()) { if (k.equalsIgnoreCase("id")) { instance.id = Integer.valueOf(columns.get(k)); } else if (k.equalsIgnoreCase("name")) { instance.name = columns.get(k); } else if (k.equalsIgnoreCase("age")) { instance.age = Integer.valueOf(columns.get(k)); } else if (k.equalsIgnoreCase("credit")) { instance.credit = new BigDecimal(columns.get(k)); } else if (k.equalsIgnoreCase("birthday")) { instance.birthday = dateFTR.parseDateTime(columns.get(k)); } else if (k.equalsIgnoreCase("lastupdate")) { instance.lastupdate = dateTimeFTR.parseDateTime(columns.get(k)); } else {//w ww . j a va2 s . c o m System.out.println("Failed to parse column " + k + " with value " + columns.get(k)); } } return instance; }
From source file:de.micromata.genome.tpsb.GroovyExceptionInterceptor.java
protected static String renderMethodBlock(Map<String, Method> collectedMethods) { StringBuilder sb = new StringBuilder(); for (String methn : collectedMethods.keySet()) { Method m = collectedMethods.get(methn); sb.append(" ").append(methn).append("{\n")// .append(" return wrappExpectedEx( { target.").append(m.getName()).append("("); for (int i = 0; i < m.getParameterTypes().length; ++i) { if (i > 0) { sb.append(", "); }//ww w. j a v a2 s .c o m sb.append("arg").append(i); } sb.append(");"); sb.append("} );\n }\n"); } return sb.toString(); }
From source file:max.hubbard.bettershops.Utils.ItemUtils.java
private static String mapToString(Map<String, Object> map) { StringBuilder stringBuilder = new StringBuilder(); for (String key : map.keySet()) { if (stringBuilder.length() > 0) { stringBuilder.append("&"); }/*from ww w .j av a 2 s . com*/ String value = map.get(key).toString(); try { stringBuilder.append((key != null ? URLEncoder.encode(key, "UTF-8") : "")); stringBuilder.append("="); stringBuilder.append(value != null ? URLEncoder.encode(value, "UTF-8") : ""); } catch (UnsupportedEncodingException e) { throw new RuntimeException("This method requires UTF-8 encoding support", e); } } return stringBuilder.toString(); }
From source file:com.github.khazrak.jdocker.utils.Filters.java
public static String encodeFilters(Map<String, String> filters) { ObjectMapper mapper = new ObjectMapper(); String result = null;/*from w w w . j a v a2 s . c om*/ ObjectNode objectNode = mapper.createObjectNode(); if (!filters.keySet().isEmpty()) { for (Map.Entry<String, String> s : filters.entrySet()) { objectNode.putObject(s.getKey()).put(s.getValue(), true); } } try { result = URLEncoder.encode(objectNode.toString(), StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.error("Error encoding filtersMap", e); } return result; }
From source file:com.nccgroup.burp.pcap.HttpReconstructor.java
public static void loadPcap(File pcapFile, StatusHandle statusHandle) throws PcapException { try {/*from w ww. j a v a2 s . c o m*/ // Reassemble the TCP streams. Map<TcpConnection, TcpReassembler> map = new PktsIoReconstructor(new PacketReassembler()) .reconstruct(pcapFile.getAbsolutePath(), statusHandle); // Parse the HTTP flows from the streams. HttpFlowParser httpParser = new HttpFlowParser(map); Map<TcpConnection, List<RecordedHttpFlow>> flows = httpParser.parse(statusHandle); // Count the total number of extracted flows. int flowcount = 0; for (TcpConnection key : flows.keySet()) { flowcount += flows.get(key).size(); } BurpExtender.callbacks.printOutput("Parsed " + flowcount + " total flows."); } catch (PcapException pce) { //These can propagate up the stack - all other exceptions are squashed below throw pce; } catch (Exception e) { if (log.isErrorEnabled()) { log.error("", e); } } }
From source file:com.kakao.rest.APIHttpRequestTask.java
public static void addQueryParam(final HttpRequestBuilder requestBuilder, final String propertiesKey, final Map properties) throws JSONException { JSONObject json = new JSONObject(); for (Object key : properties.keySet()) { json.put((String) key, properties.get(key)); }/*from w w w . j ava 2 s . com*/ requestBuilder.addQueryParameter(propertiesKey, json.toString()); }
From source file:com.technofovea.packbsp.packaging.BspZipController.java
public static void writePackingList(Map<String, File> packItems, Writer dest) throws IOException { final String newline = "\r\n"; List<String> keys = new ArrayList<String>(); keys.addAll(packItems.keySet()); Collections.sort(keys);/* ww w .j a va 2 s .co m*/ for (String inner : keys) { File outer = packItems.get(inner); dest.write(inner); dest.write(newline); dest.write(outer.getAbsolutePath()); dest.write(newline); } }