List of usage examples for java.util List toString
public String toString()
From source file:Anaphora_Resolution.ParseAllXMLDocuments.java
@SuppressWarnings("rawtypes") public static ArrayList<List> preprocess(DocumentPreprocessor strarray) { ArrayList<List> Result = new ArrayList<List>(); for (List<HasWord> sentence : strarray) { if (!StringUtils.isAsciiPrintable(sentence.toString())) { continue; // Removing non ASCII printable sentences }// w w w.j a va 2 s .c o m //string = StringEscapeUtils.escapeJava(string); //string = string.replaceAll("([^A-Za-z0-9])", "\\s$1"); int nonwords_chars = 0; int words_chars = 0; for (HasWord hasword : sentence) { String next = hasword.toString(); if ((next.length() > 30) || (next.matches("[^A-Za-z]"))) nonwords_chars += next.length(); // Words too long or non alphabetical will be junk else words_chars += next.length(); } if ((nonwords_chars / (nonwords_chars + words_chars)) > 0.5) // If more than 50% of the string is non-alphabetical, it is going to be junk continue; // Working on a character-basis because some sentences may contain a single, very long word if (sentence.size() > 100) { System.out.println("\tString longer than 100 words!\t" + sentence.toString()); continue; } Result.add(sentence); } return Result; }
From source file:org.smartloli.kafka.eagle.common.util.TestHttpClientUtils.java
/** * send single user.//from www .j a v a 2 s . c o m * * @param mobiles * @param text */ public static void sendMarkdownToDingDing(String title, String text, List<String> mobiles) { Map<String, Object> dingDingMarkdownMessage = getDingDingMarkdownMessage(title, text, mobiles); HttpPost httpPost = createHttpPost(dingDingMarkdownMessage); if (httpPost == null) { return; } LOG.info("send mark down message to ding ding. title:{}, mobiles:{}, text:{}", title, mobiles.toString(), text); executeAndGetResponse(httpPost); }
From source file:cz.muni.fi.editor.database.test.helpers.AbstractDAOTest.java
protected static void checkMethods(Class testClass, Class testingInterface) { Set<String> testMethods = new HashSet<>(); for (Method m : testClass.getDeclaredMethods()) { if (m.isAnnotationPresent(Test.class)) { testMethods.add(m.getName()); }//from w ww . j av a 2 s . c o m } List<String> targetMethods = new ArrayList<>( Arrays.asList("create", "update", "getById", "delete", "getAll", "getClassType")); targetMethods.addAll(new ArrayList<>(Arrays.asList(testingInterface.getDeclaredMethods())).stream() .map(m -> m.getName()).collect(Collectors.toList())); testMethods.forEach(targetMethods::remove); Assert.assertEquals("Following method(s) are missing in DAO test :" + targetMethods.toString(), 0, targetMethods.size()); }
From source file:com.projecttango.examples.java.floorplan.PlanBuilder.java
/** * Converts wall measurements to string. * * @param wallMeasurementList//from w ww . j a va 2 s .c o m * @return String */ public static String toString(List<WallMeasurement> wallMeasurementList) { List<String> planPoints = new ArrayList<String>(); if (!wallMeasurementList.isEmpty()) { for (WallMeasurement wallMeasurement : wallMeasurementList) { float[] openGlWall = wallMeasurement.getPlaneTransform(); float[] measurementPoint = new float[] { openGlWall[12], openGlWall[13], openGlWall[14] }; planPoints.add(Arrays.toString(measurementPoint)); } } return planPoints.toString(); }
From source file:gmailclientfx.core.GmailClient.java
public static MyMessage fetchMessage(MimeMessage m, int tblIndex, String lbl) { MyMessage myMsg = null;//from w ww .j a v a 2 s . co m try { MimeMessage msg = new MimeMessage(m); MimeMessageParser parser = new MimeMessageParser(msg); parser.parse(); String naslov = parser.getSubject(); String from = parser.getFrom(); List<Address> to = parser.getTo();//msg.getRecipients(javax.mail.Message.RecipientType.TO); String toStr = to.toString().replace("[", "").replace("]", ""); if (toStr.equals("")) toStr = GmailClient.getEmail(); String body = ""; if (parser.hasHtmlContent()) body = parser.getHtmlContent(); else body = parser.getPlainContent(); String date = msg.getSentDate().toString(); String label = lbl; myMsg = new MyMessage(User.getUserId(GmailClient.getEmail()), naslov, from, toStr, body, date, label); myMsg.setTblId(tblIndex); } catch (MessagingException ex) { Logger.getLogger(GmailClient.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(GmailClient.class.getName()).log(Level.SEVERE, null, ex); } return myMsg; }
From source file:com.google.code.joliratools.bind.apt.JAXROProcessorJSONTest.java
private static void assertEverythingExeptSchema(final Compilation compilation, final String schemaDocument) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (schemaDocument == null || schemaDocument.length() < 10) { fail("generation failed:\n" + schemaDocument); }/*from ww w .java 2 s.c o m*/ System.out.println(schemaDocument); final String genCustAdapter = compilation.getGeneratedSource(CUSTOMER_NAME + ADAPTER_POSTFIX); System.out.println(genCustAdapter); final String genAccontArrayAdapter = compilation .getGeneratedSource(ACCOUNT_NAME + ArrayEntity.POST_FIX + ADAPTER_POSTFIX); System.out.println(genAccontArrayAdapter); final List<Diagnostic<? extends JavaFileObject>> diagnostics = compilation.getDiagnostics(); assertEquals(diagnostics.toString(), 2, diagnostics.size()); final String genStringCollectionAdapter = compilation .getGeneratedSource("java.lang.String" + CollectionEntity.POST_FIX + ADAPTER_POSTFIX); System.out.println(genStringCollectionAdapter); final String genCustomerArrayAdapter = compilation .getGeneratedSource(CUSTOMER_NAME + ArrayEntity.POST_FIX + ADAPTER_POSTFIX); System.out.println(genCustomerArrayAdapter); final Compilation _compilation = new Compilation(compilation); load(EXECUTOR_NAME, _compilation); _compilation.doCompile(new PrintWriter(System.out), "-proc:none"); final List<Diagnostic<? extends JavaFileObject>> _diagnostics = _compilation.getDiagnostics(); assertEquals(_diagnostics.toString(), 0, _diagnostics.size()); final Class<?> executorCls = _compilation.getOutputClass(EXECUTOR_NAME); final Method executeMethod = executorCls.getMethod("execute"); final String instanceDocument = (String) executeMethod.invoke(null); System.out.println(instanceDocument); final JSONTokener tokener = new JSONTokener(instanceDocument); assertNotNull(tokener); // assertSchemaInstance(instanceDocument); }
From source file:it.cnr.isti.thematrix.scripting.sys.DatasetSchema.java
/** * Check if a set of attributes can be added to a dataset without duplication in the Schema, return null if no * issues are found. The method checks both duplication with the existing schema and duplicate name in the list of * attributes to be added. If passed a null or empty list of attributes, the method will warn in the logs but return * true. A detailed error message is returned if issues are found. * * @param schema/*from ww w.j a va 2s . co m*/ * the schema to extend * @param newAttributes * the List of new attributes as Symbol<?> * @return either a String with detailed error messages about all conflicting new attributes, or null if there are * none. */ public static String canExtend(DatasetSchema schema, List<Symbol<?>> newAttributes) { if (newAttributes == null || newAttributes.size() == 0) { LogST.logP(0, "WARNING DatasetSchema.canExtend() called with empty or null newAttributes"); return null; } String result = null; List<String> duplicates = new ArrayList<String>(); for (Symbol<?> attribute : newAttributes) { if (schema.containsKey(attribute.name)) duplicates.add(attribute.name); } if (duplicates.size() > 0) result = " new attributes duplicate existing attributes: " + duplicates.toString() + ";"; /** * sort the List of new attributes, so that we can check with the existing ones and between them. * We copy the list for sorting it, but we do not modify its elements. * FIXME the comparator for Symbol<?> should be in Symbol **/ ArrayList<Symbol<?>> copyNewAttributes = new ArrayList(newAttributes); Collections.sort(copyNewAttributes, new Comparator<Symbol<?>>() { public int compare(Symbol<?> s1, Symbol<?> s2) { return s1.name.compareTo(s2.name); } }); Iterator<Symbol<?>> i = copyNewAttributes.iterator(); Symbol<?> s = i.next(); // we know the list is not empty Symbol<?> prev = null; duplicates.clear(); while (i.hasNext()) { prev = s; s = i.next(); if (s.name.equals(prev.name)) duplicates.add(s.name); } if (duplicates.size() > 0) { if (result == null) result = ""; result = result + " new attributes duplicate each other: " + duplicates.toString() + ";"; } return result == null ? null : "DatasetSchema : " + result; }
From source file:com.github.pitzcarraldo.openjpeg.OpenJPEGLoader.java
/** * Method to load a JP2 file using OpenJPEG executable * @param pFile jp2 file to load/* w ww . j a v a2 s . com*/ * @return decoded buffered image from file */ private static BufferedImage loadJP2_Executable(File pFile) { logger.trace("executable decoder: " + pFile.getAbsolutePath()); File tempOutput = null; try { tempOutput = File.createTempFile("dissimilar_" + pFile.getName() + "_", ".tif"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //FIXME: null check? tempOutput.deleteOnExit(); List<String> commandLine = new LinkedList<String>(); commandLine.add(OPENJPEGEXE.getAbsolutePath()); commandLine.add("-i"); commandLine.add(pFile.getAbsolutePath()); commandLine.add("-o"); commandLine.add(tempOutput.getAbsolutePath()); logger.trace("running: " + commandLine.toString()); ToolRunner runner = new ToolRunner(true); int exitCode = 0; try { exitCode = runner.runCommand(commandLine); logger.trace("exit code: " + exitCode); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (exitCode != 0) { //some error BufferedReader log = runner.getStdout(); try { while (log.ready()) { logger.error("log: " + log.readLine()); } } catch (IOException e) { } } else { try { BufferedImage image = Imaging.getBufferedImage(tempOutput); //force a delete tempOutput.delete(); return image; } catch (ImageReadException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
From source file:cc.kune.core.server.manager.file.FileDownloadManagerUtils.java
/** * Gets the input stream in resource bases. * //from w w w . j a v a2 s . c om * @param resourceBases * the resource bases * @param filename * the filename * @return the input stream in resource bases */ public static InputStream getInputStreamInResourceBases(final List<String> resourceBases, final String filename) { InputStream in = null; final File icon = searchFileInResourceBases(resourceBases, filename); try { if (icon != null) { in = new BufferedInputStream(new FileInputStream(icon)); } } catch (final FileNotFoundException e) { LOG.error(String.format("Cannot read filename: %s in %s", filename, resourceBases.toString())); } return in; }
From source file:com.anhth12.lambda.app.ml.als.ALSUpdate.java
private static void addIDsExtentions(PMML pmml, String key, JavaPairRDD<Integer, double[]> feature, Map<Integer, String> reverseIDMaping) { List<Integer> hashedIDs = feature.keys().collect(); List<String> ids = new ArrayList<>(hashedIDs.size()); for (Integer hashedID : hashedIDs) { String originalId = reverseIDMaping.get(hashedID); ids.add(originalId == null ? hashedIDs.toString() : originalId); }// ww w . j a v a 2s . c o m AppPMMLUtils.addExtensionContent(pmml, key, ids); }