List of usage examples for java.util Collection add
boolean add(E e);
From source file:be.ac.ua.comp.scarletnebula.core.KeyManager.java
static public Collection<String> getKeyNames(final String providerName) { final File dirFile = assureDirectory(providerName); final Collection<String> keynames = new ArrayList<String>(); for (final String keyfile : dirFile.list()) { keynames.add(keyfile.replaceAll("\\.key$", "")); }//w w w . ja v a2 s . c o m return keynames; }
From source file:org.apache.nifi.processors.standard.util.HTTPUtils.java
public static void validateProxyProperties(ValidationContext context, Collection<ValidationResult> results) { if (context.getProperty(PROXY_HOST).isSet() && !context.getProperty(PROXY_PORT).isSet()) { results.add( new ValidationResult.Builder().explanation("Proxy Host was set but no Proxy Port was specified") .valid(false).subject("Proxy server configuration").build()); }//w ww . ja v a 2 s. co m ProxyConfiguration.validateProxySpec(context, results, PROXY_SPECS); }
From source file:Main.java
public static <E> void merge(final Collection<E> into, final E[] values) { checkNotNull(into, "target cannot be null"); checkNotNull(values, "source cannot be null"); for (final E value : values) { into.add(value); }//from w w w.java2 s . co m }
From source file:com.netscape.cmstools.tps.token.TokenCLI.java
public static void printToken(TokenData token) { System.out.println(" Token ID: " + token.getID()); if (token.getUserID() != null) System.out.println(" User ID: " + token.getUserID()); if (token.getType() != null) System.out.println(" Type: " + token.getType()); TokenStatusData status = token.getStatus(); if (status != null) System.out.println(" Status: " + status.name); Collection<TokenStatusData> nextStates = token.getNextStates(); if (nextStates != null) { Collection<TokenStatus> names = new ArrayList<TokenStatus>(); for (TokenStatusData nextState : nextStates) { names.add(nextState.name); }/*from ww w .jav a 2s. c o m*/ System.out.println(" Next States: " + StringUtils.join(names, ", ")); } if (token.getAppletID() != null) System.out.println(" Applet ID: " + token.getAppletID()); if (token.getKeyInfo() != null) System.out.println(" Key Info: " + token.getKeyInfo()); if (token.getPolicy() != null) System.out.println(" Policy: " + token.getPolicy()); if (token.getCreateTimestamp() != null) System.out.println(" Date Created: " + token.getCreateTimestamp()); if (token.getModifyTimestamp() != null) System.out.println(" Date Modified: " + token.getModifyTimestamp()); Link link = token.getLink(); if (verbose && link != null) { System.out.println(" Link: " + link.getHref()); } }
From source file:Main.java
/** * Adds all non-null objects into the specified list. * * @param collection//from ww w .j ava2s .c o m * list to fill * @param objects * objects * @param <T> * objects type * @return true if list changed as the result of this operation, false * otherwise */ public static <T> boolean addAllNonNull(final Collection<T> collection, final T... objects) { boolean result = false; for (final T object : objects) { if (!collection.contains(object) && object != null) { result |= collection.add(object); } } return result; }
From source file:Main.java
/** * // w w w . j a v a2 s. c o m * @param value * @return double[] */ public static double[] toDoubleArray(final String value) { if (value == null) { return new double[] {}; } final int BRACKET_LENGTH = 1; final String strippedValue = value.substring(BRACKET_LENGTH, value.length() - BRACKET_LENGTH); final StringTokenizer tokenizer = new StringTokenizer(strippedValue, ELEMENT_SEPARATOR); final Collection<Double> doubleCollection = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { doubleCollection.add(Double.valueOf(tokenizer.nextToken().trim())); } return toDoubleArray(doubleCollection); }
From source file:Main.java
private static void _addSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself) { if (cls != endBefore && cls != null && cls != Object.class) { if (addClassItself) { if (!result.contains(cls)) { result.add(cls); } else { return; }/*from w w w . j a va2 s. c o m*/ } for (Class<?> intCls : cls.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(cls.getSuperclass(), endBefore, result, true); } }
From source file:com.tamingtext.classifier.maxent.TestMaxent.java
private static void execute(File[] inputFiles, File modelFile) throws IOException, FileNotFoundException { //<start id="maxent.examples.test.setup"/> NameFinderFeatureGenerator nffg //<co id="tmx.feature"/> = new NameFinderFeatureGenerator(); BagOfWordsFeatureGenerator bowfg = new BagOfWordsFeatureGenerator(); InputStream modelStream = //<co id="tmx.modelreader"/> new FileInputStream(modelFile); DoccatModel model = new DoccatModel(modelStream); DocumentCategorizer categorizer //<co id="tmx.categorizer"/> = new DocumentCategorizerME(model, nffg, bowfg); Tokenizer tokenizer = SimpleTokenizer.INSTANCE; int catCount = categorizer.getNumberOfCategories(); Collection<String> categories = new ArrayList<String>(catCount); for (int i = 0; i < catCount; i++) { categories.add(categorizer.getCategory(i)); }/*from w w w . ja v a 2s .c o m*/ ResultAnalyzer resultAnalyzer = //<co id="tmx.results"/> new ResultAnalyzer(categories, "unknown"); runTest(inputFiles, categorizer, tokenizer, resultAnalyzer); //<co id="tmx.run"/> /*<calloutlist> <callout arearefs="tmx.feature">Setup Feature Generators</callout> <callout arearefs="tmx.modelreader">Load Model</callout> <callout arearefs="tmx.categorizer">Create Categorizer</callout> <callout arearefs="tmx.results">Prepare Result Analyzer</callout> <callout arearefs="tmx.run">Execute Test</callout> </calloutlist>*/ //<end id="maxent.examples.test.setup"/> }
From source file:cloudworker.RemoteWorker.java
public static int getQueueSize(AmazonSQS sqs, String queueUrl) { HashMap<String, String> attributes; Collection<String> attributeNames = new ArrayList<String>(); attributeNames.add("ApproximateNumberOfMessages"); GetQueueAttributesRequest getAttributesRequest = new GetQueueAttributesRequest(queueUrl) .withAttributeNames(attributeNames); attributes = (HashMap<String, String>) sqs.getQueueAttributes(getAttributesRequest).getAttributes(); return Integer.valueOf(attributes.get("ApproximateNumberOfMessages")); }
From source file:Main.java
/** * The internal, recursive implementation of getChildComponents(Container, Class...). * * @param parent Container which's children are being gathered. * @param filter The class filter applied, may be null. * @param resultList The list of gathered child components. *///from ww w .ja va 2s . com protected static void getChildComponents(final Container parent, final Class[] filter, final Collection resultList) { final Component[] components = parent.getComponents(); for (Component c : components) { if (filter.length == 0) resultList.add(c); else { for (Class f : filter) { if (f.isAssignableFrom(c.getClass())) { resultList.add(c); break; } } } if (c instanceof Container) getChildComponents((Container) c, filter, resultList); } }