List of usage examples for java.lang System lineSeparator
String lineSeparator
To view the source code for java.lang System lineSeparator.
Click Source Link
From source file:com.datamelt.nifi.processors.ExecuteRuleEngine.java
/** * construct the content for the flow file for the rule engine details. * //from w w w .j a v a 2s .c o m * when the rule engine runs, it produces results per data row and business rules. with 1 data row and 10 rules you get 10 detailed results. these results are output * in one flow file to the details relationship. * * @param header * @param headerPresent * @param outputType * @param row * @return */ private String getFlowFileRuleEngineDetailsContent(HeaderRow header, boolean headerPresent, String outputType, String row) { StringBuffer detailedFlowFileContent = new StringBuffer(); // add the header if there is one if (headerPresent && header != null && header.getNumberOfFields() > 0) { String headerRow = header.getFieldNamesWithSeparator(); detailedFlowFileContent.append(headerRow); // if the header row does not have a line separator at the end then add it if (!headerRow.endsWith(System.lineSeparator())) { detailedFlowFileContent.append(System.lineSeparator()); } } // add the results detailedFlowFileContent.append(getRuleEngineDetails(outputType, row)); return detailedFlowFileContent.toString(); }
From source file:org.apache.hadoop.yarn.client.cli.TopCLI.java
String limitLineLength(String line, int length, boolean addNewline) { if (line.length() > length) { String tmp;// w w w .ja va 2s . com if (addNewline) { tmp = line.substring(0, length - System.lineSeparator().length()); tmp += System.lineSeparator(); } else { tmp = line.substring(0, length); } return tmp; } return line; }
From source file:duthientan.mmanm.com.Main.java
private void BntOpenKeyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BntOpenKeyActionPerformed JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); if (isRSA) { key = selectedFile.getParent(); JLKey.setText(selectedFile.getName()); JFrame frame = new JFrame("ERROR"); JOptionPane.showMessageDialog(frame, key); return; }//w w w . j a v a 2s . c o m if (selectedFile.getName().contains(".txt")) { JLKey.setText(selectedFile.getName()); try { BufferedReader br = new BufferedReader(new FileReader(selectedFile.getPath())); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } key = sb.toString(); JFrame frame = new JFrame("ERROR"); JOptionPane.showMessageDialog(frame, key); } catch (FileNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } else { JFrame frame = new JFrame("ERROR"); JOptionPane.showMessageDialog(frame, "Please Choice File TXT"); } } }
From source file:org.corpus_tools.pepper.connectors.impl.MavenAccessor.java
/** this method recursively computes */ private String getDependencyPrint(DependencyNode startNode, int depth) { StringBuilder dep = new StringBuilder(); // String d = ""; for (int i = 0; i < depth; i++) { // d += " "; dep.append(" "); }//w ww.j a va 2 s . com // d += depth == 0 ? "" : "+- "; dep.append((depth == 0) ? "" : "+- "); // d += // startNode.getArtifact().toString().concat(" // (").concat(startNode.getDependency().getScope()).concat(")"); dep.append(startNode.getArtifact().toString().concat(" (").concat(startNode.getDependency().getScope()) .concat(")")); for (DependencyNode node : startNode.getChildren()) { // d += System.lineSeparator().concat(getDependencyPrint(node, depth // + 1)); dep.append(System.lineSeparator().concat(getDependencyPrint(node, depth + 1))); } // return d; return (dep.toString()); }
From source file:com.datamelt.nifi.processors.ExecuteRuleEngine.java
/** * when the ruleengine ran, a collection of results is available - if the rules passed or failed, how many failed, how many groups failed, * how many actions failed, a message, etc. * // w w w .j a v a 2 s .co m * for a given row of CSV data this method produces one row per business rule. each row will contain information about the rule execution. * * @param outputType the output type configured in the configuration * @param content a row of CSV data * @return the original row multiplied with the number of rules */ private String getRuleEngineDetails(String outputType, String content) { StringBuffer row = new StringBuffer(); // loop over all groups for (int f = 0; f < ruleEngine.getGroups().size(); f++) { // get a rulegroup RuleGroup group = ruleEngine.getGroups().get(f); try { // loop over all subgroups of the group for (int g = 0; g < group.getSubGroups().size(); g++) { RuleSubGroup subgroup = group.getSubGroups().get(g); // get the execution results of the subgroup ArrayList<RuleExecutionResult> results = subgroup.getExecutionCollection().getResults(); // loop over all results for (int h = 0; h < results.size(); h++) { // one result of one rule execution RuleExecutionResult result = results.get(h); // the corresponding rule that was executed XmlRule rule = result.getRule(); // check if rulegroup and rule are according to the output type settings // otherwise we don't need to output the data if (outputType.equals(OUTPUT_TYPE_ALL_GROUPS_ALL_RULES) || (outputType.equals(OUTPUT_TYPE_FAILED_GROUPS_FAILED_RULES) && group.getFailed() == 1 && rule.getFailed() == 1) || (outputType.equals(OUTPUT_TYPE_FAILED_GROUPS_PASSED_RULES) && group.getFailed() == 1 && rule.getFailed() == 0) || outputType.equals(OUTPUT_TYPE_FAILED_GROUPS_ALL_RULES) && group.getFailed() == 1 || (outputType.equals(OUTPUT_TYPE_PASSED_GROUPS_FAILED_RULES) && group.getFailed() == 0 && rule.getFailed() == 1) || (outputType.equals(OUTPUT_TYPE_PASSED_GROUPS_PASSED_RULES) && group.getFailed() == 0 && rule.getFailed() == 0) || (outputType.equals(OUTPUT_TYPE_PASSED_GROUPS_ALL_RULES) && group.getFailed() == 0)) { // append the content row.append(content); // add a separator row.append(separator); // append information about the ruleengine execution to each flow file // so that the rulegroup, subgroup and rule can be identified row.append(group.getId()); row.append(separator); row.append(group.getFailed()); row.append(separator); row.append(subgroup.getId()); row.append(separator); row.append(subgroup.getFailed()); row.append(separator); row.append(subgroup.getLogicalOperatorSubGroupAsString()); row.append(separator); row.append(subgroup.getLogicalOperatorRulesAsString()); row.append(separator); row.append(rule.getId()); row.append(separator); row.append(rule.getFailed()); row.append(separator); // append the resulting ruleengine message of the rule execution row.append(result.getMessage()); // add line separator except last line if (h < results.size() - 1) { row.append(System.lineSeparator()); } } } } } catch (Exception ex) { ex.printStackTrace(); } } return row.toString(); }
From source file:org.apache.hadoop.hive.metastore.MetaStoreUtils.java
private static String getAllThreadStacksAsString() { Map<Thread, StackTraceElement[]> threadStacks = Thread.getAllStackTraces(); StringBuilder sb = new StringBuilder(); for (Map.Entry<Thread, StackTraceElement[]> entry : threadStacks.entrySet()) { Thread t = entry.getKey(); sb.append(System.lineSeparator()); sb.append("Name: ").append(t.getName()).append(" State: ").append(t.getState()); addStackString(entry.getValue(), sb); }//from w ww . j a va2 s. com return sb.toString(); }
From source file:org.apache.hadoop.hive.metastore.MetaStoreUtils.java
private static void addStackString(StackTraceElement[] stackElems, StringBuilder sb) { sb.append(System.lineSeparator()); for (StackTraceElement stackElem : stackElems) { sb.append(stackElem).append(System.lineSeparator()); }//from ww w. j a va2 s .c o m }
From source file:ezbake.services.provenance.graph.GraphDb.java
public void updatePurge(ezbake.base.thrift.EzSecurityToken securityToken, long purgeId, Set<Long> completelyPurged, String note, boolean resolved) throws ProvenancePurgeIdNotFoundException, ProvenanceDocumentNotInPurgeException, org.apache.thrift.TException { validateGraphDb();//from w w w . jav a 2 s .co m try { FramedGraph<TitanGraph> framedGraph = getFramedGraph(); // check if vertex exists Iterator<PurgeEvent> it = framedGraph.query().has(PurgeEvent.PurgeId, purgeId) .vertices(PurgeEvent.class).iterator(); if (!it.hasNext()) { this.graph.rollback(); throw new ProvenancePurgeIdNotFoundException( String.format("Purge Event with id %d not found", purgeId)); } PurgeEvent event = it.next(); if (!event.getPurgeDocumentIds().containsAll(completelyPurged)) { this.graph.rollback(); throw new ProvenanceDocumentNotInPurgeException( "Document not found in PurgeEvent vertex's PurgeDocumentIds"); } // combine the existing completed set with the new one Set<Long> complelted = event.getCompletelyPurgedDocumentIds(); complelted.addAll(completelyPurged); event.setCompletelyPurgedDocumentIds(complelted); event.setResolved(resolved); // format description as // description \n\nNote: <timestamp> <applicationId> <userPrincipal>\n note if (StringUtils.isNotEmpty(note)) { StringBuilder sb = new StringBuilder(); String description = event.getDescription(); if (StringUtils.isNotEmpty(description)) { sb.append(description); sb.append(System.lineSeparator()); sb.append(System.lineSeparator()); } sb.append("Note: "); sb.append(Utils.getCurrentDate().toString()); sb.append(" "); sb.append(Utils.getApplication(securityToken)); sb.append(" "); sb.append(Utils.getUser(securityToken)); sb.append(System.lineSeparator()); sb.append(note); event.setDescription(sb.toString()); } this.graph.commit(); } catch (TitanException ex) { this.graph.rollback(); throw new TException(ex); } }
From source file:org.apache.openaz.xacml.admin.components.PolicyWorkspace.java
protected void renamePolicyFile(File sourceFile, File dest, File parent) { try {//w w w . java 2 s . c o m if (sourceFile.renameTo(dest)) { this.treeContainer.setParent(sourceFile, parent); this.treeContainer.updateItem(parent); } } catch (Exception e) { String error = "Failed to rename " + sourceFile + " to: " + dest + System.lineSeparator() + e.getLocalizedMessage(); logger.error(error); AdminNotification.error(error); } }
From source file:org.apache.pulsar.io.PulsarFunctionE2ETest.java
public static String getPrometheusMetrics(int metricsPort) throws IOException { StringBuilder result = new StringBuilder(); URL url = new URL( String.format("http://%s:%s/metrics", InetAddress.getLocalHost().getHostAddress(), metricsPort)); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line;//from w w w. j a va2 s .c o m while ((line = rd.readLine()) != null) { result.append(line + System.lineSeparator()); } rd.close(); return result.toString(); }