List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:fr.zcraft.zlib.tools.mojang.UUIDFetcher.java
/** * Fetches the UUIDs of the given list of player names from the Mojang API. * * <p><b>WARNING: this method needs to be called from a dedicated thread, as the requests to * Mojang are executed directly in the current thread and, due to the Mojang API rate limit, the * thread may be frozen to wait a bit between requests if a lot of UUID are requested.</b></p> * * <p>You can use a {@link fr.zcraft.zlib.components.worker.Worker} to retrieve UUIDs.</p> * * This method may not be able to retrieve UUIDs for some players with old accounts. For them, * use {@link #fetchRemaining(Collection, Map)}. * * @param names A list of player names. * @param limitByRequest The maximal number of UUID to retrieve per request. * * @return A map linking a player name to his Mojang {@link UUID}. * @throws IOException If an exception occurs while contacting the Mojang API. * @throws InterruptedException If the thread is interrupted while sleeping when the system wait * because of the Mojang API rate limit. */// ww w .ja va 2 s . c om static public Map<String, UUID> fetch(List<String> names, int limitByRequest) throws IOException, InterruptedException { Map<String, UUID> UUIDs = new HashMap<>(); int requests = (names.size() / limitByRequest) + 1; List<String> tempNames; Map<String, UUID> tempUUIDs; for (int i = 0; i < requests; i++) { tempNames = names.subList(limitByRequest * i, Math.min((limitByRequest * (i + 1)) - 1, names.size())); tempUUIDs = rawFetch(tempNames); UUIDs.putAll(tempUUIDs); Thread.sleep(TIME_BETWEEN_REQUESTS); } return UUIDs; }
From source file:ips1ap101.lib.core.db.util.Reporter.java
private static Map getReportParametersMap(File file, String format, Long userid, String usercode, String username, Locale locale, Map parametros) { Map parameters = getReportParametersMap(file, format, userid, usercode, username, locale); if (parametros != null && !parametros.isEmpty()) { parameters.putAll(parametros); }/*w ww . ja v a 2 s . com*/ return parameters; }
From source file:edu.ualberta.med.biobank.reporting.DynamicJasperHelper.java
/** * For running queries embebed in the report design * /*from w w w .j ava 2 s. co m*/ * @param dr * @param layoutManager * @param con * @param _parameters * @return * @throws JRException */ public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, Connection con, Map _parameters) throws JRException { log.info("generating JasperPrint"); //$NON-NLS-1$ JasperPrint jp = null; if (_parameters == null) _parameters = new HashMap(); visitSubreports(dr, _parameters); compileOrLoadSubreports(dr, _parameters); DynamicJasperDesign jd = generateJasperDesign(dr); Map params = new HashMap(); if (!_parameters.isEmpty()) { registerParams(jd, _parameters); params.putAll(_parameters); } registerEntities(jd, dr, layoutManager); layoutManager.applyLayout(jd, dr); JRProperties.setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName()); JasperReport jr = JasperCompileManager.compileReport(jd); params.putAll(jd.getParametersWithValues()); jp = JasperFillManager.fillReport(jr, params, con); return jp; }
From source file:edu.ualberta.med.biobank.reporting.DynamicJasperHelper.java
/** * For compiling and filling reports whose datasource is passed as parameter * (e.g. Hibernate, Mondrean, etc.)/* w w w .ja v a 2 s .co m*/ * * @param dr * @param layoutManager * @param _parameters * @return * @throws JRException */ public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, Map _parameters) throws JRException { log.info("generating JasperPrint"); //$NON-NLS-1$ JasperPrint jp = null; if (_parameters == null) _parameters = new HashMap(); visitSubreports(dr, _parameters); compileOrLoadSubreports(dr, _parameters); DynamicJasperDesign jd = generateJasperDesign(dr); Map params = new HashMap(); if (!_parameters.isEmpty()) { registerParams(jd, _parameters); params.putAll(_parameters); } registerEntities(jd, dr, layoutManager); layoutManager.applyLayout(jd, dr); // JRProperties.setProperty(JRProperties.COMPILER_CLASS, // DJCompilerFactory.getCompilerClassName()); JRProperties.setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName()); JasperReport jr = JasperCompileManager.compileReport(jd); params.putAll(jd.getParametersWithValues()); jp = JasperFillManager.fillReport(jr, params); return jp; }
From source file:com.acciente.commons.htmlform.Parser.java
/** * This method parses all the parameters contained in the http servlet request, in particular it parses and * merges parameters from the sources listed below. If a parameter is defined in more than on source the higher * numbered source below prevails.// ww w . ja v a 2s.c o m * * 1 - parameters in the URL's query query string (GET params) * 2 - parameters submitted using POST including multi-part parameters such as fileuploads * * @param oRequest a http servlet request object * @param iStoreFileOnDiskThresholdInBytes a file size in bytes above which the uploaded file will be stored on disk * @param oUploadedFileStorageDir a File object representing a path to which the uploaded files should be saved, * if null is specified a temporary directory is created in the java system temp directory path * * @return a map containing the paramater names and values, the paramter names are keys in the map * * @throws ParserException thrown if there is an error parsing the parameter data * @throws IOException thrown if there is an I/O error * @throws FileUploadException thrown if there is an error processing the multi-part data */ public static Map parseForm(HttpServletRequest oRequest, int iStoreFileOnDiskThresholdInBytes, File oUploadedFileStorageDir) throws ParserException, IOException, FileUploadException { Map oGETParams = null; // first process the GET parameters (if any) if (oRequest.getQueryString() != null) { oGETParams = parseGETParams(oRequest); } Map oPOSTParams = null; // next process POST parameters if ("post".equals(oRequest.getMethod().toLowerCase())) { // check how the POST data has been encoded if (ServletFileUpload.isMultipartContent(oRequest)) { oPOSTParams = parsePOSTMultiPart(oRequest, iStoreFileOnDiskThresholdInBytes, oUploadedFileStorageDir); } else { // we have plain text oPOSTParams = parsePOSTParams(oRequest); } } Map oMergedParams; // merge the GET and POST parameters if (oGETParams != null) { oMergedParams = oGETParams; if (oPOSTParams != null) { oMergedParams.putAll(oPOSTParams); } } else { // we know that the oGETParams must be null oMergedParams = oPOSTParams; } return oMergedParams; }
From source file:com.hortonworks.registries.common.util.ReflectionHelper.java
/** * Given a class, this method returns a map of names of all the instance (non static) fields to type. * if the class has any super class it also includes those fields. * @param clazz , not null//ww w.j a v a 2s. co m * @return */ public static Map<String, Class> getFieldNamesToTypes(Class clazz) { Field[] declaredFields = clazz.getDeclaredFields(); Map<String, Class> instanceVariableNamesToTypes = new HashMap<>(); for (Field field : declaredFields) { if (!Modifier.isStatic(field.getModifiers())) { LOG.trace("clazz {} has field {} with type {}", clazz.getName(), field.getName(), field.getType().getName()); instanceVariableNamesToTypes.put(field.getName(), field.getType()); } else { LOG.trace("clazz {} has field {} with type {}, which is static so ignoring", clazz.getName(), field.getName(), field.getType().getName()); } } if (!clazz.getSuperclass().equals(Object.class)) { instanceVariableNamesToTypes.putAll(getFieldNamesToTypes(clazz.getSuperclass())); } return instanceVariableNamesToTypes; }
From source file:com.t3.model.AssetManager.java
/** * <p>/*ww w. j a v a 2s. c o m*/ * This method accepts the name of a repository (as it appears in the CampaignProperties) and updates it by adding * the additional mappings that are in <code>add</code>. * </p> * <p> * This method first retrieves the mapping from the AssetLoader. It then adds in the new assets. Last, it has to * create the new index file. The index file should be stored in the local repository cache. Note that this function * <b>does not</b> update the original (network storage) repository location. * </p> * <p> * If the calling function does not update the network storage for <b>index.gz</b>, a restart of TabletopTool will lose * the information when the index is downloaded again. * </p> * * @param repo * name of the repository to update * @param add * entries to add to the repository * @return the contents of the new repository in uploadable format */ public static byte[] updateRepositoryMap(String repo, Map<String, String> add) { Map<String, String> repoMap = assetLoader.getRepositoryMap(repo); repoMap.putAll(add); byte[] index = assetLoader.createIndexFile(repo); try { assetLoader.storeIndexFile(repo, index); } catch (IOException e) { log.error("Couldn't save updated index to local repository cache", e); e.printStackTrace(); } return index; }
From source file:com.siemens.sw360.importer.ComponentImportUtils.java
@NotNull public static Map<String, Release> getReleasesById(List<Component> componentDetailedSummaryForExport) { final Map<String, Release> releasesById = new HashMap<>(); for (Component component : componentDetailedSummaryForExport) { final List<Release> releases = component.getReleases(); if (releases != null && !releases.isEmpty()) { releasesById.putAll(ThriftUtils.getIdMap(releases)); }// w w w .j a v a2 s. c o m } return releasesById; }
From source file:com.bstek.dorado.common.event.ClientEventRegistry.java
private static void collectClientEventRegisterInfos(Map<String, ClientEventRegisterInfo> eventMap, Class<?> type) {//from ww w. ja va2s .c o m Class<?> superType = type.getSuperclass(); if (superType != null) { collectClientEventRegisterInfos(eventMap, superType); } Class<?>[] interfaces = type.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { Class<?> interfaceType = interfaces[i]; collectClientEventRegisterInfos(eventMap, interfaceType); } collectClientEventRegisterInfosFromSingleType(type); Map<String, ClientEventRegisterInfo> selfEventMap = typeMap.get(type); if (selfEventMap != null) { eventMap.putAll(selfEventMap); } }
From source file:com.siemens.sw360.importer.ComponentImportUtils.java
@NotNull public static Map<String, Release> getReleasesByIdentifier(List<Component> componentDetailedSummaryForExport) { final Map<String, Release> releasesByIdentifier = new HashMap<>(); for (Component component : componentDetailedSummaryForExport) { final List<Release> releases = component.getReleases(); if (releases != null && !releases.isEmpty()) { releasesByIdentifier.putAll(getMapEntryReleaseIdentifierToRelease(releases)); }//from w ww . j a v a2 s. c o m } return releasesByIdentifier; }