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.vclipse.vcml.ui.hyperlinks.VcmlHyperlinkHelper.java
@Override public IHyperlink[] createHyperlinksByOffset(XtextResource resource, int offset, boolean createMultipleHyperlinks) { List<IHyperlink> links = Lists.newArrayList(); IHyperlink[] createHyperlinksByOffset = super.createHyperlinksByOffset(resource, offset, createMultipleHyperlinks);//from w w w .j a v a 2 s . co m if (createHyperlinksByOffset != null) { links.addAll(Arrays.asList(createHyperlinksByOffset)); } for (IHyperlinkHelper helper : extensions.getExtensions()) { createHyperlinksByOffset = helper.createHyperlinksByOffset(resource, offset, true); if (createHyperlinksByOffset != null) { links.addAll(Arrays.asList(createHyperlinksByOffset)); } } return links.isEmpty() ? null : Iterables.toArray(links, IHyperlink.class); }
From source file:dagger2.internal.codegen.writer.Snippet.java
public static Snippet format(String format, Iterable<? extends Object> args) { return format(format, Iterables.toArray(args, Object.class)); }
From source file:org.sonar.plugins.java.JavaRulesDefinition.java
@Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName("SonarAnalyzer"); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); JavaSonarWayProfile.Profile profile = JavaSonarWayProfile.readProfile(); for (Class ruleClass : checks) { newRule(ruleClass, repository, profile); }/*from ww w . ja v a 2 s . c om*/ repository.done(); }
From source file:edu.umn.msi.tropix.webgui.server.IdentificationJobImpl.java
@ServiceMethod(readOnly = true) public Collection<ProteomicsRun> getRuns(final Collection<String> sourceIds) { final ProteomicsRun[] runs = analysisService.getRuns(userSession.getGridId(), Iterables.toArray(sourceIds, String.class)); return Sets.newHashSet(Collections.transform(Lists.newArrayList(runs), BeanSanitizerUtils.<ProteomicsRun>asFunction(beanSanitizer))); }
From source file:hmi.tts.util.BMLTextUtil.java
public static List<SyncAndOffset> getSyncAndOffsetList(String text, int numberOfWords) { text = stripSyncNameSpace(text);//from w w w.jav a2 s. co m List<SyncAndOffset> syncAndOffsetList = new ArrayList<SyncAndOffset>(); int index = text.indexOf("<sync"); while (index != -1) { String str = text.substring(0, index); String strAfter = text.substring(index, text.length()); String syncId = strAfter.replaceAll("<sync\\s+id\\s*=\\s*\"", ""); syncId = syncId.replaceAll("\".*", ""); //replace syncs before String strNoSync2 = str.replaceAll("<sync\\s+id\\s*=\\s*\"[a-zA-Z][a-zA-Z0-9\\-_]*\"\\s*/?>", ""); strNoSync2 = strNoSync2.replaceAll("</sync>", ""); String strSplit[] = Iterables.toArray(Splitter.on(" ").omitEmptyStrings().split(strNoSync2), String.class); if (strSplit.length == numberOfWords) { syncAndOffsetList.add(new SyncAndOffset(syncId, strSplit.length)); } else { syncAndOffsetList.add(new SyncAndOffset(syncId, strSplit.length)); } index = text.indexOf("<sync", index + 1); } return syncAndOffsetList; }
From source file:org.sonatype.nexus.maven.staging.workflow.AbstractStagingBuildActionMojo.java
protected String[] getStagingRepositoryIds() throws MojoExecutionException { String[] result = null;//from w w w . java 2s . c om if (stagingRepositoryId != null) { // explicitly configured either via config or CLI, use that result = Iterables.toArray(Splitter.on(",").split(stagingRepositoryId), String.class); } if (result == null) { // collect all the repositories we created final ArrayList<String> resultNames = new ArrayList<String>(); final File stageRoot = getStagingDirectoryRoot(); final File[] localStageRepositories = stageRoot.listFiles(); if (localStageRepositories == null) { getLog().info("We have nothing locally staged, bailing out."); result = null; // this will fail the build later below } else { for (File profileDirectory : localStageRepositories) { if (!(profileDirectory.isFile() && profileDirectory.getName().endsWith( AbstractStagingDeployStrategy.STAGING_REPOSITORY_PROPERTY_FILE_NAME_SUFFIX))) { continue; } final String managedStagingRepositoryId = readStagingRepositoryIdFromPropertiesFile( profileDirectory); if (managedStagingRepositoryId != null) { resultNames.add(managedStagingRepositoryId); } } } result = resultNames.toArray(new String[resultNames.size()]); } // check did we get any result at all if (result == null || result.length == 0) { throw new MojoExecutionException( "The staging repository to operate against is not defined! (use \"-DstagingRepositoryId=foo1,foo2\" on CLI)"); } return result; }
From source file:org.opensocial.explorer.specserver.servlet.ExplorerInjectedServlet.java
protected String[] getPaths(HttpServletRequest req) { String path = req.getPathInfo(); if (path == null) { return new String[0]; }//from w ww . ja va 2s . co m Iterable<String> splitPath = PATH_SPLITTER.split(path); return Iterables.toArray(splitPath, String.class); }
From source file:org.eclipse.rcptt.ui.utils.WriteAccessChecker.java
private IQ7Element[] findReadOnly(IQ7Element... models) { List<IQ7Element> readOnly = new ArrayList<IQ7Element>(); for (IQ7Element model : models) { if (isReadOnly(model) && !readOnly.contains(model)) { readOnly.add(model);//from ww w .j a v a2s .c o m } } return Iterables.toArray(readOnly, IQ7Element.class); }
From source file:org.apache.jackrabbit.oak.spi.security.authorization.cug.impl.TopLevelPaths.java
boolean contains(@Nonnull String path) { if (!hasAny()) { return false; }//from ww w .j a v a 2s.c om if (PathUtils.denotesRoot(path)) { return true; } if (cnt == null) { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); PropertyState hiddenTopCnt = rootTree.getProperty(HIDDEN_TOP_CUG_CNT); if (hiddenTopCnt != null) { cnt = hiddenTopCnt.getValue(Type.LONG); if (cnt <= MAX_CNT) { PropertyState hidden = root.getTree(PathUtils.ROOT_PATH).getProperty(HIDDEN_NESTED_CUGS); paths = (hidden == null) ? new String[0] : Iterables.toArray(hidden.getValue(Type.STRINGS), String.class); } else { paths = null; } } else { cnt = NONE; } } if (cnt == NONE) { return false; } if (cnt > MAX_CNT) { return true; } else if (paths != null) { for (String p : paths) { if (Text.isDescendantOrEqual(path, p)) { return true; } } } return false; }
From source file:com.clarkparsia.sbol.editor.dialog.SOMappingTab.java
@Override public Component getComponent() { final URITableModel tableModel = new URITableModel(Collections.<URI>emptyList()); final JTable table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(100, 100)); InputDialog.setWidthAsPercentages(table, tableModel.getWidths()); final JComboBox typeSelection = new JComboBox(Iterables.toArray(Parts.sorted(), Part.class)); typeSelection.setRenderer(new PartCellRenderer()); typeSelection.addActionListener(new ActionListener() { @Override/*w ww. j ava2 s.c o m*/ public void actionPerformed(ActionEvent e) { Part part = (Part) typeSelection.getSelectedItem(); ((URITableModel) table.getModel()).setElements(part.getTypes()); } }); typeSelection.setSelectedItem(Parts.GENERIC); FormBuilder form = new FormBuilder(); form.add("SBOL Part", typeSelection); JPanel topPanel = form.build(); JPanel tablePanel = new JPanel(); tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.PAGE_AXIS)); JLabel label = new JLabel("SO Types"); label.setLabelFor(table); label.setAlignmentX(Component.LEFT_ALIGNMENT); JScrollPane tableScroller = new JScrollPane(table); // tableScroller.setPreferredSize(new Dimension(450, 200)); tableScroller.setAlignmentX(Component.LEFT_ALIGNMENT); // tablePane.add(label); // tablePane.add(Box.createRigidArea(new Dimension(0, 5))); tablePanel.add(tableScroller); // tablePane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel); // table.setRowSorter(sorter); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.add(topPanel, BorderLayout.NORTH); panel.add(tablePanel, BorderLayout.CENTER); return panel; }