Example usage for java.util HashMap entrySet

List of usage examples for java.util HashMap entrySet

Introduction

In this page you can find the example usage for java.util HashMap entrySet.

Prototype

Set entrySet

To view the source code for java.util HashMap entrySet.

Click Source Link

Document

Holds cached entrySet().

Usage

From source file:com.github.reinert.jjschema.JsonSchemaGenerator.java

protected <T> void processProperties(Class<T> type, ObjectNode schema) throws TypeException {
    HashMap<Method, Field> props = findProperties(type);
    for (Map.Entry<Method, Field> entry : props.entrySet()) {
        Field field = entry.getValue();
        Method method = entry.getKey();
        ObjectNode prop = generatePropertySchema(type, method, field);
        if (prop != null && field != null) {
            addPropertyToSchema(schema, field, method, prop);
        }/*from w  w w  . j a v a 2 s . com*/
    }
}

From source file:io.personium.test.jersey.PersoniumRestAdapter.java

/**
 * ??? PUT.//from  www  .  ja  va2 s .c  om
 * @param url URL
 * @param data ??
 * @param headers ??
 * @return DcResponse
 * @throws PersoniumException DAO
 */
public final PersoniumResponse put(final String url, final String data, final HashMap<String, String> headers)
        throws PersoniumException {
    String contentType = headers.get(HttpHeaders.CONTENT_TYPE);
    HttpUriRequest req = makePutRequest(url, data, contentType);
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        req.setHeader(entry.getKey(), entry.getValue());
    }
    req.addHeader("X-Personium-Version", PersoniumCoreTestConfig.getCoreVersion());

    debugHttpRequest(req, data);
    PersoniumResponse res = request(req);
    return res;
}

From source file:io.personium.test.jersey.PersoniumRestAdapter.java

/**
 * ??? POST.//from w ww.  j  a v  a 2s  .c  om
 * @param url URL
 * @param data ??
 * @param headers ??
 * @return DcResponse
 * @throws PersoniumException DAO
 */
public final PersoniumResponse post(final String url, final String data, final HashMap<String, String> headers)
        throws PersoniumException {
    String contentType = headers.get(HttpHeaders.CONTENT_TYPE);
    HttpUriRequest req = makePostRequest(url, data, contentType);
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        req.setHeader(entry.getKey(), entry.getValue());
    }
    req.addHeader("X-Personium-Version", PersoniumCoreTestConfig.getCoreVersion());

    debugHttpRequest(req, data);
    PersoniumResponse res = request(req);
    return res;
}

From source file:com.epam.catgenome.manager.protein.ProteinSequenceManager.java

private Map<Gene, List<List<ProteinSequenceEntry>>> loadProteinSequencesByVarCds(
        HashMap<Gene, List<Gene>> mrnaToVarCdsMap, Map<Gene, List<List<Sequence>>> cdsToNucleotidesMap,
        long referenceId, Track<Gene> geneTrack, Chromosome chromosome) throws GeneReadingException {
    Map<Gene, List<List<ProteinSequenceEntry>>> mrnaToAminoAcidsMap = new HashMap<>();
    for (Map.Entry<Gene, List<Gene>> mrnaToVarCdsEntry : mrnaToVarCdsMap.entrySet()) {
        // Load protein sequences.
        try {//from  w w  w .j  a  v  a 2  s.co  m
            reconstructProteinSequenceVariants(referenceId, geneTrack, chromosome, cdsToNucleotidesMap,
                    mrnaToAminoAcidsMap, mrnaToVarCdsEntry.getKey(), mrnaToVarCdsEntry.getValue());
        } catch (IOException e) {
            throw new GeneReadingException(geneTrack, e);
        }
    }

    return mrnaToAminoAcidsMap;
}

From source file:com.supernovapps.audio.jstreamsourcer.Icecast.java

public HttpUriRequest getUpdateMetadataRequest(String song, String artist, String album) {
    if (!started) {
        return null;
    }//from  w  w w. ja v  a2 s .  c o m

    String metadata = metadataTemplate.replace("_song_", song).replace("_artist_", artist).replace("_album_",
            album);

    MetaDataHttpRequestParams params = new MetaDataHttpRequestParams();
    params.put("mode", "updinfo");
    params.put("mount", path);
    params.put("charset", "UTF-8");
    params.put("song", metadata);

    String authString = username + ":" + password;
    String token = Base64.encodeBase64String(authString.getBytes());

    HashMap<String, String> headers = new HashMap<String, String>();
    headers.put("Authorization:", "Basic " + token);
    headers.put("User-Agent", USER_AGENT);

    HttpUriRequest request = new HttpGet(MetaDataHttpRequestParams.getUrlWithQueryString(
            "http://" + host + ":" + Integer.toString(port) + "/admin/metadata", params));
    if (headers != null) {
        for (Map.Entry<String, String> entry : headers.entrySet()) {
            request.addHeader(entry.getKey(), entry.getValue());
        }
    }

    return request;
}

From source file:com.esri.geoportal.commons.ags.client.AgsClient.java

/**
 * Generates token.//from ww w .  ja  v  a  2s .  c  o m
 *
 * @param minutes expiration in minutes.
 * @param credentials credentials.
 * @return token response
 * @throws URISyntaxException if invalid URL
 * @throws IOException if accessing token fails
 */
public TokenResponse generateToken(int minutes, SimpleCredentials credentials)
        throws URISyntaxException, IOException {
    HttpPost post = new HttpPost(rootUrl.toURI().resolve("tokens/generateToken"));
    HashMap<String, String> params = new HashMap<>();
    params.put("f", "json");
    if (credentials != null) {
        params.put("username", StringUtils.trimToEmpty(credentials.getUserName()));
        params.put("password", StringUtils.trimToEmpty(credentials.getPassword()));
    }
    params.put("client", "ip");
    params.put("ip", InetAddress.getLocalHost().getHostAddress());
    params.put("expiration", Integer.toString(minutes));
    HttpEntity entity = new UrlEncodedFormEntity(params.entrySet().stream()
            .map(e -> new BasicNameValuePair(e.getKey(), e.getValue())).collect(Collectors.toList()));
    post.setEntity(entity);

    try (CloseableHttpResponse httpResponse = httpClient.execute(post);
            InputStream contentStream = httpResponse.getEntity().getContent();) {
        if (httpResponse.getStatusLine().getStatusCode() >= 400) {
            throw new HttpResponseException(httpResponse.getStatusLine().getStatusCode(),
                    httpResponse.getStatusLine().getReasonPhrase());
        }
        String responseContent = IOUtils.toString(contentStream, "UTF-8");
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper.readValue(responseContent, TokenResponse.class);
    }
}

From source file:au.org.ands.vocabs.toolkit.provider.transform.SesameTransformUtils.java

/** Run a SPARQL Update on a repository.
 * @param taskInfo The TaskInfo object describing the entire task.
 * @param subtask The specification of this transform subtask
 * @param results HashMap representing the result of the transform.
 * @param updateString The text of the SPARQL Update to run.
 * @param bindings Any bindings that are to be applied. Keys are
 * variable names (without leading "?"); values are the corresponding
 * values to be bound.//from   ww w . ja v a 2  s .c  om
 * @return True, iff the update succeeded.
*/
public static boolean runUpdate(final TaskInfo taskInfo, final JsonNode subtask,
        final HashMap<String, String> results, final String updateString,
        final HashMap<String, Value> bindings) {
    RepositoryManager manager = null;
    // First, open the repository
    Repository repository;
    try {
        manager = RepositoryProvider.getRepositoryManager(sesameServer);

        String repositoryID = ToolkitFileUtils.getSesameRepositoryId(taskInfo);

        repository = manager.getRepository(repositoryID);
        if (repository == null) {
            LOGGER.error("SesameTransformUtils.runUpdate(): " + "no such repository: " + repositoryID);
            TaskUtils.updateMessageAndTaskStatus(LOGGER, taskInfo.getTask(), results, TaskStatus.ERROR,
                    "SesameTransformUtils.runUpdate(): no such repository: " + repositoryID);
            return false;
        }
    } catch (RepositoryConfigException | RepositoryException e) {
        LOGGER.error("Exception in SesameTransformUtils.runUpdate() " + "opening repository", e);
        TaskUtils.updateMessageAndTaskStatus(LOGGER, taskInfo.getTask(), results, TaskStatus.EXCEPTION,
                "Exception in SesameTransformUtils.runUpdate() " + "opening repository");
        return false;
    }
    // Now, open a connection and process the update
    try {
        RepositoryConnection conn = null;
        try {
            conn = repository.getConnection();
            Update update = conn.prepareUpdate(QueryLanguage.SPARQL, updateString);
            for (Entry<String, Value> binding : bindings.entrySet()) {
                update.setBinding(binding.getKey(), binding.getValue());
            }
            update.execute();
        } catch (MalformedQueryException e) {
            LOGGER.error("Bad update passed to " + "SesameTransformUtils.runUpdate(): " + updateString, e);
            TaskUtils.updateMessageAndTaskStatus(LOGGER, taskInfo.getTask(), results, TaskStatus.EXCEPTION,
                    "Bad update passed to " + "SesameTransformUtils.runUpdate(): " + updateString);
            return false;
        } catch (UpdateExecutionException e) {
            LOGGER.error("SesameTransformUtils.runUpdate() update failed: " + updateString, e);
            TaskUtils.updateMessageAndTaskStatus(LOGGER, taskInfo.getTask(), results, TaskStatus.EXCEPTION,
                    "SesameTransformUtils.runUpdate() update failed: " + updateString);
            return false;
        } finally {
            if (conn != null) {
                conn.close();
            }
        }
    } catch (RepositoryException e) {
        LOGGER.error("Exception in SesameTransformUtils.runUpdate() with " + "connection handling", e);
        TaskUtils.updateMessageAndTaskStatus(LOGGER, taskInfo.getTask(), results, TaskStatus.EXCEPTION,
                "Exception in SesameTransformUtils.runUpdate() with " + "connection handling");
        return false;
    }
    return true;
}

From source file:com.fujitsu.dc.test.jersey.DcRestAdapter.java

/**
 * Stream?PUT./*from  w  ww  .j  a  va  2  s. co  m*/
 * @param url PUT?URL
 * @param headers ??
 * @param is PUT?
 * @return DcResponse
 * @throws DcException DAO
 */
public final DcResponse put(final String url, final HashMap<String, String> headers, final InputStream is)
        throws DcException {
    String contentType = headers.get(HttpHeaders.CONTENT_TYPE);
    HttpUriRequest req = makePutRequestByStream(url, contentType, is);
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        req.setHeader(entry.getKey(), entry.getValue());
    }
    req.addHeader("X-Dc-Version", DcCoreTestConfig.getCoreVersion());

    debugHttpRequest(req, "body is InputStream...");
    DcResponse res = request(req);
    return res;
}

From source file:com.aurel.track.move.ItemMoveBL.java

/************************************ BRYNTUM CASCADE ************************************/
public static void saveChangedItems(HashSet<Integer> projectIDs,
        HashMap<Integer, GanttTaskBean> workItemIDToTaskStore, TPersonBean pers, Locale loc) {
    FilterUpperTO filterUpperTO = new FilterUpperTO();
    filterUpperTO.setSelectedProjects(GeneralUtils.createIntegerArrFromCollection(projectIDs));
    List<TWorkItemBean> workItemBeans = null;
    try {//from w  w w  . j  a  va 2 s.c o m
        workItemBeans = LoadTreeFilterItems.getTreeFilterWorkItemBeans(filterUpperTO, pers, loc, false);
        if (!workItemBeans.isEmpty()) {
            HashMap<Integer, TWorkItemBean> workItemIDToWorkItemBean = createWorkItemIDToWorkitemBeanMap(
                    workItemBeans);
            for (Map.Entry<Integer, GanttTaskBean> entry : workItemIDToTaskStore.entrySet()) {
                TWorkItemBean workItemBeanToChange = workItemIDToWorkItemBean.get(entry.getKey());
                if (workItemBeanToChange != null) {
                    if (entry.getValue().getStartDate() != null && entry.getValue().getEndDate() != null) {
                        setStartDate(workItemBeanToChange, entry.getValue().getStartDate());
                        setEndDate(workItemBeanToChange, entry.getValue().getEndDate());
                    }
                    try {
                        LOGGER.debug("Saving work item after cascade: " + workItemBeanToChange.getObjectID());
                        workItemDAO.saveSimple(workItemBeanToChange);
                    } catch (ItemPersisterException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    } catch (TooManyItemsToLoadException ex) {
        ex.printStackTrace();
    }
}

From source file:com.yahoo.ycsb.db.AsyncHBaseClient.java

/**
 * Update a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified
 * record key, overwriting any existing values with the same field name.
 *
 * @param table  The name of the table//  www. j  a  v  a2s .  c  o m
 * @param key    The record key of the record to write
 * @param values A HashMap of field/value pairs to update in the record
 * @return Zero on success, a non-zero error code on error
 */
public int update(String table, String key, HashMap<String, ByteIterator> values) {

    if (_debug) {
        System.out.println("Setting up put for key: " + key);
    }
    byte[][] qualifiers = new byte[values.size()][];
    byte[][] valuesArr = new byte[values.size()][];
    int idx = 0;
    for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
        final byte[] keyBytes = entry.getKey().getBytes(UTF8);
        final byte[] valueBytes = entry.getValue().toArray().clone();
        if (_debug) {
            System.out.println("Adding field/value " + Bytes.pretty(keyBytes) + "/" + Bytes.pretty(valueBytes)
                    + " to put request");
        }
        qualifiers[idx] = keyBytes;
        valuesArr[idx] = valueBytes;
        idx++;
    }
    final PutRequest put = new PutRequest(table.getBytes(UTF8), key.getBytes(UTF8), _columnFamilyBytes,
            qualifiers, valuesArr);
    put.setBufferable(_buffered);
    put.setDurable(_durable);
    final Deferred<Object> d = _client.put(put).addErrback(errback);
    if (_failed) {
        return ServerError;
    }
    tryThrottle(d);
    return Ok;
}