List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:rvsnoop.ui.MultiLineToolTipUI.java
@Override public void paint(Graphics g, JComponent c) { final int w = c.getWidth(), h = c.getHeight(); g.setColor(c.getBackground());//from ww w . j av a 2s. co m g.fillRect(0, 0, w, h); g.setColor(c.getForeground()); g.drawRect(0, 0, w, h); final String[] lines = Iterables.toArray(splitter.split(((JToolTip) c).getTipText()), String.class); if (lines.length > 0) { final Font font = c.getFont(); final FontMetrics fontMetrics = c.getFontMetrics(font); final int fontHeight = fontMetrics.getHeight(); int y = INSET + fontMetrics.getAscent(); for (int i = 0, imax = lines.length; i < imax; ++i) { g.drawString(lines[i], INSET, y); y += fontHeight; } } }
From source file:ec.nbdemetra.ui.interchange.impl.Configs.java
@VisibleForTesting ConfigsBean toBean() {/*www .j av a 2 s . c o m*/ ConfigsBean result = new ConfigsBean(); result.author = author; result.creationTime = creationTime; result.items = Iterables.toArray(items, Config.class); return result; }
From source file:be.nbb.demetra.access.JackcessProvider.java
@Override public File[] getPaths() { return Iterables.toArray(paths, File.class); }
From source file:com.google.devtools.build.lib.vfs.UnixOsPathPolicy.java
@Override public String normalize(String path, int normalizationLevel) { if (normalizationLevel == NORMALIZED) { return path; }/*from w w w .jav a2s . c om*/ if (path.isEmpty()) { return path; } boolean isAbsolute = path.charAt(0) == '/'; StringBuilder sb = new StringBuilder(path.length()); if (isAbsolute) { sb.append('/'); } String[] segments = Iterables.toArray(PATH_SPLITTER.splitToList(path), String.class); int segmentCount = Utils.removeRelativePaths(segments, 0, isAbsolute); for (int i = 0; i < segmentCount; ++i) { sb.append(segments[i]); sb.append('/'); } if (segmentCount > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
From source file:com.enonic.cms.upgrade.task.datasource.DataSourceConverter2.java
private String[] findParameterValues(final Element source) { final List<String> list = Lists.newArrayList(); for (final Element child : findElements(source, "parameter")) { list.add(getTextNode(child));//from www. j av a 2s . co m } return Iterables.toArray(list, String.class); }
From source file:org.comicwiki.transforms.ComicCharacterTransform.java
private static String[] tokenize(String text) { return Iterables.toArray(Splitter.on(' ').trimResults().omitEmptyStrings().split(text), String.class); }
From source file:edu.umn.msi.tropix.persistence.service.impl.UserServiceImpl.java
public User[] getUsers() { return Iterables.toArray(userDao.getUsers(), User.class); }
From source file:com.hpcloud.mon.app.validation.Validation.java
/** * @throws WebApplicationException if the {@code value} is null or empty. */// w w w . jav a 2 s . co m public static Map<String, String> parseAndValidateNameAndDimensions(String name, String dimensionsStr) { Validation.validateNotNullOrEmpty(dimensionsStr, "dimensions"); Map<String, String> dimensions = new HashMap<String, String>(); for (String dimensionStr : COMMA_SPLITTER.split(dimensionsStr)) { String[] dimensionArr = Iterables.toArray(COLON_SPLITTER.split(dimensionStr), String.class); if (dimensionArr.length == 2) dimensions.put(dimensionArr[0], dimensionArr[1]); } String service = dimensions.get(Services.SERVICE_DIMENSION); MetricNameValidation.validate(name, service); DimensionValidation.validate(dimensions, service); return dimensions; }
From source file:com.querydsl.core.types.dsl.PathInits.java
public PathInits(String... initStrs) { boolean initAllProps = false; PathInits defaultValue = DEFAULT;// w ww . j ava2s . c om Map<String, Collection<String>> properties = Maps.newHashMap(); for (String initStr : initStrs) { if (initStr.equals("*")) { initAllProps = true; } else if (initStr.startsWith("*.")) { initAllProps = true; defaultValue = new PathInits(initStr.substring(2)); } else { String key = initStr; List<String> inits = Collections.emptyList(); if (initStr.contains(".")) { key = initStr.substring(0, initStr.indexOf('.')); inits = ImmutableList.of(initStr.substring(key.length() + 1)); } Collection<String> values = properties.get(key); if (values == null) { values = new ArrayList<String>(); properties.put(key, values); } values.addAll(inits); } } for (Map.Entry<String, Collection<String>> entry : properties.entrySet()) { PathInits inits = new PathInits(Iterables.toArray(entry.getValue(), String.class)); propertyToInits.put(entry.getKey(), inits); } this.initAllProps = initAllProps; this.defaultValue = defaultValue; }
From source file:org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider.java
@Override public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) { fTableViewer = (TableViewer) viewer; if (newInput instanceof Collection<?> || newInput instanceof ISegmentStore) { @SuppressWarnings("unchecked") Collection<ISegment> segmentStore = (Collection<@NonNull ISegment>) newInput; ISegment[] array = Iterables.toArray(segmentStore, ISegment.class); @NonNull/*from w w w . java 2 s .co m*/ ISegment[] checkedArray = checkNotNullContents(array); if (fComparator != null) { Arrays.sort(checkedArray, fComparator); } fSegmentArray = checkedArray; } else if (newInput instanceof ISegment[]) { /* * Ensure that there are no null elements in the array, so we can * set it back to fSegmentArray, which does not allow nulls. */ @NonNull ISegment[] checkedArray = checkNotNullContents((@Nullable ISegment[]) newInput); if (fComparator != null) { Arrays.sort(checkedArray, fComparator); } fSegmentArray = checkedArray; } else { fSegmentArray = null; } }