Example usage for com.google.common.collect ImmutableTable row

List of usage examples for com.google.common.collect ImmutableTable row

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableTable row.

Prototype

@Override
public ImmutableMap<C, V> row(R rowKey) 

Source Link

Usage

From source file:org.fao.geonet.api.records.formatters.SchemaLocalizations.java

public Collection<String> codelist(String codelistName) throws Exception {
    int prefix = codelistName.indexOf(':');
    if (prefix > -1) {
        codelistName = codelistName.substring(prefix + 1);
    }//from  w w  w .j a  va 2  s . c o  m

    Set<String> codelists = Sets.newHashSet();
    for (SchemaLocalization schemaLocalization : this.schemaLocalizations) {
        final ImmutableTable<String, String, Element> codeListIndex = schemaLocalization
                .getCodeListIndex(this.languageHolder.getLang3());
        codelists.addAll(codeListIndex.row(codelistName).keySet());
    }
    return codelists;
}

From source file:org.fao.geonet.api.records.formatters.SchemaLocalizations.java

public String nodeTranslation(String qualifiedNodeName, String qualifiedParentNodeName, String type)
        throws Exception {
    if (qualifiedParentNodeName == null) {
        qualifiedParentNodeName = "";
    }// www  . j  a  v a2  s .  c om

    for (SchemaLocalization schemaLocalization : this.schemaLocalizations) {
        final ImmutableTable<String, String, Element> labelIndex = schemaLocalization
                .getLabelIndex(this.languageHolder.getLang3());
        Element element = labelIndex.get(qualifiedNodeName, qualifiedParentNodeName);
        if (element == null) {
            element = labelIndex.get(qualifiedNodeName, "");
        }
        if (element == null) {
            final ImmutableCollection<Element> values = labelIndex.row(qualifiedNodeName).values();
            if (!values.isEmpty()) {
                element = values.iterator().next();
            }
        }
        if (element != null) {
            return element.getChildText(type);
        }
    }

    return qualifiedNodeName;
}

From source file:net.sf.e4ftrace.ui.model.TraceModelImplFactory.java

public TraceImpl[] createFTraces(TraceService traceService, URI uri) throws ExecutionException {

    ImmutableTable<Integer, Short, ITrace> data = traceService.fetch(uri, 0);

    UnmodifiableIterator<Integer> it = data.rowKeySet().iterator();

    ArrayList<TraceImpl> rList = Lists.<TraceImpl>newArrayList();

    Random random = new Random();

    /* While Tasks */
    while (it.hasNext()) {

        int atomId = it.next();

        String name = TraceBiMap.getStringValue(atomId);

        ImmutableMap<Short, ITrace> traces = data.row(atomId);

        UnmodifiableIterator<Short> ck = traces.keySet().iterator();

        /* While Cores */
        while (ck.hasNext()) {

            short cpuid = ck.next();
            ITrace trace = traces.get(cpuid);

            TraceImpl traceImpl = new TraceImpl(name, name);

            Iterator<IEvent> ei = trace.getEventsIterator();

            long prevStamp = 0;
            EventImpl prevEventImpl = null;
            TreeSet<Long> tsSet = Sets.<Long>newTreeSet();

            /* While Events */
            while (ei.hasNext()) {

                IEvent event = ei.next();

                long timestamp = event.getTime();

                tsSet.add(timestamp);/*  w  ww . ja v  a  2  s .  co  m*/

                int type = random.nextInt(8) % 7;

                EventImpl eventImpl = new EventImpl(timestamp, traceImpl, getEventType(type));

                if (prevStamp != 0) {

                    long duration = timestamp - prevStamp;

                    prevEventImpl.setDuration(duration);

                    traceImpl.addTraceEvent(prevEventImpl);
                }

                prevStamp = timestamp;
                prevEventImpl = eventImpl;

            }

            long timeStart = tsSet.first();
            long timeEnd = tsSet.last();
            traceImpl.setStartTime(timeStart);
            traceImpl.setStopTime(timeEnd);

            rList.add(traceImpl);
        }
    }

    TraceImpl[] ra = rList.toArray(new TraceImpl[rList.size()]);

    return ra;

}