List of usage examples for java.util Collection toArray
default <T> T[] toArray(IntFunction<T[]> generator)
From source file:com.liferay.ide.alloy.core.webresources_src.PortalResourcesProvider.java
@Override public File[] getResources(IWebResourcesContext context) { File[] retval = null;//from ww w. j a v a 2s.co m IFile htmlFile = context.getHtmlFile(); ILiferayProject project = LiferayCore.create(htmlFile.getProject()); if ((htmlFile != null) && (project != null)) { ILiferayPortal portal = project.adapt(ILiferayPortal.class); if ((portal != null) && ProjectUtil.isPortletProject(htmlFile.getProject())) { IPath portalDir = portal.getAppServerPortalDir(); if (portalDir != null) { IPath cssPath = portalDir.append("html/themes/_unstyled/css"); if (FileUtil.exists(cssPath)) { synchronized (_fileCache) { Collection<File> cachedFiles = _fileCache.get(cssPath); if (cachedFiles != null) { retval = cachedFiles.toArray(new File[0]); } else { String types = new String[] { "css", "scss" }; Collection<File> files = FileUtils.listFiles(cssPath.toFile(), types, true); Collection<File> cached = new HashSet<>(); for (File file : files) { String fileName = file.getName(); if (fileName.endsWith("scss")) { File cachedFile = new File(file.getParent(), ".sass-cache/" + fileName.replaceAll("scss$", "css")); if (FileUtil.exists(cachedFile)) { cached.add(file); } } } files.removeAll(cached); if (files != null) { retval = files.toArray(new File[0]); } _fileCache.put(cssPath, files); } } } } } else if ((portal != null) && ProjectUtil.isLayoutTplProject(htmlFile.getProject())) { // return the static css resource for layout template names based on the version String version = portal.getVersion(); try { if ((version != null) && (version.startsWith("6.0") || version.startsWith("6.1"))) { retval = _createLayoutHelperFiles("resources/layouttpl-6.1.css"); } else if (version != null) { retval = _createLayoutHelperFiles("resources/layouttpl-6.2.css"); } } catch (IOException ioe) { AlloyCore.logError("Unable to load layout template helper css files", ioe); } } } return retval; }
From source file:com.trsst.server.AbstractMultipartAdapter.java
public String[] getAccepts(RequestContext request) { Collection<String> acceptKeys = getAlternateAccepts(request).keySet(); return acceptKeys.toArray(new String[acceptKeys.size()]); }
From source file:com.laxser.blitz.lama.provider.jdbc.JdbcDataAccessProvider.java
protected SQLInterpreter[] findSQLInterpreters() { @SuppressWarnings("unchecked") Collection<SQLInterpreter> interpreters = this.applicationContext.getBeansOfType(SQLInterpreter.class) .values();//from w w w . j a v a 2 s . c o m SQLInterpreter[] arrayInterpreters = interpreters.toArray(new SQLInterpreter[0]); Arrays.sort(arrayInterpreters, new Comparator<SQLInterpreter>() { @Override public int compare(SQLInterpreter thees, SQLInterpreter that) { Order thessOrder = thees.getClass().getAnnotation(Order.class); Order thatOrder = that.getClass().getAnnotation(Order.class); int thessValue = thessOrder == null ? 0 : thessOrder.value(); int thatValue = thatOrder == null ? 0 : thatOrder.value(); return thessValue - thatValue; } }); return arrayInterpreters; }
From source file:com.opengamma.component.factory.web.FreemarkerConfigurationComponentFactory.java
static TemplateLoader[] createLoaders(String[] locations, ServletContext servletContext) { Collection<TemplateLoader> templateLoaders = new ArrayList<TemplateLoader>(); for (String location : locations) { String[] prefixAndBase = StringUtils.split(location, ":", 2); if (prefixAndBase.length != 2) { throw new OpenGammaRuntimeException("Invalid Freemarker template location: " + location); }//from w w w.j a v a2 s . c o m String prefix = prefixAndBase[0].trim(); String base = prefixAndBase[1].trim(); if (SERVLET_CONTEXT.equals(prefix)) { templateLoaders.add(new WebappTemplateLoader(servletContext, base)); } else if (FILE.equals(prefix)) { try { templateLoaders.add(new FileTemplateLoader(new File(base))); } catch (IOException e) { throw new OpenGammaRuntimeException("Unable to load Freemarker templates from " + base, e); } } else { throw new OpenGammaRuntimeException("Invalid Freemarker template location: " + location); } } return templateLoaders.toArray(new TemplateLoader[templateLoaders.size()]); }
From source file:com.appeligo.search.messenger.Messenger.java
/** * /*from ww w .j a va 2s. co m*/ * @param messages */ public int send(Collection<com.appeligo.search.entity.Message> messages) { if (messages != null) { return send(messages.toArray(new com.appeligo.search.entity.Message[0])); } return 0; }
From source file:com.mmnaseri.dragonfly.runtime.session.ApplicationSessionPreparator.java
public ApplicationSessionPreparator(Collection<String> basePackages, DatabaseDialect databaseDialect, boolean initializeSession) { this(basePackages.toArray(new String[basePackages.size()]), databaseDialect, initializeSession); }
From source file:edu.emory.cci.aiw.cvrg.eureka.etl.ksb.PropositionDefinitionFinder.java
public List<PropositionDefinition> findAll(Collection<String> propIds) throws PropositionFinderException { try {/*from w ww . jav a 2 s . c om*/ return this.knowledgeSource.readPropositionDefinitions(propIds.toArray(new String[propIds.size()])); } catch (KnowledgeSourceReadException e) { throw new PropositionFinderException(e); } }
From source file:de.monticore.codegen.GeneratorTest.java
/** * Creates an Iterable over all the JavaFileObjects contained in a given * directory./* w ww . j a va2 s .co m*/ * * @param sourceCodePath the directory from which JavaFileObjects are to be * retrieved * @param fileManager the StandardJavaFileManager to be used for the * JavaFileObject creation * @return the JavaFileObjects contained in the given directory */ protected Iterable<? extends JavaFileObject> getJavaFileObjects(Path sourceCodePath, StandardJavaFileManager fileManager) { Collection<File> files = FileUtils.listFiles(sourceCodePath.toFile(), new String[] { "java" }, true); return fileManager.getJavaFileObjects(files.toArray(new File[files.size()])); }
From source file:com.digitalpebble.storm.crawler.Metadata.java
public void addValues(String key, Collection<String> values) { if (values == null || values.size() == 0) return;//from w w w. ja va 2 s . co m String[] existingvals = md.get(key); if (existingvals == null) { md.put(key, values.toArray(new String[values.size()])); return; } ArrayList<String> existing = new ArrayList<String>(existingvals.length + values.size()); for (String v : existingvals) existing.add(v); existing.addAll(values); md.put(key, existing.toArray(new String[existing.size()])); }
From source file:com.digitalpebble.stormcrawler.Metadata.java
public void addValues(String key, Collection<String> values) { if (values == null || values.size() == 0) return;//from w w w .j ava 2 s.com String[] existingvals = md.get(key); if (existingvals == null) { md.put(key, values.toArray(new String[values.size()])); return; } ArrayList<String> existing = new ArrayList<>(existingvals.length + values.size()); for (String v : existingvals) existing.add(v); existing.addAll(values); md.put(key, existing.toArray(new String[existing.size()])); }