Example usage for com.google.common.collect Iterables toString

List of usage examples for com.google.common.collect Iterables toString

Introduction

In this page you can find the example usage for com.google.common.collect Iterables toString.

Prototype

public static String toString(Iterable<?> iterable) 

Source Link

Document

Returns a string representation of iterable , with the format [e1, e2, ..., en] (that is, identical to java.util.Arrays Arrays .toString(Iterables.toArray(iterable)) ).

Usage

From source file:org.polymap.core.mapeditor.contextmenu.WmsFeatureInfoContribution.java

@Override
public IContextMenuContribution init(ContextMenuSite _site) {
    this.site = _site;

    setVisible(false);//from   w  w w. j  av a 2  s  . c o  m

    for (final ILayer layer : site.getMap().getLayers()) {
        if (layer.isVisible() && layer.getGeoResource().canResolve(WebMapServer.class)) {

            setVisible(true);

            UIJob job = new UIJob("GetFeatureInfo: " + layer.getLabel()) {
                protected void runWithException(IProgressMonitor monitor) throws Exception {
                    try {
                        IGeoResource geores = layer.getGeoResource();
                        WebMapServer wms = geores.resolve(WebMapServer.class, null);

                        WMSCapabilities caps = wms.getCapabilities();

                        // GetFeatureInfo supported?
                        if (caps.getRequest().getGetFeatureInfo() != null) {
                            List<String> formats = caps.getRequest().getGetFeatureInfo().getFormats();
                            log.info("Possible formats: " + layer.getLabel());
                            log.info("    " + Iterables.toString(formats));

                            String format = formats.contains("text/html") ? "text/html" : null;
                            format = format == null && formats.contains("text/plain") ? "text/plain" : format;
                            //                                format = format == null && formats.contains( "application/vnd.ogc.gml" ) ? "application/vnd.ogc.gml" : format;

                            // no format !?
                            if (format == null) {
                                log.warn(Messages.get("WmsFeatureInfoContribution_noFormat", layer.getLabel())
                                        + ", Formate: " + Iterables.toString(formats));
                                //                                    PolymapWorkbench.handleError( MapEditorPlugin.PLUGIN_ID, this, 
                                //                                            Messages.get( "WmsFeatureInfoContribution_noFormat", layer.getLabel() ), 
                                //                                            new Exception( "Formate: " + Iterables.toString( formats ) ) );
                            }
                            // rough check if any feature is covered
                            String plain = issueRequest(geores, format, false);
                            log.info("Plain: " + StringUtils.abbreviate(plain, 200));
                            if (plain.length() > 50) {
                                awaitAndFillMenuEntry(layer, geores, format);
                            }
                        }
                    } catch (Throwable e) {
                        log.warn("Unable to GetFeatureInfo of: " + layer.getLabel());
                        log.debug("", e);
                    }
                }
            };
            job.schedule();
        }
    }
    return this;
}

From source file:name.marcelomorales.siqisiqi.configuration.ConfigProvider.java

public Iterable<String> possibleConfigFilePositions() {

    // Filter out when APPDATA or HOME or anything else is missing
    final Multimap<String, String> applicableTemplates = Multimaps.filterKeys(TEMPLATES,
            new Predicate<String>() {

                @Override//from ww w .j  av a2 s .  co  m
                public boolean apply(@Nullable String input) {
                    return Strings.isNullOrEmpty(input) || !Strings.isNullOrEmpty(System.getenv(input));
                }
            });

    final Iterable<String> transform = Iterables.transform(applicableTemplates.entries(),
            new Function<Map.Entry<String, String>, String>() {

                @Override
                public String apply(Map.Entry<String, String> input) {
                    return MessageFormat.format(input.getValue(), System.getenv(input.getKey()), vendorName,
                            applicationName);
                }
            });

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Will check all these paths in order {}", Iterables.toString(transform));
    }

    return transform;
}

From source file:org.jclouds.aliyun.ecs.domain.options.TagOptions.java

private void validateInput(final String input, int maxLength) {
    checkNotNull(input);/*from ww  w.j a  va  2 s  .  c o m*/
    checkState(input.length() <= maxLength, String.format("input must be <= %d chars", maxLength));
    checkState(!Iterables.any(FORBIDDEN_PREFIX, new Predicate<String>() {
        @Override
        public boolean apply(String forbiddenPrefix) {
            return input.startsWith(forbiddenPrefix);
        }
    }), input + " cannot starts with any of " + Iterables.toString(FORBIDDEN_PREFIX));
}

From source file:com.palantir.common.collect.IterableUtils.java

public static <T> Iterable<T> mergeIterables(final Iterable<? extends T> one, final Iterable<? extends T> two,
        final Comparator<? super T> ordering, final Function<? super Pair<T, T>, ? extends T> mergeFunction) {
    Preconditions.checkNotNull(one);//from   ww  w.  j  a  va2s . co  m
    Preconditions.checkNotNull(two);
    Preconditions.checkNotNull(mergeFunction);
    Preconditions.checkNotNull(ordering);
    return new Iterable<T>() {
        @Override
        public Iterator<T> iterator() {
            return IteratorUtils.mergeIterators(one.iterator(), two.iterator(), ordering, mergeFunction);
        }

        @Override
        public String toString() {
            return Iterables.toString(this);
        }
    };
}

From source file:eu.interedition.collatex.neo4j.Neo4jVariantGraphVertex.java

@Override
public String toString() {
    return Iterables.toString(tokens());
}

From source file:com.google.devtools.build.lib.skyframe.ConfiguredTargetValue.java

@Override
public String toString() {
    return "ConfiguredTargetValue: " + configuredTarget + ", actions: "
            + (configuredTarget == null ? null : Iterables.toString(getActions()));
}

From source file:org.impressivecode.depress.its.ITSInputTransformer.java

@Override
public InputTransformer<ITSDataType> validate() throws InvalidSettingsException {
    checkNotNull(this.minimalTableSpec, "Minimal DataTableSpec hat to be set");
    checkNotNull(this.inputTableSpec, "Input DataTableSpec hat to be set");

    Set<String> missing = DataTableSpecUtils.findMissingColumnSubset(this.inputTableSpec,
            this.minimalTableSpec);
    if (!missing.isEmpty()) {
        throw new InvalidSettingsException("History data table does not contain required columns. Missing: "
                + Iterables.toString(missing));
    }//  w w  w  . j av  a 2s  . com
    return this;
}

From source file:com.palantir.common.collect.IterableUtils.java

public static <T> Iterable<T> transformIterator(final Iterable<T> it,
        final Function<Iterator<T>, Iterator<T>> f) {
    return new Iterable<T>() {
        @Override/*w w w  . ja  va2  s .co m*/
        public Iterator<T> iterator() {
            return f.apply(it.iterator());
        }

        @Override
        public String toString() {
            return Iterables.toString(this);
        }
    };
}

From source file:jflowmap.FlowMapGraph.java

/**
 * This constructor is intended to be used when the stats have to be
 * induced and not calculated (for instance, in case when a global mapping over
 * a number of flow maps for small multiples must be used).
 * Otherwise, use {@link #FlowMapGraph(Graph, FlowMapAttrSpec)}.
 *///from   w w  w.  j  a v  a2s .  c o  m
public FlowMapGraph(Graph graph, FlowMapAttrSpec attrSpec, FlowMapStats stats) {
    attrSpec.checkValidityFor(graph);
    this.graph = graph;
    this.attrSpec = attrSpec;
    //    List<String> weightAttrs = Lists.newArrayList(attrSpec.getEdgeWeightAttrNames());
    //    Collections.sort(weightAttrs);

    List<String> weightAttrs = attrSpec.getFlowWeightAttrs();
    if (weightAttrs.size() == 0) {
        throw new IllegalArgumentException("FlowMapGraph must have at least one weight attr. "
                + "Available columns: " + Iterables.toString(Tables.columns(graph.getEdgeTable())));
    }

    logger.info("Creating FlowMapGraph '" + getGraphId(graph) + "' with " + graph.getNodeTable().getRowCount()
            + " nodes" + ", " + graph.getEdgeTable().getRowCount() + " flows" + ", and " + weightAttrs.size()
            + " flow weight attrs");

    if (logger.isDebugEnabled()) {
        logger.debug("FlowMapGraph flow weight attrs: " + weightAttrs);
    }

    if (stats == null) {
        //stats = EdgeListFlowMapStats.createFor(edges(), attrSpec);
        stats = MultiFlowMapStats.createFor(this);
        logger.info("Flow weight stats: " + stats.getEdgeWeightStats());
    }
    this.stats = stats;
}

From source file:eu.numberfour.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager.java

@Override
protected List<WorkingSet> initializeWorkingSets() {
    checkState(orderedWorkingSetFilters.size() == orderedWorkingSetIds.size(),
            "Expected same number of working set names as working set filters." + "\nNames were: "
                    + Iterables.toString(orderedWorkingSetIds) + "\nFilters were: "
                    + Iterables.toString(orderedWorkingSetFilters));

    if (orderedWorkingSetFilters.isEmpty()) {
        orderedWorkingSetFilters.add(OTHERS_WORKING_SET_ID);
        orderedWorkingSetIds.add(OTHERS_WORKING_SET_ID);
    }//from   w w w . j a  v a 2s.  com

    final int size = orderedWorkingSetFilters.size();
    final WorkingSet[] workingSets = new WorkingSet[size];
    for (int i = 0; i < size; i++) {
        final String regex = orderedWorkingSetFilters.get(i);
        final String name = orderedWorkingSetIds.get(i);
        workingSets[i] = new ProjectNameFilterWorkingSet(Pattern.compile(regex), name, this);
    }

    return Arrays.asList(workingSets);
}