List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:de.openali.odysseus.chart.factory.config.resolver.ChartTypeResolver.java
private AbstractStyleType findUrlStyleType(final URL context, final String uri, final String identifier) throws XmlException, IOException { final ChartConfigurationLoader loader = getLoader(context, uri); final ChartType[] charts = loader.getCharts(); final List<ChartType> chartTypes = new ArrayList<>(); Collections.addAll(chartTypes, charts); for (final ChartType chart : chartTypes) { final Styles styles = chart.getStyles(); final AbstractStyleType style = StyleHelper.findStyle(styles, identifier); if (style != null) return style; final LayersType layers = chart.getLayers(); final LayerType[] layerArray = layers.getLayerArray(); for (final LayerType layer : layerArray) { final Styles layerStyles = layer.getStyles(); final AbstractStyleType layerStyle = StyleHelper.findStyle(layerStyles, identifier); if (layerStyle != null) return layerStyle; }/*from www . j av a 2 s . c o m*/ final Renderers renderers = chart.getRenderers(); final AxisRendererType[] rendererArray = renderers.getAxisRendererArray(); for (final AxisRendererType renderer : rendererArray) { final Styles rendererStyles = renderer.getStyles(); final AbstractStyleType rendererStyle = StyleHelper.findStyle(rendererStyles, identifier); if (rendererStyle != null) return rendererStyle; } } return null; }
From source file:me.oriley.crate.CrateGenerator.java
@NonNull private static List<File> getFileList(@NonNull File directory) { if (!directory.exists() || !directory.isDirectory()) { throw new IllegalArgumentException("Crate: Invalid file passed: " + directory.getAbsolutePath()); }/* www . j a v a2s .co m*/ List<File> files = new LinkedList<>(); File[] fileArray = directory.listFiles(); if (fileArray != null) { Arrays.sort(fileArray, new Comparator<File>() { @Override public int compare(File o1, File o2) { boolean o1Directory = o1.isDirectory(); boolean o2Directory = o2.isDirectory(); if ((o1Directory && o2Directory) || (!o1Directory && !o2Directory)) { return o1.getName().compareToIgnoreCase(o2.getName()); } else { return o1Directory ? -1 : 1; } } }); Collections.addAll(files, fileArray); } return files; }
From source file:org.ambraproject.admin.service.impl.DocumentManagementServiceImpl.java
/** * @return List of filenames of files in uploadable directory on server *///w ww. j a v a 2s . c om @Override public List<String> getUploadableFiles() { List<String> documents = new ArrayList<String>(); File dir = new File(documentDirectory); if (dir.isDirectory()) { Collections.addAll(documents, dir.list(new FilenameFilter() { //check the file extensions public boolean accept(File file, String fileName) { for (String extension : new String[] { ".tar", ".tar.bz", ".tar.bz2", ".tar.gz", ".tb2", ".tbz", ".tbz2", ".tgz", ".zip" }) { if (fileName.endsWith(extension)) { return true; } } return false; } })); } Collections.sort(documents); return documents; }
From source file:com.github.maven_nar.cpptasks.compiler.CommandLineCompiler.java
@Override protected CompilerConfiguration createConfiguration(final CCTask task, final LinkType linkType, final ProcessorDef[] baseDefs, final CompilerDef specificDef, final TargetDef targetPlatform, final VersionInfo versionInfo) { this.prefix = specificDef.getCompilerPrefix(); this.objDir = task.getObjdir(); final Vector<String> args = new Vector<>(); final CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1]; for (int i = 0; i < baseDefs.length; i++) { defaultProviders[i + 1] = (CompilerDef) baseDefs[i]; }// w ww . j av a 2 s.com defaultProviders[0] = specificDef; final Vector<CommandLineArgument> cmdArgs = new Vector<>(); // // add command line arguments inherited from <cc> element // any "extends" and finally the specific CompilerDef CommandLineArgument[] commandArgs; for (int i = defaultProviders.length - 1; i >= 0; i--) { commandArgs = defaultProviders[i].getActiveProcessorArgs(); for (final CommandLineArgument commandArg : commandArgs) { if (commandArg.getLocation() == 0) { String arg = commandArg.getValue(); if (isWindows() && arg.matches(".*[ \"].*")) { // Work around inconsistent quoting by Ant arg = "\"" + arg.replaceAll("[\\\\\"]", "\\\\$0") + "\""; } args.addElement(arg); } else { cmdArgs.addElement(commandArg); } } } final Vector<ProcessorParam> params = new Vector<>(); // // add command line arguments inherited from <cc> element // any "extends" and finally the specific CompilerDef ProcessorParam[] paramArray; for (int i = defaultProviders.length - 1; i >= 0; i--) { paramArray = defaultProviders[i].getActiveProcessorParams(); Collections.addAll(params, paramArray); } paramArray = params.toArray(new ProcessorParam[params.size()]); if (specificDef.isClearDefaultOptions() == false) { final boolean multithreaded = specificDef.getMultithreaded(defaultProviders, 1); final boolean debug = specificDef.getDebug(baseDefs, 0); final boolean exceptions = specificDef.getExceptions(defaultProviders, 1); final Boolean rtti = specificDef.getRtti(defaultProviders, 1); final OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1); this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization); } // // add all appropriate defines and undefines // buildDefineArguments(defaultProviders, args); final int warnings = specificDef.getWarnings(defaultProviders, 0); addWarningSwitch(args, warnings); Enumeration<CommandLineArgument> argEnum = cmdArgs.elements(); int endCount = 0; while (argEnum.hasMoreElements()) { final CommandLineArgument arg = argEnum.nextElement(); switch (arg.getLocation()) { case 1: args.addElement(arg.getValue()); break; case 2: endCount++; break; } } final String[] endArgs = new String[endCount]; argEnum = cmdArgs.elements(); int index = 0; while (argEnum.hasMoreElements()) { final CommandLineArgument arg = argEnum.nextElement(); if (arg.getLocation() == 2) { endArgs[index++] = arg.getValue(); } } // // Want to have distinct set of arguments with relative // path names for includes that are used to build // the configuration identifier // final Vector<String> relativeArgs = (Vector) args.clone(); // // add all active include and sysincludes // final StringBuffer includePathIdentifier = new StringBuffer(); final File baseDir = specificDef.getProject().getBaseDir(); String baseDirPath; try { baseDirPath = baseDir.getCanonicalPath(); } catch (final IOException ex) { baseDirPath = baseDir.toString(); } final Vector<String> includePath = new Vector<>(); final Vector<String> sysIncludePath = new Vector<>(); for (int i = defaultProviders.length - 1; i >= 0; i--) { String[] incPath = defaultProviders[i].getActiveIncludePaths(); for (final String element : incPath) { includePath.addElement(element); } incPath = defaultProviders[i].getActiveSysIncludePaths(); for (final String element : incPath) { sysIncludePath.addElement(element); } } final File[] incPath = new File[includePath.size()]; for (int i = 0; i < includePath.size(); i++) { incPath[i] = new File(includePath.elementAt(i)); } final File[] sysIncPath = new File[sysIncludePath.size()]; for (int i = 0; i < sysIncludePath.size(); i++) { sysIncPath[i] = new File(sysIncludePath.elementAt(i)); } addIncludes(baseDirPath, incPath, args, relativeArgs, includePathIdentifier, false); addIncludes(baseDirPath, sysIncPath, args, null, null, true); final StringBuffer buf = new StringBuffer(getIdentifier()); for (int i = 0; i < relativeArgs.size(); i++) { buf.append(' '); buf.append(relativeArgs.elementAt(i)); } for (final String endArg : endArgs) { buf.append(' '); buf.append(endArg); } final String configId = buf.toString(); final String[] argArray = new String[args.size()]; args.copyInto(argArray); final boolean rebuild = specificDef.getRebuild(baseDefs, 0); final File[] envIncludePath = getEnvironmentIncludePath(); final String path = specificDef.getToolPath(); CommandLineCompiler compiler = this; Environment environment = specificDef.getEnv(); if (environment == null) { for (final ProcessorDef baseDef : baseDefs) { environment = baseDef.getEnv(); if (environment != null) { compiler = (CommandLineCompiler) compiler.changeEnvironment(baseDef.isNewEnvironment(), environment); } } } else { compiler = (CommandLineCompiler) compiler.changeEnvironment(specificDef.isNewEnvironment(), environment); } return new CommandLineCompilerConfiguration(compiler, configId, incPath, sysIncPath, envIncludePath, includePathIdentifier.toString(), argArray, paramArray, rebuild, endArgs, path, specificDef.getCcache()); }
From source file:interactivespaces.workbench.tasks.WorkbenchTaskContext.java
/** * Add all extension classpath entries that the controller specifies. * * @param classpath// ww w . j a va 2s . c o m * the list of files to add to * @param extraComponent * the extra component to add */ public void addExtrasControllerExtensionsClasspath(List<File> classpath, String extraComponent) { File[] extraComponentFiles = new File( new File(workbench.getWorkbenchFileSystem().getInstallDirectory(), EXTRAS_BASE_FOLDER), extraComponent).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(FILENAME_JAR_EXTENSION); } }); if (extraComponentFiles != null) { Collections.addAll(classpath, extraComponentFiles); } }
From source file:com.andersson.minesweeper.util.IabHelper.java
public String getPricesDev() throws RemoteException, JSONException { ArrayList<String> skuList = new ArrayList<String>(); Collections.addAll(skuList, SkuDetails.SKU_LIST); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); Bundle skuDetails = mService.getSkuDetails(3, mPackageName, "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); logError(thisResponse);//from w w w . j a v a2 s . c o m } } return "Not found"; }
From source file:org.apache.ignite.yardstick.cache.load.IgniteCacheRandomOperationBenchmark.java
/** * Load allowed operation from parameters. *//* w w w. ja v a 2 s. c om*/ private void loadAllowedOperations() { allowedLoadTestOps = new ArrayList<>(); if (args.allowedLoadTestOps().isEmpty()) Collections.addAll(allowedLoadTestOps, Operation.values()); else { for (String opName : args.allowedLoadTestOps()) allowedLoadTestOps.add(Operation.valueOf(opName.toUpperCase())); } }
From source file:com.duroty.application.mail.manager.SendManager.java
/** * DOCUMENT ME!// w w w.ja va2 s .co m * * @param hsession DOCUMENT ME! * @param session DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param ideIdint DOCUMENT ME! * @param to DOCUMENT ME! * @param cc DOCUMENT ME! * @param bcc DOCUMENT ME! * @param subject DOCUMENT ME! * @param body DOCUMENT ME! * @param attachments DOCUMENT ME! * @param isHtml DOCUMENT ME! * @param charset DOCUMENT ME! * @param headers DOCUMENT ME! * @param priority DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void saveDraft(org.hibernate.Session hsession, Session session, String repositoryName, int ideIdint, String to, String cc, String bcc, String subject, String body, Vector attachments, boolean isHtml, String charset, InternetHeaders headers, String priority) throws MailException { try { if (charset == null) { charset = MimeUtility.javaCharset(Charset.defaultCharset().displayName()); } if ((body == null) || body.trim().equals("")) { body = " "; } Email email = null; if (isHtml) { email = new HtmlEmail(); } else { email = new MultiPartEmail(); } email.setCharset(charset); Users user = getUser(hsession, repositoryName); Identity identity = getIdentity(hsession, ideIdint, user); InternetAddress _returnPath = new InternetAddress(identity.getIdeEmail(), identity.getIdeName()); InternetAddress _from = new InternetAddress(identity.getIdeEmail(), identity.getIdeName()); InternetAddress _replyTo = new InternetAddress(identity.getIdeReplyTo(), identity.getIdeName()); InternetAddress[] _to = MessageUtilities.encodeAddresses(to, null); InternetAddress[] _cc = MessageUtilities.encodeAddresses(cc, null); InternetAddress[] _bcc = MessageUtilities.encodeAddresses(bcc, null); if (_from != null) { email.setFrom(_from.getAddress(), _from.getPersonal()); } if (_returnPath != null) { email.addHeader("Return-Path", _returnPath.getAddress()); email.addHeader("Errors-To", _returnPath.getAddress()); email.addHeader("X-Errors-To", _returnPath.getAddress()); } if (_replyTo != null) { email.addReplyTo(_replyTo.getAddress(), _replyTo.getPersonal()); } if ((_to != null) && (_to.length > 0)) { HashSet aux = new HashSet(_to.length); Collections.addAll(aux, _to); email.setTo(aux); } if ((_cc != null) && (_cc.length > 0)) { HashSet aux = new HashSet(_cc.length); Collections.addAll(aux, _cc); email.setCc(aux); } if ((_bcc != null) && (_bcc.length > 0)) { HashSet aux = new HashSet(_bcc.length); Collections.addAll(aux, _bcc); email.setBcc(aux); } email.setSubject(subject); Date now = new Date(); email.setSentDate(now); File dir = new File(System.getProperty("user.home") + File.separator + "tmp"); if (!dir.exists()) { dir.mkdir(); } if ((attachments != null) && (attachments.size() > 0)) { for (int i = 0; i < attachments.size(); i++) { ByteArrayInputStream bais = null; FileOutputStream fos = null; try { MailPartObj obj = (MailPartObj) attachments.get(i); File file = new File(dir, obj.getName()); bais = new ByteArrayInputStream(obj.getAttachent()); fos = new FileOutputStream(file); IOUtils.copy(bais, fos); EmailAttachment attachment = new EmailAttachment(); attachment.setPath(file.getPath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription("File Attachment: " + file.getName()); attachment.setName(file.getName()); if (email instanceof MultiPartEmail) { ((MultiPartEmail) email).attach(attachment); } } catch (Exception ex) { } finally { IOUtils.closeQuietly(bais); IOUtils.closeQuietly(fos); } } } if (headers != null) { Header xheader; Enumeration xe = headers.getAllHeaders(); for (; xe.hasMoreElements();) { xheader = (Header) xe.nextElement(); if (xheader.getName().equals(RFC2822Headers.IN_REPLY_TO)) { email.addHeader(xheader.getName(), xheader.getValue()); } else if (xheader.getName().equals(RFC2822Headers.REFERENCES)) { email.addHeader(xheader.getName(), xheader.getValue()); } } } if (priority != null) { if (priority.equals("high")) { email.addHeader("Importance", priority); email.addHeader("X-priority", "1"); } else if (priority.equals("low")) { email.addHeader("Importance", priority); email.addHeader("X-priority", "5"); } } if (email instanceof HtmlEmail) { ((HtmlEmail) email).setHtmlMsg(body); } else { email.setMsg(body); } email.setMailSession(session); email.buildMimeMessage(); MimeMessage mime = email.getMimeMessage(); int size = MessageUtilities.getMessageSize(mime); if (!controlQuota(hsession, user, size)) { throw new MailException("ErrorMessages.mail.quota.exceded"); } messageable.storeDraftMessage(getId(), mime, user); } catch (MailException e) { throw e; } catch (Exception e) { throw new MailException(e); } catch (java.lang.OutOfMemoryError ex) { System.gc(); throw new MailException(ex); } catch (Throwable e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.baidu.rigel.biplatform.ma.resource.utils.DataModelUtils.java
/** * /* w ww. j a v a 2s.c om*/ * @param cube * @param rowHeadFields * @return String[] */ private static String[] getDimCaptions(Cube cube, List<HeadField> rowHeadFields) { List<String> captions = Lists.newArrayList(); for (HeadField headField : rowHeadFields) { if (!CollectionUtils.isEmpty(headField.getNodeList())) { Collections.addAll(captions, getDimCaptions(cube, headField.getNodeList())); } String uniqueName = headField.getNodeUniqueName(); // TODO ?? if ("?".equals(headField.getCaption())) { uniqueName = headField.getChildren().get(0).getValue(); } else { uniqueName = headField.getValue(); // captions.add(headField.getCaption()); } String dimName = MetaNameUtil.getDimNameFromUniqueName(uniqueName); captions.add(getDimensionCaptionByName(cube, dimName)); } return captions.toArray(new String[0]); }
From source file:com.sonyericsson.hudson.plugins.gerrit.trigger.spec.DuplicateGerritListenersPreloadedProjectHudsonTestCase.java
/** * Constructs the java command for launching a jenkins-cli command. * * @param cmd the cli command to run with parameters. * @return the full command <code>java -jar path/to/jenkins-cli.jar -s theurl cmd...</code>. * @throws IOException if so/*from www.j a v a 2s . c o m*/ * @throws URISyntaxException if so */ List<String> javaCliJarCmd(String... cmd) throws IOException, URISyntaxException { List<String> commands = new ArrayList<String>(cmd.length + 5); commands.add(String.format("%s/bin/java", System.getProperty("java.home"))); commands.add("-jar"); commands.add(new File(j.jenkins.getJnlpJars("jenkins-cli.jar").getURL().toURI()).getAbsolutePath()); commands.add("-s"); commands.add(j.getURL().toExternalForm()); Collections.addAll(commands, cmd); return commands; }