List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:org.blip.workflowengine.transferobject.ModifiablePropertyNode.java
@Override public PropertyNode add(final String key, final String value, final Collection<Attribute> attributes) { return internalAdd(true, key, value, Iterables.toArray(attributes, Attribute.class)); }
From source file:brooklyn.util.task.Tasks.java
public static Task<List<?>> sequential(List<? extends TaskAdaptable<?>> tasks) { return sequential(asTasks(Iterables.toArray(tasks, TaskAdaptable.class))); }
From source file:com.kolich.curacao.mappers.request.matchers.AntPathMatcher.java
/** * Tokenize the given String into a String array via a StringTokenizer. * <p>The given delimiters string is supposed to consist of any number of * delimiter characters. Each of those characters can be used to separate * tokens. A delimiter is always a single character; for multi-character * delimiters, consider using {@code delimitedListToStringArray} * @param str the String to tokenize//from ww w . ja v a2 s. c o m * @param delimiters the delimiter characters, assembled as String * (each of those characters is individually considered as delimiter) * @param ignoreEmptyTokens omit empty tokens from the result array * (only applies to tokens that are empty after trimming; StringTokenizer * will not consider subsequent delimiters as token in the first place). * @return an array of the tokens ({@code null} if the input String * was {@code null}) * @see java.util.StringTokenizer * @see String#trim() */ private static String[] tokenizeToStringArray(String str, String delimiters, boolean ignoreEmptyTokens) { if (str == null) { return null; } final StringTokenizer st = new StringTokenizer(str, delimiters); final List<String> tokens = Lists.newLinkedList(); while (st.hasMoreTokens()) { final String token = st.nextToken().trim(); if (!ignoreEmptyTokens || token.length() > 0) { tokens.add(token); } } return Iterables.toArray(tokens, String.class); }
From source file:de.fhg.iais.cortex.model.aip.util.XmlUtils.java
public static Element element(Element root, boolean create, String... path) { Element e = root;/*from w w w . j a va2 s .c o m*/ Element parent = null; if (path != null) { String joinedPaths = JOINER.join(path); String[] pathElements = Iterables.toArray(SPLITTER.split(joinedPaths), String.class); if (pathElements.length > 0) { if (!root.getName().equals(pathElements[0])) { throw new DomElementException( "Expected root '" + pathElements[0] + "', found '" + root.getName() + "'!"); } for (int i = 1; i < pathElements.length; i++) { parent = e; e = e.getChild(pathElements[i]); if (e == null) { e = retryWithNamespace(parent, pathElements[i], Namespace.getNamespace("http://www.deutsche-digitale-bibliothek.de/cortex")); if (e == null) { e = retryWithNamespace(parent, pathElements[i], Namespace .getNamespace("http://www.deutsche-digitale-bibliothek.de/institution")); } if (e == null) { e = retryWithNamespace(parent, pathElements[i], Namespace.getNamespace("http://www.deutsche-digitale-bibliothek.de/item")); } if (e == null) { if (create) { e = new Element(pathElements[i]); XmlUtils.addChild(parent, e); } else { return null; } } } } } else { return null; } } return e; }
From source file:org.cloudsmith.geppetto.pp.dsl.ui.editor.findrefs.ReferenceSearchResultContentProvider.java
public Object[] getChildren(Object parentElement) { if (parentElement instanceof ReferenceSearchViewTreeNode) { return Iterables.toArray(((ReferenceSearchViewTreeNode) parentElement).getChildren(), ReferenceSearchViewTreeNode.class); }//from ww w . j ava 2s . c om return null; }
From source file:brooklyn.util.task.Tasks.java
public static Task<List<?>> sequential(String name, List<? extends TaskAdaptable<?>> tasks) { return sequential(name, asTasks(Iterables.toArray(tasks, TaskAdaptable.class))); }
From source file:ru.ksu.niimm.cll.mocassin.crawl.parser.gate.util.AnnotationUtilImpl.java
private String[] extractTokensWithMathExpressions(Document document, Annotation annotation, String symbol) { List<Annotation> tokenList = getSortedTokenList(document, annotation, false); tokenList.addAll(getMathTokens(document, annotation)); Collections.sort(tokenList, new OffsetComparator()); List<String> strTokens = new ArrayList<String>(); for (Annotation a : tokenList) { String value = null;//from w ww . ja v a 2s . c o m if (a.getType().equals(TOKEN_ANNOTATION_NAME)) { value = (String) a.getFeatures().get(GateFormatConstants.TOKEN_FEATURE_NAME); } else if (a.getType().equals(ARXMLIV_MATH_ANNOTATION_NAME)) { value = symbol == null ? String.format("$%s$", (String) a.getFeatures().get(ARXMLIV_MATH_TEX_ANNOTATION_NAME)) : symbol; } if (value != null) { strTokens.add(value); } } return Iterables.toArray(strTokens, String.class); }
From source file:org.apache.lens.cli.commands.LensDimensionTableCommands.java
/** * Gets the storage from dim.//from w ww.j av a 2s . c o m * * @param tablepair the tablepair * @return the storage from dim */ @CliCommand(value = "dimtable get storage", help = "describe storage of dimension table") public String getStorageFromDim(@CliOption(key = { "", "table" }, mandatory = true, help = "<dimension-table-name> <storage-name>") String tablepair) { Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(tablepair); String[] pair = Iterables.toArray(parts, String.class); if (pair.length != 2) { return "Syntax error, please try in following " + "format. create dimtable <dimtable spec path> <storage spec path>"; } try { return formatJson( mapper.writer(pp).writeValueAsString(getClient().getStorageFromDim(pair[0], pair[1]))); } catch (IOException e) { throw new IllegalArgumentException(e); } }
From source file:org.blip.workflowengine.transferobject.ModifiablePropertyNode.java
@Override public PropertyNode add(final String key, final Instant value, final Collection<Attribute> attributes) { return internalAdd(true, key, value, Iterables.toArray(attributes, Attribute.class)); }
From source file:com.inmobi.grill.cli.commands.GrillFactCommands.java
@CliCommand(value = "fact get storage", help = "get storage of fact table") public String getStorageFromFact( @CliOption(key = { "", "table" }, mandatory = true, help = "<table> <storage>") String tablepair) { Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(tablepair); String[] pair = Iterables.toArray(parts, String.class); if (pair.length != 2) { return "Syntax error, please try in following " + "format. fact get storage <table> <storage>"; }/*from w w w.j a va2 s. c o m*/ XStorageTableElement element = client.getStorageFromFact(pair[0], pair[1]); return FormatUtils.getStorageString(element); }