Example usage for com.google.common.collect Maps newTreeMap

List of usage examples for com.google.common.collect Maps newTreeMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newTreeMap.

Prototype

public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() 

Source Link

Document

Creates a mutable, empty TreeMap instance using the natural ordering of its elements.

Usage

From source file:elaborate.editor.config.Configuration.java

private static void processConfiguration(HierarchicalConfiguration h_config) {
    renditions = Maps.newTreeMap();
    HierarchicalConfiguration config = configurationAt(h_config, "renditions");
    if (config != null) {
        extractRenditions(config);// w  ww  .ja v a 2 s . co m
    }
    messages = Maps.newTreeMap();
    config = configurationAt(h_config, "messages");
    if (config != null) {
        int n = config.getMaxIndex("group");
        for (int i = 0; i <= n; i++) {
            String groupId = config.getString("group(" + i + ")[@id]");
            if (groupId != null) {
                HierarchicalConfiguration group = config.configurationAt("group(" + i + ")");
                extractMessages(groupId, group);
            }
        }
    }
}

From source file:org.eclipse.wb.internal.core.xml.model.description.AbstractDescription.java

/**
 * Sets the value of tag./*from ww w . java  2 s . co m*/
 */
public final void putTag(String tag, String value) {
    if (m_tags == null) {
        m_tags = Maps.newTreeMap();
    }
    m_tags.put(tag, value);
}

From source file:com.zimbra.doc.soap.apidesc.SoapApiDescription.java

public void build(Root soapApiDataModelRoot) {
    Map<String, SoapApiType> typesMap = Maps.newTreeMap();
    for (Command cmd : soapApiDataModelRoot.getAllCommands()) {
        addCommand(new SoapApiCommand(cmd));
        for (XmlElementDescription elemDesc : cmd.getAllElements()) {
            if (!elemDesc.isJaxbType()) {
                continue;
            }//from w  w  w  . ja  v a2  s .com
            Class<?> jaxbClass = elemDesc.getJaxbClass();
            if ((jaxbClass != null) && (!typesMap.containsKey(jaxbClass.getName()))) {
                typesMap.put(jaxbClass.getName(), new SoapApiType(elemDesc));
            }
            SoapApiType valueType = getJaxbSoapApiType(elemDesc.getValueType());
            if (valueType != null) {
                if ((!typesMap.containsKey(valueType.getClassName()))) {
                    typesMap.put(valueType.getClassName(), valueType);
                }
            }
            for (XmlAttributeDescription attr : elemDesc.getAttribs()) {
                valueType = getJaxbSoapApiType(attr.getValueDescription());
                if (valueType != null) {
                    if ((!typesMap.containsKey(valueType.getClassName()))) {
                        typesMap.put(valueType.getClassName(), valueType);
                    }
                }
            }
        }
    }
    types.addAll(typesMap.values());
    Collections.sort(commands);
}

From source file:linn.core.lang.production.RewriteProduction.java

@Override
public List<Production> execute(final LinnTurtle state, final ProductionParameter... parameters) {
    final List<Integer> ruleIds = this.linn.getRuleIds(this.ruleName);
    if (ruleIds.size() == 1) {
        final Integer ruleId = Iterables.getOnlyElement(ruleIds);
        // TODO check condition if any
        final List<Production> rewriteProductions = this.linn.getRuleProductions(ruleId);
        return rewriteProductions;
    } else if (ruleIds.size() > 1) {
        // TODO impl conditional case
        double totalRuleWeight = 0;
        // range for probability based on weight for all potential rules
        final TreeMap<Double, Integer> weightRangeOfRule = Maps.newTreeMap();
        for (final Integer ruleId : ruleIds) {
            final double ruleWeight = this.linn.getRuleWeight(ruleId);
            totalRuleWeight += ruleWeight;
            weightRangeOfRule.put(totalRuleWeight, ruleId);
        }//from  ww w.  j  a  va2s.c  o m
        // pick a random rule considering weights
        final double chosenRangeValue = LOCAL_RAND.nextDouble() * totalRuleWeight;
        final Entry<Double, Integer> chosenRuleEntry = weightRangeOfRule.ceilingEntry(chosenRangeValue);
        checkNotNull(chosenRuleEntry);
        final List<Production> rewriteProductions = this.linn.getRuleProductions(chosenRuleEntry.getValue());
        return rewriteProductions;
    }
    return null;
}

From source file:org.acz.mailsplat.MessageRepresentation.java

@JsonProperty
public Map<String, List<String>> getHeaders() {
    if (!full)//  w w w . ja v  a 2 s . c o m
        return null;
    try {
        Session session = Session.getDefaultInstance(new Properties());
        ByteArrayInputStream stream = new ByteArrayInputStream(message.getData().getBytes(Charsets.ISO_8859_1));
        MimeMessage message = new MimeMessage(session, stream);

        Map<String, List<String>> headers = Maps.newTreeMap();
        for (Enumeration e = message.getAllHeaders(); e.hasMoreElements();) {
            Header header = (Header) e.nextElement();
            if (!headers.containsKey(header.getName())) {
                headers.put(header.getName(), new ArrayList<String>());
            }
            headers.get(header.getName()).add(header.getValue());
        }
        return headers;
    } catch (Exception e) {
        return null;
    }
}

From source file:org.locationtech.geogig.porcelain.InitOp.java

/**
 * Constructs a new {@code InitOp} with the specified parameters.
 * /*  ww  w .j ava  2 s  .  c  om*/
 * @param platform where to get the current directory from
 * @param hints may contain where to get the repository from (using the
 *        {@link Hints#REPOSITORY_URL} argument)
 */
@Inject
public InitOp(Hints hints) {
    this.config = Maps.newTreeMap();
    this.hints = hints;
}

From source file:org.apache.bookkeeper.tests.integration.topologies.BKCluster.java

private BKCluster(BKClusterSpec spec) {
    this.spec = spec;
    this.clusterName = spec.clusterName();
    this.network = Network.newNetwork();
    this.metadataContainer = (MetadataStoreContainer) new ZKContainer(clusterName).withNetwork(network)
            .withNetworkAliases(ZKContainer.HOST_NAME);
    this.bookieContainers = Maps.newTreeMap();
    this.internalEndpointsToExternalEndpoints = Maps.newConcurrentMap();
    this.numBookies = spec.numBookies();
    this.extraServerComponents = spec.extraServerComponents();
    this.enableContainerLog = spec.enableContainerLog();
}

From source file:com.palantir.typescript.text.PresentationReconciler.java

public PresentationReconciler() {
    this.classifier = CLASSIFIER_SUPPLIER.get();
    this.classificationTextAttributes = createClassificationTextAttributes();
    this.listener = new MyTextListener();
    this.finalLexStates = Maps.newTreeMap();
}

From source file:org.sonar.server.technicaldebt.TechnicalDebtModelFinder.java

protected void findAvailableXMLFiles() {
    if (contributingPluginKeyToClassLoader == null) {
        contributingPluginKeyToClassLoader = Maps.newTreeMap();
        for (PluginMetadata metadata : pluginRepository.getMetadata()) {
            String pluginKey = metadata.getKey();
            ClassLoader classLoader = pluginRepository.getPlugin(pluginKey).getClass().getClassLoader();
            if (classLoader.getResource(getXMLFilePath(pluginKey)) != null) {
                contributingPluginKeyToClassLoader.put(pluginKey, classLoader);
            }/*from w w  w .  j  av a 2  s .  com*/
        }
        // Add default model
        contributingPluginKeyToClassLoader.put(DEFAULT_MODEL, getClass().getClassLoader());
    }
    contributingPluginKeyToClassLoader = Collections.unmodifiableMap(contributingPluginKeyToClassLoader);
}

From source file:com.opengamma.bbg.referencedata.cache.EHValueCachingReferenceDataProvider.java

@Override
protected Map<String, ReferenceData> loadFieldValues(Set<String> identifiers) {
    Map<String, ReferenceData> result = Maps.newTreeMap();
    FudgeSerializer serializer = new FudgeSerializer(getFudgeContext());
    for (String identifier : identifiers) {
        ReferenceData cachedResult = loadStateFromCache(serializer, identifier);
        if (cachedResult != null) {
            result.put(identifier, cachedResult);
        }//from   www . j a v a  2 s  .com
    }
    return result;
}