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:edu.udo.scaffoldhunter.plugins.dataimport.impl.sql.SQLImportPluginResults.java

/**
 * @param arguments/*from w  w  w. ja  v  a  2  s . c o  m*/
 * 
 */
public SQLImportPluginResults(SQLImportPluginArguments arguments) {
    this.arguments = arguments;
    probablyNumeric = Sets.newHashSet();
    sourceProperties = Maps.newTreeMap();
    Properties connProps = new Properties();
    connProps.put("user", arguments.getUser());
    connProps.put("password", arguments.getPass());
    try {
        this.connection = DriverManager.getConnection(arguments.getUrl(), connProps);

        numMolecules = 0;
        Statement statement = connection.createStatement();
        ResultSet result = statement.executeQuery(arguments.getSelectClause());
        ResultSetMetaData meta = result.getMetaData();
        for (int i = 1; i <= meta.getColumnCount(); i++) {
            if (meta.getColumnType(i) == java.sql.Types.INTEGER
                    || meta.getColumnType(i) == java.sql.Types.DOUBLE) {
                probablyNumeric.add(meta.getColumnName(i));
            }
            sourceProperties.put(meta.getColumnName(i), null);
        }
        while (result.next()) {
            numMolecules++;
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        numMolecules = 0;
    }
}

From source file:org.apache.tephra.snapshot.SnapshotCodecV2.java

@Override
protected NavigableMap<Long, TransactionManager.InProgressTx> decodeInProgress(BinaryDecoder decoder)
        throws IOException {

    int size = decoder.readInt();
    NavigableMap<Long, TransactionManager.InProgressTx> inProgress = Maps.newTreeMap();
    while (size != 0) { // zero denotes end of list as per AVRO spec
        for (int remaining = size; remaining > 0; --remaining) {
            long txId = decoder.readLong();
            long expiration = decoder.readLong();
            long visibilityUpperBound = decoder.readLong();
            int txTypeIdx = decoder.readInt();
            TransactionManager.InProgressType txType;
            try {
                txType = TransactionManager.InProgressType.values()[txTypeIdx];
            } catch (ArrayIndexOutOfBoundsException e) {
                throw new IOException("Type enum ordinal value is out of range: " + txTypeIdx);
            }/*from  www.j  a v  a2s  .  c  o  m*/
            inProgress.put(txId, new TransactionManager.InProgressTx(visibilityUpperBound, expiration, txType,
                    new LongArrayList()));
        }
        size = decoder.readInt();
    }
    return inProgress;
}

From source file:com.google.gerrit.server.change.ListDrafts.java

@Override
public Object apply(RevisionResource rsrc)
        throws AuthException, BadRequestException, ResourceConflictException, Exception {
    Map<String, List<CommentInfo>> out = Maps.newTreeMap();
    AccountInfo.Loader accountLoader = includeAuthorInfo() ? accountLoaderFactory.create(true) : null;
    for (PatchLineComment c : listComments(rsrc)) {
        CommentInfo o = new CommentInfo(c, accountLoader);
        List<CommentInfo> list = out.get(o.path);
        if (list == null) {
            list = Lists.newArrayList();
            out.put(o.path, list);/*from  w ww  .  j  a v  a 2 s.  c  om*/
        }
        o.path = null;
        list.add(o);
    }
    for (List<CommentInfo> list : out.values()) {
        Collections.sort(list, new Comparator<CommentInfo>() {
            @Override
            public int compare(CommentInfo a, CommentInfo b) {
                int c = firstNonNull(a.side, Side.REVISION).ordinal()
                        - firstNonNull(b.side, Side.REVISION).ordinal();
                if (c == 0) {
                    c = firstNonNull(a.line, 0) - firstNonNull(b.line, 0);
                }
                if (c == 0) {
                    c = a.id.compareTo(b.id);
                }
                return c;
            }
        });
    }
    if (accountLoader != null) {
        accountLoader.fill();
    }
    return out;
}

From source file:com.davidbracewell.cli.CommandLineParser.java

/**
 * Default Constructor/*from   w w  w. jav  a  2s  .co m*/
 */
public CommandLineParser() {
    this.knownArguments = Maps.newTreeMap();
    this.helpDescriptions = Maps.newHashMap();
    this.aliases = Maps.newHashMap();
    this.setOptionMap = Maps.newConcurrentMap();
    addOption(CommandLineOption.HELP);
    addOption(CommandLineOption.CONFIG);
    addOption(CommandLineOption.CONFIG_EXPLAIN);
}

From source file:org.eclipse.wb.internal.swing.model.layout.gbl.GridBagConstraintsNameSupport.java

@Override
protected Map<String, String> getValueMap() {
    // prepare variables
    Map<String, String> valueMap = Maps.newTreeMap();
    {/*from w  w w .j  av a 2s  .com*/
        valueMap.put("constraintsAcronym", getAcronym());
        valueMap.put("constraintsClassName", getClassName());
        valueMap.put("componentName", getParentName());
        valueMap.put("componentName-cap", getParentNameCap());
    }
    return valueMap;
}

From source file:com.trilemon.boss.infra.base.util.TopApiUtils.java

/**
 * session key//from w w w.  j a  v  a2  s  . co  m
 *
 *
 * @param appKey       app key
 * @param appSecret    app secret
 * @param sessionKey   session key
 * @param refreshToken refresh token
 * @return {@link TaobaoSession}
 * @throws java.io.IOException ?{@link TaobaoSession}?
 */
public static TaobaoSession refreshSessionKey(String appKey, String appSecret, String sessionKey,
        String refreshToken) throws IOException {
    Map<String, String> signParams = Maps.newTreeMap();
    signParams.put("appkey", appKey);
    signParams.put("refresh_token", refreshToken);
    signParams.put("sessionkey", sessionKey);

    StringBuilder params = new StringBuilder();
    for (Map.Entry paramEntry : signParams.entrySet()) {
        params.append(paramEntry.getKey()).append(paramEntry.getValue());
    }
    String sign = DigestUtils.md5Hex((params.toString() + appSecret).getBytes("utf-8")).toUpperCase();
    String signEncoder = URLEncoder.encode(sign, "utf-8");
    String appkeyEncoder = URLEncoder.encode(appKey, "utf-8");
    String refreshTokenEncoder = URLEncoder.encode(refreshToken, "utf-8");
    String sessionKeyEncoder = URLEncoder.encode(sessionKey, "utf-8");

    String freshUrl = "http://container.api.taobao.com/container/refresh?appkey=" + appkeyEncoder
            + "&refresh_token=" + refreshTokenEncoder + "&sessionkey=" + sessionKeyEncoder + "&sign="
            + signEncoder;
    String topParametersJson = WebUtils.doPost(freshUrl, null, "utf-8", 30 * 1000 * 60, 30 * 1000 * 60);

    TaobaoSession taobaoSession = JsonMapper.nonEmptyMapper().fromJson(topParametersJson, TaobaoSession.class);
    return taobaoSession;
}

From source file:org.apache.bookkeeper.mledger.offload.jcloud.impl.OffloadIndexBlockImpl.java

public static OffloadIndexBlockImpl get(LedgerMetadata metadata, long dataObjectLength, long dataHeaderLength,
        List<OffloadIndexEntryImpl> entries) {
    OffloadIndexBlockImpl block = RECYCLER.get();
    block.indexEntries = Maps.newTreeMap();
    entries.forEach(entry -> block.indexEntries.putIfAbsent(entry.getEntryId(), entry));
    checkState(entries.size() == block.indexEntries.size());
    block.segmentMetadata = metadata;//from   w  w  w  . ja v a2 s. c  o  m
    block.dataObjectLength = dataObjectLength;
    block.dataHeaderLength = dataHeaderLength;
    return block;
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.templates.GenerationOptions.java

private void populateProperties() {
    templateFiles = Maps.newLinkedHashMap();
    this.applications = Maps.newLinkedHashMap();
    this.contextProperties = Maps.newTreeMap();
    contextProperties.putAll(new BasePropertyCollector().propertiesForContext(context.getContext()));
}

From source file:nl.knaw.huygens.timbuctoo.messages.ActiveMQBroker.java

@Inject
//TODO factor out the config.
public ActiveMQBroker(Configuration config, TypeRegistry typeRegistry) {
    brokerName = config.getSetting(BROKER_NAME_KEY) + BROKER_NAME;
    url = "vm://" + brokerName;
    LOG.info("Message broker URL: '{}'", url);
    createBrokerService(config);/*  w  ww .j  a  va 2  s  .  co  m*/
    this.typeRegistry = typeRegistry;

    producers = Maps.newTreeMap();
    consumers = Maps.newTreeMap();
}

From source file:com.nomsic.sid.Sid.java

public Sid() {
    recordSimsetMap = Maps.newTreeMap();
    recordFieldCountMap = Maps.newHashMap();
}