List of usage examples for java.util Collection toString
public String toString()
From source file:org.xdi.oxauth.model.util.StringUtils.java
public static void addQueryStringParam(StringBuilder p_queryStringBuilder, String key, Collection value) throws UnsupportedEncodingException { if (p_queryStringBuilder != null && isNotBlank(key) && value != null && !value.isEmpty()) { if (p_queryStringBuilder.toString().length() > 0) { p_queryStringBuilder.append("&"); }/* w w w. java 2s . c om*/ p_queryStringBuilder.append(key).append("=") .append(URLEncoder.encode(value.toString(), Util.UTF8_STRING_ENCODING)); } }
From source file:nc.noumea.mairie.appock.core.utility.AppockUtil.java
/** * Mthode pour "charger" une collection, pour viter pb de lazy loading * @param collection collection charger *//* ww w .j a v a 2 s . c om*/ public static void chargeCollection(@SuppressWarnings("rawtypes") Collection collection) { // ne pas enlever cette ligne de debug, volontaire if (collection != null) { log.debug(collection.toString()); } }
From source file:org.evors.core.TestUtils.java
public static Matcher<Vector2D> vIsIn(final Collection<Vector2D> vc) { return new BaseMatcher<Vector2D>() { @Override/*from ww w . ja v a2 s. co m*/ public boolean matches(Object item) { Vector2D v2 = (Vector2D) item; boolean matchFound = false; for (Vector2D v : vc) { if (v2.distance(v) < EPS) matchFound = true; } return matchFound; } @Override public void describeTo(Description description) { description.appendText("Vector not found in collection :" + vc.toString()); } }; }
From source file:com.tamingtext.classifier.bayes.ExtractTrainingData.java
/** * Extract training data from a lucene index. * <p>//from w w w .j av a 2 s.c o m * Iterates over documents in the lucene index, the values in the categoryFields are inspected and if found to * contain any of the strings found in the category file, a training data item will be emitted, assigned to the * matching category and containing the terms found in the fields listed in textFields. Output is written to * the output directory with one file per category. * <p> * The category file contains one line per category, each line contains a number of whitespace delimited strings. * The first string on each line is the category name, while subsequent strings will be used to identify documents * that belong in that category. * <p> * 'Technology Computers Macintosh' will cause documents that contain either 'Technology', 'Computers' or 'Machintosh' * in one of their categoryFields to be assigned to the 'Technology' category. * * * @param indexDir * directory of lucene index to extract from * * @param maxDocs * the maximum number of documents to process. * * @param categoryFile * file containing category strings to extract * * @param categoryFields * list of fields to match against category data * * @param textFields * list of fields containing terms to extract * * @param outputDir * directory to write output to * * @throws IOException */ public static void extractTraininingData(File indexDir, File categoryFile, Collection<String> categoryFields, Collection<String> textFields, File outputDir, boolean useTermVectors) throws IOException { log.info("Index dir: " + indexDir); log.info("Category file: " + categoryFile); log.info("Output dir: " + outputDir); log.info("Category fields: " + categoryFields.toString()); log.info("Text fields: " + textFields.toString()); log.info("Use Term Vectors?: " + useTermVectors); OpenObjectIntHashMap<String> categoryCounts = new OpenObjectIntHashMap<String>(); Map<String, List<String>> categories = readCategoryFile(categoryFile); Directory dir = FSDirectory.open(indexDir); IndexReader reader = IndexReader.open(dir, true); int max = reader.maxDoc(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < max; i++) { if (!reader.isDeleted(i)) { Document d = reader.document(i); String category = null; // determine whether any of the fields in this document contain a // category in the category list fields: for (String field : categoryFields) { for (Field f : d.getFields(field)) { if (f.isStored() && !f.isBinary()) { String fieldValue = f.stringValue().toLowerCase(); for (String cat : categories.keySet()) { List<String> cats = categories.get(cat); for (String c : cats) { if (fieldValue.contains(c)) { category = cat; break fields; } } } } } } if (category == null) continue; // append the terms from each of the textFields to the training data for this document. buf.setLength(0); for (String field : textFields) { if (useTermVectors) { appendVectorTerms(buf, reader.getTermFreqVector(i, field)); } else { appendFieldText(buf, d.getField(field)); } } getWriterForCategory(outputDir, category).printf("%s\t%s\n", category, buf.toString()); categoryCounts.adjustOrPutValue(category, 1, 1); } } if (log.isInfoEnabled()) { StringBuilder b = new StringBuilder(); b.append("\nCatagory document counts:\n"); LinkedList<String> keyList = new LinkedList<String>(); categoryCounts.keysSortedByValue(keyList); String key; while (!keyList.isEmpty()) { key = keyList.removeLast(); b.append(categoryCounts.get(key)).append('\t').append(key).append('\n'); } log.info(b.toString()); } }
From source file:org.kuali.kfs.module.ld.util.ConsolidationUtil.java
/** * Utility class for helping DAOs deal with building queries for the consolidation option * // w w w . j av a 2 s . co m * @param query Query to make consolidated * @param extraFields fields included in the query * @param ignoredFields to omit from the query */ public static void buildConsolidatedQuery(ReportQueryByCriteria query, String... extraFields) { Collection<String> attributeList = buildAttributeCollection(extraFields); Collection<String> groupByList = buildGroupByCollection(); attributeList.remove(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); groupByList.remove(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); attributeList.remove(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE); groupByList.remove(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE); attributeList.remove(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE); groupByList.remove(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE); // set the selection attributes String[] attributes = (String[]) attributeList.toArray(new String[attributeList.size()]); query.setAttributes(attributes); if (LOG.isDebugEnabled()) { LOG.debug("Built Attributes for Query: " + attributeList.toString()); } // add the group criteria into the selection statement String[] groupBy = (String[]) groupByList.toArray(new String[attributeList.size()]); query.addGroupBy(groupBy); if (LOG.isDebugEnabled()) { LOG.debug("Built GroupBy for Query: " + groupByList.toString()); } }
From source file:com.himanshu.poc.springbootsec.UserDaoTest.java
@Test public void testGetAll() { Assert.assertNotNull(userDao);//from www . j av a2 s. c om Collection<UserDO> users = userDao.getAll(); logger.info(users.toString()); Assert.assertNotNull(users); Assert.assertTrue(users.size() == 3); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.graph.decorators.IB_EdgeToolTipTransformer.java
public String transform(IB_Edge e) { if (e instanceof Graph) { String tip = "tool tip unavailable"; // how many are selected? don't return if the string is too large Collection vc = ((Graph) e).getEdges(); if (vc.size() < 3) tip = vc.toString(); return tip; }//from www . j a va2s . c o m return e.toString(); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.graph.decorators.IB_VertexToolTipTransformer.java
public String transform(IB_Vertex v) { if (v instanceof Graph) { String tip = "tool tip unavailable"; // how many are selected? don't return if the string is too large Collection vc = ((Graph) v).getVertices(); if (vc.size() < 3) tip = vc.toString(); return tip; }// w ww. j a v a 2s . co m return v.toString(); }
From source file:de.openity.xmlworks.parsers.ParseXMLTest.java
@Test public void testParse() throws Exception { final ClassPathResource classPathResource = new ClassPathResource("testXMLs/TestRSS.xml"); Collection<RSSEntity> entity = new ParserImpl<RSSEntity>(RSSEntity.class) .parse(classPathResource.getFile()); System.out.println(entity.toString()); System.out.println(entity.size()); }
From source file:net.hamnaberg.json.generator.CollectionGeneratorTest.java
@Test public void canParseGeneratedCollection() throws Exception { List<Item> items = new ArrayList<Item>(); items.add(Item.create(COLLECTION_URI.resolve("item/1"), Arrays.asList(Property.value("one", Optional.of("One"), ValueFactory.createOptionalValue(1))), Collections.<Link>emptyList())); Collection collection = Collection.builder(COLLECTION_URI).addItems(items).build(); String generated = collection.toString(); Collection parsed = new CollectionParser().parse(generated); assertEquals(collection.toString(), parsed.toString()); }