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:org.apache.bookkeeper.mledger.offload.jcloud.impl.OffloadIndexBlockImpl.java

public static OffloadIndexBlockImpl get(InputStream stream) throws IOException {
    OffloadIndexBlockImpl block = RECYCLER.get();
    block.indexEntries = Maps.newTreeMap();
    block.fromStream(stream);//from   w w  w.j a  v  a 2s.c om
    return block;
}

From source file:com.centretown.parts.server.domain.Membership.java

/**
 * default constructor (protected)//w  ww.  j a  v a2s.co  m
 */
protected Membership() {
    super();
    this.names = Maps.newTreeMap();
    this.ids = Maps.newHashMap();
}

From source file:uk.ac.ebi.mdk.io.text.mnxref.MnxRefCompoundInput.java

private Map<String, MnxRefCompound> load(Reader propertyReader, Reader referenceReader) throws IOException {

    Map<String, MnxRefCompound> compounds = Maps.newTreeMap();

    {//from  www. j a v a2 s  .  c  o  m
        CSVReader tsv = new CSVReader(propertyReader, SEPARATOR, QUOTE);
        try {
            String[] line;
            while ((line = tsv.readNext()) != null) {
                if (line[0].charAt(0) != COMMENT) {
                    compounds.put(line[0], MnxRefCompound.parse(line));
                }
            }
        } finally {
            tsv.close();
        }
    }

    {
        CSVReader tsv = new CSVReader(referenceReader, SEPARATOR, QUOTE);
        try {
            String[] line;
            while ((line = tsv.readNext()) != null) {
                if (line[0].charAt(0) != COMMENT) {
                    String mnxId = line[1];
                    MnxRefCompound c = compounds.get(mnxId);
                    if (c == null) {
                        Logger logger = Logger.getLogger(getClass());
                        logger.warn("cound not find MNX id " + line[1]);
                    } else {
                        c.add(Xref.parse(line));
                    }
                }
            }
        } finally {
            tsv.close();
        }
    }

    return compounds;
}

From source file:com.google.caliper.model.BenchmarkSpec.java

private BenchmarkSpec() {
    this.className = "";
    this.methodName = "";
    this.parameters = Maps.newTreeMap();
}

From source file:com.zimbra.soap.json.jackson.ZmDomElementJsonSerializer.java

private void serializeInner(Element value, JsonGenerator jgen, SerializerProvider provider, String parentNs)
        throws IOException, JsonGenerationException {
    String namespaceURI = value.getNamespaceURI();
    jgen.writeStartObject();//from w  w w  . ja v  a  2  s. com
    NamedNodeMap attributes = value.getAttributes();
    if (attributes != null && attributes.getLength() > 0) {
        for (int i = 0; i < attributes.getLength(); i++) {
            Attr attribute = (Attr) attributes.item(i);
            if ("xmlns".equals(attribute.getName())) {
                if (!attribute.getValue().startsWith("urn:zimbra")) {
                    jgen.writeStringField(attribute.getName(), attribute.getValue());
                }
            } else {
                jgen.writeStringField(attribute.getName(), attribute.getValue());
            }
            // Not supporting attributes in different namespaces
        }
    }

    Map<String, List<Element>> elemMap = Maps.newTreeMap();
    NodeList children = value.getChildNodes();
    if (children != null && children.getLength() > 0) {
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            switch (child.getNodeType()) {
            case Node.CDATA_SECTION_NODE:
            case Node.TEXT_NODE:
                String txt = child.getNodeValue();
                if ((txt == null) || ((txt.startsWith("\n")) && (txt.trim().length() == 0))) {
                    break; // Almost certainly only formatting text
                }
                jgen.writeStringField(JSONElement.A_CONTENT /* "_content" */, txt);
                break;
            case Node.ELEMENT_NODE:
                Element elem = (Element) child;
                String eleName = elem.getLocalName();
                List<Element> elems = elemMap.get(eleName);
                if (elems == null) {
                    elems = Lists.newArrayList();
                    elemMap.put(eleName, elems);
                }
                elems.add(elem);
                break;
            }
        }
        for (Entry<String, List<Element>> entry : elemMap.entrySet()) {
            jgen.writeArrayFieldStart(entry.getKey());
            for (Element elem : entry.getValue()) {
                serializeInner(elem, jgen, provider, namespaceURI);
            }
            jgen.writeEndArray();
        }
    }

    if ((namespaceURI != null) && (!namespaceURI.equals(parentNs))) {
        if (!namespaceURI.startsWith("urn:zimbra")) {
            jgen.writeStringField(JSONElement.A_NAMESPACE, namespaceURI);
        }
    }
    jgen.writeEndObject();
}

From source file:com.oddprints.dao.ApplicationSetting.java

public static String getSetting(String key) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    List<ApplicationSetting> applicationSettings = getSettingObjects(pm);

    Map<String, String> map = Maps.newTreeMap();
    for (ApplicationSetting setting : applicationSettings) {
        map.put(setting.getKey(), setting.getValue());
    }/*from  ww w. jav a2  s . com*/
    return map.get(key);
}

From source file:com.huawei.streaming.cql.LocalTaskCommons.java

/**
 * ??//ww  w. j ava 2  s.c o  m
 * @return ?
 */
public static TreeMap<String, String> createLocalConfs() {
    TreeMap<String, String> config = Maps.newTreeMap();
    config.put("streaming.storm.submit.islocal", "true");
    //                config.put("streaming.storm.submit.islocal", "false");
    //                config.put("streaming.storm.nimbus.host", "160.133.0.107");
    return config;
}

From source file:org.kiji.rest.representations.KijiRestRow.java

/**
 * Adds a new cell (specified by the family, qualifier, timestamp and value) to the current row.
 *
 * @param family is the family of the cell to add.
 * @param qualifier is the qualifier of the cell to add.
 * @param timestamp is the timestamp of the cell to add.
 * @param value is the value of the cell to add.
 * @param writerSchema is the writer schema (contained as an option: either as a string or uid)
 *        of the cell's value./*w ww  . j  ava 2  s. c o  m*/
 */
public void addCell(String family, String qualifier, Long timestamp, Object value, SchemaOption writerSchema) {
    NavigableMap<String, List<KijiRestCell>> familyMap = mKijiCellMap.get(family);
    if (familyMap == null) {
        familyMap = Maps.newTreeMap();
        mKijiCellMap.put(family, familyMap);
    }
    List<KijiRestCell> restCells = familyMap.get(qualifier);
    if (restCells == null) {
        restCells = Lists.newArrayList();
        familyMap.put(qualifier, restCells);
    }
    restCells.add(new KijiRestCell(timestamp, value, writerSchema));
}

From source file:org.pshdl.model.simulation.PStoEXCompiler.java

public PStoEXCompiler(String uri, ExecutorService service) {
    super(uri, service);
    final Collection<ITypeOuptutProvider> allImplementations = HDLCore
            .getAllImplementations(ITypeOuptutProvider.class);
    providers = Maps.newTreeMap();
    for (final ITypeOuptutProvider ito : allImplementations) {
        providers.put(ito.getHookName().toLowerCase(), ito);
    }// ww  w .  ja va  2s  .  co  m
}

From source file:com.wavylabs.microbox.servlet.ProxyRpcServlet.java

@Inject
public ProxyRpcServlet(@Named("baseUrl") String baseUrl, @Named("basePort") int basePort) {
    url = baseUrl;/*from   w w  w .  j  ava 2 s.  co  m*/
    port = basePort;
    rpcUrl = "http://" + url + ":" + port + DATA_API_RPC;
    NavigableMap<ProtocolVersion, Gson> gsons = Maps.newTreeMap();
    Gson gsonForPostV2 = new GsonFactory().create();
    gsons.put(ProtocolVersion.V2_2, gsonForPostV2);
    // Remove lines below if we want to stop support for <0.22
    gsons.put(ProtocolVersion.V2_1, gsonForPostV2);

    GsonFactory factoryForV2 = new GsonFactory();
    ElementGsonAdaptorV2 elementGsonAdaptorV2 = new ElementGsonAdaptorV2();
    factoryForV2.registerTypeAdapter(Element.class, elementGsonAdaptorV2);
    factoryForV2.registerTypeAdapter(Attachment.class, elementGsonAdaptorV2);
    gsons.put(ProtocolVersion.V2, factoryForV2.create());

    robotSerializer = new RobotSerializer(gsons, ProtocolVersion.DEFAULT);
}