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:org.apache.openmeetings.cli.OmHelpFormatter.java

@Override
protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad) {
    final String dpad = createPadding(descPad);
    final String optional = "(optional) ";

    LinkedHashMap<String, List<OmOption>> optList = getOptions(options, leftPad);

    char[] delimiter = new char[width - 2];
    Arrays.fill(delimiter, '-');

    for (Entry<String, List<OmOption>> me : optList.entrySet()) {
        if (GENERAL_OPTION_GROUP.equals(me.getKey())) {
            sb.append("General options:").append(getNewLine());
        }//from w  w  w.  j av  a 2  s  .c  o m
        for (OmOption option : me.getValue()) {
            StringBuilder optBuf = new StringBuilder(option.getHelpPrefix());

            if (optBuf.length() < maxPrefixLength) {
                optBuf.append(createPadding(maxPrefixLength - optBuf.length()));
            }

            optBuf.append(dpad);

            int nextLineTabStop = maxPrefixLength + descPad;

            if (option.isOptional(me.getKey())) {
                optBuf.append(optional);
            }
            if (option.getDescription() != null) {
                optBuf.append(option.getDescription());
            }

            renderWrappedText(sb, width, nextLineTabStop, optBuf.toString());

            sb.append(getNewLine());
        }
        sb.append(delimiter).append(getNewLine());
    }
    return sb;
}

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

private double fitFunctionToData(LinkedHashMap<IPeak, HKL> peaks, boolean hasIntercept) {
    regression = new SimpleRegression(hasIntercept);
    if (hasIntercept) {
        regression.addData(0.0, 0.0);/*  w  w  w.ja v a 2s  . co  m*/
    }
    for (Entry<IPeak, HKL> peak : peaks.entrySet()) {
        double position = peak.getKey().getPosition();
        double qVal = 2.0 * Math.PI / peak.getValue().getD().doubleValue(unit);
        regression.addData(position, qVal);
    }
    regression.regress();

    gradient = Amount.valueOf(regression.getSlope(), regression.getSlopeStdErr(), unit.inverse())
            .divide(pixelSize)
            .to(unit.inverse().divide(pixelSize.getUnit()).asType(ScatteringVectorOverDistance.class));
    intercept = Amount.valueOf(regression.getIntercept(), regression.getInterceptStdErr(), unit.inverse())
            .to(unit.inverse().asType(ScatteringVector.class));
    //fitResult = new double [] {regression.getIntercept(), regression.getSlope()/pixelSize.doubleValue(SI.MILLIMETRE)};
    logger.info("Gradient: {},  Intercept: {}", gradient.doubleValue(unitGradient),
            intercept.doubleValue(unitIntercept));
    return regression.getSumSquaredErrors();
}

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

@SuppressWarnings("unused")
private Amount<Length> estimateCameraLength(LinkedHashMap<IPeak, HKL> indexedPeaks) {
    ArrayList<Double> cameraLen = new ArrayList<Double>();
    CombinationGenerator<Entry<IPeak, HKL>> combinations = new CombinationGenerator<Entry<IPeak, HKL>>(
            indexedPeaks.entrySet(), 2);
    for (List<Entry<IPeak, HKL>> comb : combinations) {
        Entry<IPeak, HKL> peak1 = comb.get(0);
        Entry<IPeak, HKL> peak2 = comb.get(1);
        //double q1 = regression.predict(peak1.getPosition());
        //double q2 = regression.predict(peak2.getPosition());
        Amount<ScatteringVector> q1 = Constants.two_.divide(peak1.getValue().getD())
                .to(ScatteringVector.UNIT);
        Amount<ScatteringVector> q2 = Constants.two_.divide(peak2.getValue().getD())
                .to(ScatteringVector.UNIT);
        Amount<Length> dist = pixelSize.times(peak2.getKey().getPosition() - peak1.getKey().getPosition())
                .times(Constants.two_).divide(wavelength.times(q2.minus(q1))).to(Length.UNIT);
        cameraLen.add(dist.doubleValue(SI.MILLIMETRE));
        //logger.info("Camera length from " + indexedPeaks.get(peak2).toString() + " and " + indexedPeaks.get(peak1).toString() + "is {} mm", dist);
    }/*from   www.j ava 2s  .  c  om*/
    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:com.qwazr.extractor.test.AllTest.java

/**
 * Check if the given string is present in a multivalued map
 *
 * @param map//from w w  w  . ja  v  a 2 s  .  com
 * @param text
 * @return
 */
protected boolean checkText(LinkedHashMap<String, ArrayList<Object>> map, String text) {
    if (map == null)
        return false;
    for (Map.Entry<String, ArrayList<Object>> entry : map.entrySet())
        for (Object object : entry.getValue())
            if (object.toString().contains(text))
                return true;
    return false;
}

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

private void writeHeaders(PrintWriter output) {
    LinkedHashMap<String, String> headers = new LinkedHashMap<String, String>();
    headers.put("User-Agent", USER_AGENT);
    headers.put("icy-notice1", USER_AGENT);

    for (Entry<String, String> entry : headers.entrySet()) {
        output.println(entry.getKey() + ": " + entry.getValue());
    }/*from   w w  w.  j a  v a2 s  . c  o m*/

    for (Entry<String, String> entry : streamInfos.entrySet()) {
        output.println(entry.getKey() + ": " + entry.getValue());
    }
}

From source file:com.fortify.bugtracker.common.tgt.processor.AbstractTargetProcessorUpdateIssuesWithTransitions.java

protected List<TransitionWithComment> getTransitions(Context context,
        TargetIssueLocatorAndFields targetIssueLocatorAndFields,
        LinkedHashMap<SimpleExpression, List<TransitionWithComment>> transitionsMap) {
    if (MapUtils.isNotEmpty(transitionsMap) && targetIssueLocatorAndFields.canRetrieveFields()) {
        for (Map.Entry<SimpleExpression, List<TransitionWithComment>> entry : transitionsMap.entrySet()) {
            if (ContextSpringExpressionUtil.evaluateExpression(context, targetIssueLocatorAndFields,
                    entry.getKey(), Boolean.class)) {
                return entry.getValue();
            }/*from   w  ww . ja v  a 2s.  c  om*/
        }
    }
    return null;
}

From source file:org.springframework.security.web.access.intercept.AnyframeReloadableDefaultFilterInvocationSecurityMetadataSource.java

/**
 * Builds the internal request map from the supplied map. The key elements should be of type {@link RequestKey},
 * which contains a URL path and an optional HTTP method (may be null). The path stored in the key will depend on
 * the type of the supplied UrlMatcher./*from  w  w w . j a v a  2  s.  c  o m*/
 *
 * @param urlMatcher typically an ant or regular expression matcher.
 * @param requestMap order-preserving map of request definitions to attribute lists
 */
public AnyframeReloadableDefaultFilterInvocationSecurityMetadataSource(UrlMatcher urlMatcher,
        LinkedHashMap<RequestKey, Collection<ConfigAttribute>> requestMap) {
    this.urlMatcher = urlMatcher;

    for (Map.Entry<RequestKey, Collection<ConfigAttribute>> entry : requestMap.entrySet()) {
        addSecureUrl(entry.getKey().getUrl(), entry.getKey().getMethod(), entry.getValue());
    }
}

From source file:org.waveprotocol.box.server.waveserver.SolrSearchProviderImpl.java

private LinkedHashMap<WaveId, WaveViewData> createResults(final ParticipantId user, final boolean isAllQuery,
        LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView) {
    Function<ReadableWaveletData, Boolean> matchesFunction = new Function<ReadableWaveletData, Boolean>() {

        @Override/*from   w w  w  . j av a 2s . c  o m*/
        public Boolean apply(ReadableWaveletData wavelet) {
            try {
                return isWaveletMatchesCriteria(wavelet, user, sharedDomainParticipantId, isAllQuery);
            } catch (WaveletStateException e) {
                LOG.warning("Failed to access wavelet "
                        + WaveletName.of(wavelet.getWaveId(), wavelet.getWaveletId()), e);
                return false;
            }
        }
    };

    LinkedHashMap<WaveId, WaveViewData> results = filterWavesViewBySearchCriteria(matchesFunction,
            currentUserWavesView);
    if (LOG.isFineLoggable()) {
        for (Map.Entry<WaveId, WaveViewData> e : results.entrySet()) {
            LOG.fine("filtered results contains: " + e.getKey());
        }
    }
    return results;
}

From source file:org.shw.process.SHWOrderLineInoutLineCreate.java

private void saveBrowseValues(PO po, String alias) {

    LinkedHashMap<String, Object> values = m_values.get(po.get_ID());

    for (Entry<String, Object> entry : values.entrySet()) {
        String columnName = entry.getKey();
        if (columnName.contains(alias.toUpperCase() + "_")) {
            columnName = columnName.substring(columnName.indexOf("_") + 1);
            po.set_ValueOfColumn(columnName, entry.getValue());
            po.saveEx();//from www .  j  a v  a  2s. c o  m
        }
    }
}

From source file:org.broadleafcommerce.common.resource.service.ResourceBundlingServiceImpl.java

protected String getBundleVersion(LinkedHashMap<String, Resource> foundResources) throws IOException {
    StringBuilder sb = new StringBuilder();
    for (Entry<String, Resource> entry : foundResources.entrySet()) {
        sb.append(entry.getKey());//from   w  w  w  . j av  a 2 s  .  c om

        if (entry.getValue() instanceof GeneratedResource) {
            sb.append(((GeneratedResource) entry.getValue()).getHashRepresentation());
        } else {
            sb.append(entry.getValue().lastModified());
        }

        sb.append("\r\n");
    }
    String version = String.valueOf(sb.toString().hashCode());
    return version;
}