List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:net.ae97.pokebot.extensions.faq.FaqExtension.java
@Override public String[] getAliases() { ArrayList<String> aliases = new ArrayList<>(); aliases.addAll(subCommands.keySet()); String[] it;// w ww .ja v a 2s .co m synchronized (databases) { it = databases.keySet().toArray(new String[0]); } for (String key : it) { for (String sub : subCommands.keySet()) { aliases.add(key + sub); } } return aliases.toArray(new String[aliases.size()]); }
From source file:ElcRate.exception.ExceptionHandler.java
/** * Get a list of all the exceptions. We get a copy rather than the list * itself so that we do not get concurrent access problems. * * @return The exception list/*from www. j a v a2s . c o m*/ */ public ArrayList<Exception> getExceptionList() { synchronized (lock) { // locks are re-entrant, it's ok that hasError is // synchronized on 'lock' also. // We make a copy to avoid concurrent modification exception ArrayList<Exception> queueCopy = new ArrayList<>(); queueCopy.addAll(exceptionQueue); return queueCopy; } }
From source file:be.neutrinet.ispng.vpn.api.VPNClientConfig.java
@Post public Representation getConfig(Map<String, String> data) { try {//w ww . jav a 2s . c o m if (!getRequestAttributes().containsKey("client")) return clientError("MALFORMED_REQUEST", Status.CLIENT_ERROR_BAD_REQUEST); Client client = Clients.dao.queryForId(getAttribute("client")); if (!Policy.get().canAccess(getSessionToken().get().getUser(), client)) { return clientError("FORBIDDEN", Status.CLIENT_ERROR_BAD_REQUEST); } ArrayList<String> config = new ArrayList<>(); config.addAll(Arrays.asList(DEFAULTS)); // create zip ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(baos); List<Certificate> userCert = Certificates.dao.queryForEq("client_id", client.id).stream() .filter(Certificate::valid).collect(Collectors.toList()); if (!userCert.isEmpty()) { byte[] raw = userCert.get(0).getRaw(); zip.putNextEntry(new ZipEntry("client.crt")); zip.write(raw); zip.putNextEntry(new ZipEntry("README")); zip.write(("!! You are using your own keypair. Please make sure to adjust the " + "path to your private key in the config file or move the private key" + " here and name it client.key").getBytes()); config.add("cert client.crt"); config.add("key client.key"); } else if (client.user.certId != null && !client.user.certId.isEmpty()) { Representation res = addPKCS11config(data.get("platform").toLowerCase(), config, client.user); if (res != null) return res; } if (client.user.certId == null || client.user.certId.isEmpty()) { zip.putNextEntry(new ZipEntry("NO_KEYPAIR_DEFINED")); zip.write("Invalid state, no keypair has been defined.".getBytes()); } return finalizeZip(config, zip, baos); } catch (Exception ex) { Logger.getLogger(getClass()).error("Failed to generate config file archive", ex); } return DEFAULT_ERROR; }
From source file:com.almuramc.bolt.registry.CommonRegistry.java
protected Collection<Lock> getRawAll() { ArrayList<Lock> locks = new ArrayList<Lock>(); for (TInt21TripleObjectHashMap value : registry.values()) { locks.addAll(value.valueCollection()); }/* w w w.j a va 2s . c o m*/ return locks; }
From source file:com.celements.menu.MenuService.java
public List<BaseObject> getSubMenuItems(Integer headerId) { TreeMap<Integer, BaseObject> menuItemsMap = new TreeMap<Integer, BaseObject>(); addMenuItems(menuItemsMap, headerId); getContext().setDatabase("celements2web"); addMenuItems(menuItemsMap, headerId); getContext().setDatabase(getContext().getOriginalDatabase()); ArrayList<BaseObject> resultList = new ArrayList<BaseObject>(); resultList.addAll(menuItemsMap.values()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("getSubMenuItems_internal returning: " + Arrays.deepToString(resultList.toArray())); }//from w ww . j a v a 2 s. co m LOGGER.debug("getSubMenuItems_internal end"); return resultList; }
From source file:com.morphoss.jumble.models.Word.java
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(nameKey);/*www .jav a 2s .c o m*/ dest.writeString(imagePath); ArrayList<Localisation> valueList = new ArrayList<Localisation>(); valueList.addAll(localisations.values()); Localisation[] arr = new Localisation[valueList.size()]; valueList.toArray(arr); dest.writeParcelableArray(arr, 0); }
From source file:de.decidr.test.database.factories.EntityFactory.java
/** * Returns a subset containing numItems items of the given list, in random * order./*w w w . j av a2s. c om*/ * * @param list * must not be null * @param numItems * must be positive * @return random subset */ @SuppressWarnings("unchecked") public List getRandomList(List list, int numItems) { ArrayList result = new ArrayList(Math.min(list.size(), numItems)); if (list.isEmpty()) { // nothing to do, return empty list } else if (list.size() == 1) { // (frequent) special case where the input list can serve as a // random pool result.add(list.get(rnd.nextInt(list.size()))); } else { // create temporary shallow copy that serves as a random pool. ArrayList copy = new ArrayList(list.size()); copy.addAll(list); for (int i = 0; i < numItems; i++) { result.add(copy.remove(rnd.nextInt(copy.size()))); } copy.clear(); } return result; }
From source file:org.cloudfoundry.tools.compiler.CloudFoundryJavaCompiler.java
/** * Adapt any tasks options for use with the eclipse batch compiler. * /* w w w .ja va2 s.co m*/ * @param options the source options (never null) * @param classes the class (never null) * @return a set of options that can be applied to the {@link EclipseBatchCompiler} */ private String[] getArgumentsForBatchCompiler(List<String> options, List<String> classes) { ArrayList<String> arguments = new ArrayList<String>(); arguments.addAll(options); if (!classes.isEmpty()) { arguments.add("-classNames"); arguments.add(StringUtils.collectionToCommaDelimitedString(classes)); } return arguments.toArray(new String[arguments.size()]); }
From source file:com.almuramc.bolt.registry.CommonRegistry.java
@Override public Collection<Lock> getAll() { ArrayList<Lock> locks = new ArrayList<Lock>(); for (TInt21TripleObjectHashMap value : registry.values()) { locks.addAll(value.valueCollection()); }/* w w w . j a v a 2 s . co m*/ return Collections.unmodifiableCollection(locks); }
From source file:com.celements.menu.MenuService.java
public List<BaseObject> getMenuHeaders() { LOGGER.trace("getMenuHeaders_internal start"); TreeMap<Integer, BaseObject> menuHeadersMap = new TreeMap<Integer, BaseObject>(); addMenuHeaders(menuHeadersMap);/*from w ww . java 2s. co m*/ getContext().setDatabase("celements2web"); addMenuHeaders(menuHeadersMap); getContext().setDatabase(getContext().getOriginalDatabase()); ArrayList<BaseObject> resultList = new ArrayList<BaseObject>(); resultList.addAll(menuHeadersMap.values()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("getMenuHeaders_internal returning: " + Arrays.deepToString(resultList.toArray())); } LOGGER.debug("getMenuHeaders_internal end"); return resultList; }