Example usage for java.util LinkedHashMap entrySet

List of usage examples for java.util LinkedHashMap entrySet

Introduction

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

Prototype

public Set<Map.Entry<K, V>> entrySet() 

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:by.stub.yaml.YamlParser.java

@SuppressWarnings("unchecked")
protected void mapHttpSettingsToPojo(final Object target, final LinkedHashMap<String, Object> httpProperties)
        throws Exception {

    for (final Map.Entry<String, Object> pair : httpProperties.entrySet()) {

        final Object value = pair.getValue();
        final String propertyName = pair.getKey();

        if (value instanceof Map) {
            final Map<String, String> keyValues = encodeAuthorizationHeader((Map<String, String>) value);
            ReflectionUtils.setPropertyValue(target, propertyName, keyValues);
            continue;
        }//from   www. ja  va2s.c  o  m

        final String propertyValue = extractPropertyValueAsString(propertyName, value);
        ReflectionUtils.setPropertyValue(target, propertyName, propertyValue);
    }
}

From source file:jp.aegif.nemaki.cmis.factory.info.AclCapabilities.java

private void customizeTable(NemakiPermissionDefinition custom, LinkedHashMap<String, PermissionMapping> table) {
    for (Entry<String, PermissionMapping> entry : table.entrySet()) {
        String k = entry.getKey();
        PermissionMapping pm = entry.getValue();

        //Add where base exists
        if (CollectionUtils.isNotEmpty(custom.getBase())) {
            //Check if any base is contained
            boolean baseContained = false;
            for (String base : custom.getBase()) {
                if (pm.getPermissions().contains(base)) {
                    baseContained = true;
                    break;
                }/* www . j  av  a 2  s  .  c o m*/
            }

            //Check mapped flag
            Boolean mapped = custom.getPermissionMapping().get(k);
            //Default to true
            if (custom.getPermissionMapping().containsKey(k) && mapped == null) {
                mapped = true;
            }

            //Customize table
            if (Boolean.TRUE == mapped || ((mapped == null) && baseContained)) {
                //Add without duplicate
                boolean duplicate = pm.getPermissions().contains(custom.getId());
                if (!duplicate) {
                    List<String> permissions = new ArrayList<String>(pm.getPermissions());
                    permissions.add(custom.getId());

                    PermissionMappingDataImpl pmdi = new PermissionMappingDataImpl();
                    pmdi.setKey(k);
                    pmdi.setPermissions(permissions);

                    table.put(k, pmdi);
                }
            }
        }

    }
}

From source file:com.zhumeng.dream.orm.hibernate.HibernateDao.java

/**
 * order by? :order by o.email desc , o.username asc
 * @author: lizhong/*ww  w .ja v  a 2  s.c  o  m*/
 * @param orderBy key , valuedesc/asc.:
 * orderBy.put("email", "desc");
 * orderBy.put("username", "asc");
 * ?sql?order by o.email desc,o.username asc
 * @return
 */

public static String buildOrderby(LinkedHashMap<String, String> orderBy) {
    StringBuilder order = new StringBuilder();
    if (orderBy != null && orderBy.size() > 0) {
        order.append(" order by ");
        for (Entry<String, String> entry : orderBy.entrySet()) {
            order.append(" o.").append(entry.getKey()).append(" ").append(entry.getValue()).append(",");
        }
        order.deleteCharAt(order.length() - 1);
    }
    return order.toString();
}

From source file:uk.ac.diamond.scisoft.ncd.calibration.CalibrationMethods.java

private Amount<Length> estimateCameraLengthSingle(LinkedHashMap<IPeak, HKL> indexedPeaks) {
    ArrayList<Double> cameraLen = new ArrayList<Double>();
    for (Entry<IPeak, HKL> peak : indexedPeaks.entrySet()) {
        double peakPos = peak.getKey().getPosition();
        Amount<ScatteringVector> q = Amount.valueOf(regression.predict(peakPos), unit.inverse())
                .to(ScatteringVector.UNIT);
        Amount<Length> dist = pixelSize.times(peakPos).times(Constants.two_).divide(wavelength.times(q))
                .to(Length.UNIT);/*from   w w  w.  j  a va2  s . c  o  m*/
        cameraLen.add(dist.doubleValue(SI.MILLIMETRE));
    }
    double[] cameraLenArray = ArrayUtils.toPrimitive(cameraLen.toArray(new Double[] {}));
    double mcl = StatUtils.mean(cameraLenArray);
    double std = Math.sqrt(StatUtils.variance(cameraLenArray));
    meanCameraLength = Amount.valueOf(mcl, std, SI.MILLIMETRE);

    logger.info("Camera length: {}", meanCameraLength.to(SI.METRE));
    return meanCameraLength;
}

From source file:net.gplatform.spring.social.weibo.connect.WeiboOAuth2Template.java

@Override
protected RestTemplate createRestTemplate() {
    RestTemplate restTemplate = new RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory());
    HttpMessageConverter<?> messageConverter = new FormHttpMessageConverter() {

        private final ObjectMapper objectMapper = new ObjectMapper();

        @Override//from ww  w.  j  av  a2  s  .  c  o m
        public boolean canRead(Class<?> clazz, MediaType mediaType) {
            return true;
        }

        @Override
        public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz,
                HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {

            TypeReference<Map<String, ?>> mapType = new TypeReference<Map<String, ?>>() {
            };
            LinkedHashMap<String, ?> readValue = objectMapper.readValue(inputMessage.getBody(), mapType);
            LinkedMultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>();
            for (Entry<String, ?> currentEntry : readValue.entrySet()) {
                result.add(currentEntry.getKey(), currentEntry.getValue().toString());
            }
            return result;
        }
    };

    restTemplate.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(messageConverter));
    return restTemplate;
}

From source file:com.vmware.bdd.cli.commands.CommandsUtils.java

public static void printInTableFormat(LinkedHashMap<String, List<String>> columnNamesWithKeys,
        List<Map> entities, String spacesBeforeStart) throws Exception {
    if (MapUtils.isNotEmpty(columnNamesWithKeys)) {
        int columnNum = columnNamesWithKeys.size();

        if (CollectionUtils.isNotEmpty(entities)) {
            String[][] table = new String[entities.size() + 1][columnNum];

            //build table header: column names
            String[] tableHeader = table[0];

            int rowIndex = 1;
            int columnIndex = 0;
            for (Map<String, String> entity : entities) {
                for (Entry<String, List<String>> columnNameEntry : columnNamesWithKeys.entrySet()) {
                    if (tableHeader[columnIndex] == null) {
                        tableHeader[columnIndex] = columnNameEntry.getKey();
                    }//from w  w  w. j  a  v  a 2s  .c o  m

                    StringBuilder value = new StringBuilder();
                    for (String key : columnNameEntry.getValue()) {
                        if (value.length() > 0) {
                            value.append(',');
                        }

                        Object valueObj = entity.get(key);

                        if (valueObj == null) {
                            value.append(' ');
                        } else {
                            if (valueObj instanceof Double) {
                                value.append(String.valueOf(
                                        round(((Double) valueObj).doubleValue(), 2, BigDecimal.ROUND_FLOOR)));
                            } else {
                                value.append(valueObj);
                            }
                        }
                    }

                    if (isJansiAvailable()) {
                        table[rowIndex][columnIndex] = transferEncoding(value.toString());
                    } else {
                        table[rowIndex][columnIndex] = value.toString();
                    }
                    columnIndex++;
                }
                rowIndex++;
            }

            printTable(table, spacesBeforeStart);
        }
    }
}

From source file:org.romaframework.aspect.view.form.FormViewer.java

public void sync(Screen iScreen) {
    LinkedHashMap<String, Object> queuedForms = (LinkedHashMap<String, Object>) Roma.session()
            .getProperty("formQueue");
    if (queuedForms != null) {
        for (Map.Entry<String, Object> entry : queuedForms.entrySet()) {
            Roma.view().show(entry.getValue(), entry.getKey(), iScreen, null);
        }/*  w  w w. j a  v  a2s . com*/
        queuedForms.clear();
        Roma.session().setProperty("formQueue", null);
    }
}

From source file:gaffer.data.elementdefinition.view.ViewElementDefinition.java

/**
 * Set the transient properties.//from  w ww  .  ja va  2s.  c  om
 *
 * @param newTransientProperties {@link LinkedHashMap} of transient property name to class name.
 * @throws ClassNotFoundException thrown if any of the property class names could not be found.
 */
@JsonSetter("transientProperties")
public void setTransientPropertyMapWithClassNames(final LinkedHashMap<String, String> newTransientProperties)
        throws ClassNotFoundException {
    transientProperties = new LinkedHashMap<>();
    for (Entry<String, String> entry : newTransientProperties.entrySet()) {
        transientProperties.put(entry.getKey(), Class.forName(entry.getValue()));
    }
}

From source file:com.espertech.esper.pattern.EvalEveryDistinctStateExpireKeyNode.java

public final void evaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, boolean isQuitted) {
    // determine if this evaluation has been seen before from the same node
    Object matchEventKey = PatternExpressionUtil.getKeys(matchEvent, everyNode);
    boolean haveSeenThis = false;
    LinkedHashMap<Object, Long> keysFromNode = spawnedNodes.get(fromNode);
    if (keysFromNode != null) {
        // Clean out old keys
        Iterator<Map.Entry<Object, Long>> it = keysFromNode.entrySet().iterator();
        long currentTime = everyNode.getContext().getPatternContext().getTimeProvider().getTime();
        for (; it.hasNext();) {
            Map.Entry<Object, Long> entry = it.next();
            if (currentTime - entry.getValue() >= everyNode.getFactoryNode().getMsecToExpire()) {
                it.remove();//from   w w w. j  a v  a 2  s.  co  m
            } else {
                break;
            }
        }

        if (keysFromNode.containsKey(matchEventKey)) {
            haveSeenThis = true;
        } else {
            keysFromNode.put(matchEventKey, currentTime);
        }
    }

    if (isQuitted) {
        spawnedNodes.remove(fromNode);
    }

    // See explanation in EvalFilterStateNode for the type check
    if (fromNode.isFilterStateNode()) {
        // We do not need to newState new listeners here, since the filter state node below this node did not quit
    } else {
        // Spawn all nodes below this EVERY node
        // During the start of a child we need to use the temporary evaluator to catch any event created during a start
        // Such events can be raised when the "not" operator is used.
        EvalEveryStateSpawnEvaluator spawnEvaluator = new EvalEveryStateSpawnEvaluator(
                everyNode.getContext().getPatternContext().getStatementName());
        EvalStateNode spawned = everyNode.getChildNode().newState(spawnEvaluator, null, 0L);
        spawned.start(beginState);

        // If the whole spawned expression already turned true, quit it again
        if (spawnEvaluator.isEvaluatedTrue()) {
            spawned.quit();
        } else {
            LinkedHashMap<Object, Long> keyset = new LinkedHashMap<Object, Long>();
            if (keysFromNode != null) {
                keyset.putAll(keysFromNode);
            }
            spawnedNodes.put(spawned, keyset);
            spawned.setParentEvaluator(this);
        }
    }

    if (!haveSeenThis) {
        this.getParentEvaluator().evaluateTrue(matchEvent, this, false);
    }
}

From source file:org.springside.modules.security.springsecurity.DefinitionSourceFactoryBean.java

/**
 * resourceDetailService??LinkedHashMap<String, String>?URL??
 * DefaultFilterInvocationDefinitionSource?LinkedHashMap<RequestKey, ConfigAttributeDefinition>?.
 *//* w w  w.  j  a  v a  2  s.co m*/
protected LinkedHashMap<RequestKey, ConfigAttributeDefinition> buildRequestMap() throws Exception {
    LinkedHashMap<String, String> srcMap = resourceDetailsService.getRequestMap();
    LinkedHashMap<RequestKey, ConfigAttributeDefinition> distMap = new LinkedHashMap<RequestKey, ConfigAttributeDefinition>();
    ConfigAttributeEditor editor = new ConfigAttributeEditor();

    for (Map.Entry<String, String> entry : srcMap.entrySet()) {
        RequestKey key = new RequestKey(entry.getKey(), null);
        if (StringUtils.isNotBlank(entry.getValue())) {
            editor.setAsText(entry.getValue());
            distMap.put(key, (ConfigAttributeDefinition) editor.getValue());
        } else {
            distMap.put(key, ConfigAttributeDefinition.NO_ATTRIBUTES);
        }
    }

    return distMap;
}