List of usage examples for com.google.common.base Strings repeat
public static String repeat(String string, int count)
From source file:net.sourceforge.vaticanfetcher.build.BuildMain.java
private static void runTests() { Util.println("Running tests..."); final List<String> classNames = new ArrayList<String>(); new FileWalker() { protected void handleFile(File file) { String name = file.getName(); if (!name.endsWith(".java")) return; name = Util.splitFilename(name)[0]; if (!name.startsWith("Test") && !name.endsWith("Test")) return; String path = file.getPath(); int start = "src/".length(); int end = path.length() - ".java".length(); path = path.substring(start, end); path = path.replace("/", ".").replace("\\", "."); if (path.equals(TestFiles.class.getName())) return; classNames.add(path);/*w w w. j av a 2s. c o m*/ } }.run(new File("src")); Collections.sort(classNames); JUnitCore junit = new JUnitCore(); junit.addListener(new RunListener() { public void testFailure(Failure failure) throws Exception { Util.printErr(Strings.repeat(" ", 8) + "FAILED"); } }); for (String className : classNames) { /* * AppUtil.Const must be cleared before each test, otherwise one test class could load * AppUtil.Const and thereby hide AppUtil.Const loading failures in subsequent tests. */ AppUtil.Const.clear(); try { Class<?> clazz = Class.forName(className); Util.println(Strings.repeat(" ", 4) + className); junit.run(clazz); } catch (ClassNotFoundException e) { Util.printErr(e); } } AppUtil.Const.clear(); }
From source file:edu.buaa.satla.analysis.core.MainCPAStatistics.java
private void printSubStatistics(PrintStream out, Result result, ReachedSet reached) { assert reached != null : "ReachedSet may be null only if analysis not yet started"; for (Statistics s : subStats) { String name = s.getName(); if (!Strings.isNullOrEmpty(name)) { name = name + " statistics"; out.println(name);//from w w w . j ava 2 s. c o m out.println(Strings.repeat("-", name.length())); } try { s.printStatistics(out, result, reached); } catch (OutOfMemoryError e) { logger.logUserException(Level.WARNING, e, "Out of memory while generating statistics and writing output files"); } if (!Strings.isNullOrEmpty(name)) { out.println(); } } }
From source file:ox.softeng.burst.grails.plugin.exception.BurstException.java
protected String buildCauseMessage(Throwable cause, int indent) { if (cause != null) { return "\n" + Strings.repeat(" ", indent) + "- " + cause.toString() + buildCauseMessage(cause.getCause(), indent + 2); }/*from ww w . j a v a 2 s . co m*/ return ""; }
From source file:com.chiorichan.permission.Permission.java
public void debugPermissionStack(int deepth) { String spacing = (deepth > 0) ? Strings.repeat(" ", deepth - 1) + "|---> " : ""; if (value == null) PermissionManager.getLogger().info(ConsoleColor.YELLOW + spacing + getLocalName()); else/*www.j av a 2 s .c o m*/ PermissionManager.getLogger() .info(ConsoleColor.YELLOW + spacing + getLocalName() + "=" + value.toString()); deepth++; for (Permission p : children) { p.debugPermissionStack(deepth); } }
From source file:com.google.googlejavaformat.java.javadoc.JavadocWriter.java
private void appendSpaces(int count) { output.append(Strings.repeat(" ", count)); }
From source file:org.eclipse.elk.layered.JsonDebugUtil.java
/** * Ends the list of child nodes./*w w w.ja va2 s. com*/ * * @param writer * writer to write to. * @param indentation * the indentation level to use. * @throws IOException * if anything goes wrong with the writer. */ private static void endChildNodeList(final Writer writer, final int indentation) throws IOException { writer.write("\n" + Strings.repeat(INDENT, indentation) + "],\n"); }
From source file:org.apache.drill.PlanTestBase.java
private static String getPrefixJoinOrderFromPlan(String plan, String joinKeyWord, String scanKeyWord) { final StringBuilder builder = new StringBuilder(); final String[] planLines = plan.split("\n"); int cnt = 0;// w w w. jav a 2 s . c om final Stack<Integer> s = new Stack<>(); for (final String line : planLines) { if (line.trim().isEmpty()) { continue; } if (line.contains(joinKeyWord)) { builder.append(Strings.repeat(" ", 2 * s.size())); builder.append(joinKeyWord + "\n"); cnt++; s.push(cnt); cnt = 0; continue; } if (line.contains(scanKeyWord)) { cnt++; builder.append(Strings.repeat(" ", 2 * s.size())); builder.append(line.trim() + "\n"); if (cnt == 2) { cnt = s.pop(); } } } return builder.toString(); }
From source file:io.prestosql.sql.TreePrinter.java
private void print(Integer indentLevel, String value) { out.println(Strings.repeat(INDENT, indentLevel) + value); }
From source file:org.corpus_tools.peppermodules.annis.Salt2ANNISMapper.java
@Override public DOCUMENT_STATUS mapSDocument() { this.preorderTable = new ConcurrentHashMap<>(); this.postorderTable = new ConcurrentHashMap<>(); prePostOrder = 0l;/*from w w w . j a v a 2 s . c om*/ numberOfMappedNodes.set(0); if (this.getDocument() == null || this.getDocument().getDocumentGraph() == null) { throw new PepperModuleException(this, "Cannot map sDocumentGraph, because sDocumentGraph is null."); } {//start traversion of documentStructure try { if (this.getDocument().getDocumentGraph().getNodes() != null) { this.numberOfDocumentNodes = this.getDocument().getDocumentGraph().getNodes().size(); } /** * traverse by SpanningRelations: DOCUMENT_STRUCTURE_CR * DominanceRelations: DOCUMENT_STRUCTURE_DR PointingRelations: * DOCUMENT_STRUCTURE_PR * * DominanceRelations Subcomponents: DOCUMENT_STRUCTURE_DR_SUB * PointingRelations Subcomponents: DOCUMENT_STRUCTURE_PR_SUB * * Dominance relations may consist of different subcomponents since * there are "edge" and "secedge" types * * Since every root node has it's own component, the pre and post order * needs to be 0 for the root node. You need to handle this. */ List<? extends SNode> sRelationRoots; Multimap<String, SNode> subComponentRoots; // Map<String, List<SNode>> subComponentRoots; Map<SToken, Long> token2Index = calculateToken2Index(getDocument().getDocumentGraph()); // START Step 1: map SOrderRelation subComponentRoots = this.getDocument().getDocumentGraph() .getRootsByRelationType(SALT_TYPE.SORDER_RELATION); if (subComponentRoots != null) { if (subComponentRoots.size() > 0) { for (Entry<String, SNode> entry : subComponentRoots.entries()) { SRelation2ANNISMapper sOrderRelationMapper = new SOrderRelation2ANNISMapper( getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); String traversionType = entry.getKey(); if (SaltUtil.SALT_NULL_VALUE.equals(traversionType)) { traversionType = "default_seg"; } sOrderRelationMapper.setTraversionSType(traversionType); sOrderRelationMapper.mapSRelations2ANNIS(subComponentRoots.get(entry.getKey()), SALT_TYPE.SORDER_RELATION, null); } } } // END Step 1: map SOrderRelation // also map the timeline (by creating a virtual tokenization if necessary) STimelineRelation2ANNISMapper timelineMapper = new STimelineRelation2ANNISMapper(getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this, mergeTextsWithTimeline); timelineMapper.run(); // START Step 2: map SText if (idManager.hasVirtualTokenization()) { Long sDocID; Long textId = 0l; String sDocumentElementId = this.getDocument().getId(); if (sDocumentElementId == null) { throw new PepperModuleException(this, "SId Id of the document '" + this.getDocument().getName() + "' is NULL!"); } sDocID = this.idManager.getNewCorpusTabId(sDocumentElementId); String textName = "sText0"; String textContent = Strings.repeat(" ", idManager.getNumberOfVirtualToken()); ArrayList<String> tuple = new ArrayList<>(); tuple.add(sDocID.toString()); tuple.add(textId.toString()); tuple.add(textName); tuple.add(textContent); long transactionId = tw_text.beginTA(); try { tw_text.addTuple(transactionId, tuple); tw_text.commitTA(transactionId); } catch (FileNotFoundException e) { tw_text.abortTA(transactionId); throw new PepperModuleException(this, "Could not write to the node.tab, exception was" + e.getMessage()); } } else { this.mapSText(); } ExecutorService exec = null; if (mapRelationsInParallel) { exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); } subComponentRoots = getDocument().getDocumentGraph() .getRootsByRelationType(SALT_TYPE.SPOINTING_RELATION); if (subComponentRoots != null) { //System.out.println("The Pointing relation graphs have "+ subComponentRoots.size() + " STypes."); if (subComponentRoots.size() > 0) { for (String key : subComponentRoots.keySet()) { //System.out.println("Count of PR roots for key "+key+" : "+subComponentRoots.get(key).size()); //System.out.println("Mapping PointingRelation subcomponents with sType: "+key); SRelation2ANNISMapper sPointingSubRelationMapper = new SPointingRelation2ANNISMapper( getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); sPointingSubRelationMapper.mapSRelations2ANNIS(subComponentRoots.get(key), SALT_TYPE.SPOINTING_RELATION, TRAVERSION_TYPE.DOCUMENT_STRUCTURE_PR); sPointingSubRelationMapper.setTraversionSType(key); if (exec != null) { exec.execute(sPointingSubRelationMapper); } else { sPointingSubRelationMapper.run(); } } } else { //System.out.println("No PointingRelation components found (null map)"); } } else { //System.out.println("No PointingRelation components found (empty map)"); } // END Step 2: map SPointingRelations // START Step 3: map SDominanceRelations sRelationRoots = this.getDocument().getDocumentGraph() .getRootsByRelation(SALT_TYPE.SDOMINANCE_RELATION); if (sRelationRoots != null) { if (sRelationRoots.size() > 0) { SRelation2ANNISMapper sDominanceRelationMapper = new SDominanceRelation2ANNISMapper( getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); sDominanceRelationMapper.mapSRelations2ANNIS(sRelationRoots, SALT_TYPE.SDOMINANCE_RELATION, TRAVERSION_TYPE.DOCUMENT_STRUCTURE_DR); if (exec != null) { exec.execute(sDominanceRelationMapper); } else { sDominanceRelationMapper.run(); } } } // END Step 3: map SDominanceRelations // START Step 3.1 : map the subComponents of the SDominanceRelations subComponentRoots = getDocument().getDocumentGraph() .getRootsByRelationType(SALT_TYPE.SDOMINANCE_RELATION); if (subComponentRoots != null) { //System.out.println("The Dominance relation graphs have "+ subComponentRoots.size() + " STypes."); if (subComponentRoots.size() > 0) { Set<String> domComponentTypeNames = subComponentRoots.keySet(); // only output the named relation types if there the user has not choosen // to include them or if there are more than 1 named types if (!((ANNISExporterProperties) this.getProperties()).getExcludeSingleDomType() || domComponentTypeNames.size() >= 2) { for (String key : domComponentTypeNames) { if (!SaltUtil.SALT_NULL_VALUE.equals(key)) { SRelation2ANNISMapper sDominanceSubRelationMapper = new SDominanceRelation2ANNISMapper( getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); sDominanceSubRelationMapper.setTraversionSType(key); sDominanceSubRelationMapper.mapSRelations2ANNIS(subComponentRoots.get(key), SALT_TYPE.SDOMINANCE_RELATION, TRAVERSION_TYPE.DOCUMENT_STRUCTURE_DR); if (exec != null) { exec.execute(sDominanceSubRelationMapper); } else { sDominanceSubRelationMapper.run(); } } } } } else { //System.out.println("No DominanceRelation subcomponents found (null map)"); } } else { //System.out.println("No DominanceRelation subcomponents found (empty map)"); } // END Step 3.1 : map the subComponents of the SDominanceRelations // START Step 4: map SSpanningrelations sRelationRoots = this.getDocument().getDocumentGraph() .getRootsByRelation(SALT_TYPE.SSPANNING_RELATION); if (sRelationRoots != null) { if (sRelationRoots.size() > 0) { SRelation2ANNISMapper spanningRelationMapper = new SSpanningRelation2ANNISMapper( getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); spanningRelationMapper.mapSRelations2ANNIS(sRelationRoots, SALT_TYPE.SSPANNING_RELATION, TRAVERSION_TYPE.DOCUMENT_STRUCTURE_CR); if (exec != null) { exec.execute(spanningRelationMapper); } else { spanningRelationMapper.run(); } } } // END Step 4: map SSpanningrelations // START Step 5: map SMedialRelations sRelationRoots = this.getDocument().getDocumentGraph().getTokens(); if (sRelationRoots != null) { if (sRelationRoots.size() > 0) { SRelation2ANNISMapper audioRelationMapper = new Audio2ANNISMapper(getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); audioRelationMapper.mapSRelations2ANNIS(sRelationRoots, SALT_TYPE.STIME_OVERLAPPING_RELATION, TRAVERSION_TYPE.DOCUMENT_STRUCTURE_AUDIO); if (exec != null) { exec.execute(audioRelationMapper); } else { audioRelationMapper.run(); } } } // END Step 5: map SMedialRelations if (exec != null) { exec.shutdown(); while (!exec.awaitTermination(60, TimeUnit.SECONDS)) { // wait to finish } } // START Step 6: map all SToken which were not mapped, yet SRelation2ANNISMapper mapper = new SSpanningRelation2ANNISMapper(getIdManager(), getDocument().getDocumentGraph(), token2Index, tw_node, tw_nodeAnno, tw_rank, tw_edgeAnno, tw_component, this); mapper.beginTransaction(); for (SNode node : getDocument().getDocumentGraph().getTokens()) { if (this.idManager.getVirtualisedSpanId(node.getId()) == null) { mapper.mapSNode(node); } } mapper.commitTransaction(); // END Step 6: map all SToken which were not mapped, yet } catch (PepperModuleException e) { throw new PepperModuleException(this, "Some error occurs while traversing document structure graph.", e); } catch (InterruptedException e) { throw new PepperModuleException(this, "Some error occurs while traversing document structure graph.", e); } } //start traversion of corpus structure mergeLocalStatsIntoGlobal(); setProgress(1.0); return DOCUMENT_STATUS.COMPLETED; }
From source file:org.sosy_lab.cpachecker.core.algorithm.termination.TerminationStatistics.java
@Override public void printStatistics(PrintStream pOut, Result pResult, ReachedSet pReached) { pOut.println("Total time : " + totalTime); pOut.println("Time for recursion analysis: " + recursionTime); pOut.println();// ww w .ja v a2 s . c om int loops = analysedLoops.size(); pOut.println("Number of analysed loops: " + valueWithPercentage(loops, totalLoops)); pOut.println("Total time for loop analysis: " + loopTime); pOut.println(" Avg time per loop analysis: " + format(loopTime.getAvgTime())); pOut.println(" Max time per loop analysis: " + format(loopTime.getMaxTime())); pOut.println(); int safetyAnalysisRuns = safetyAnalysisRunsPerLoop.values().stream().mapToInt(AtomicInteger::get).sum(); assert safetyAnalysisRuns == safetyAnalysisTime.getNumberOfIntervals(); int maxSafetyAnalysisRuns = safetyAnalysisRunsPerLoop.values().stream().mapToInt(AtomicInteger::get).max() .orElse(0); String loopsWithMaxSafetyAnalysisRuns = safetyAnalysisRunsPerLoop.entrySet().stream() .filter(e -> e.getValue().get() == maxSafetyAnalysisRuns).map(Entry::getKey) .map(l -> l.getLoopHeads().toString()).collect(Collectors.joining(", ")); pOut.println("Number of safety analysis runs: " + format(safetyAnalysisRuns)); if (loops > 0) { pOut.println(" Avg safety analysis run per loop: " + div(safetyAnalysisRuns, loops)); } pOut.println(" Max safety analysis run per loop: " + format(maxSafetyAnalysisRuns) + " \t for loops " + loopsWithMaxSafetyAnalysisRuns); pOut.println("Total time for safety analysis: " + safetyAnalysisTime); pOut.println( " Avg time per safety analysis run: " + format(safetyAnalysisTime.getAvgTime())); pOut.println( " Max time per safety analysis run: " + format(safetyAnalysisTime.getMaxTime())); pOut.println(); int iterations = lassoTime.getNumberOfIntervals(); int lassos = lassosPerLoop.values().stream().mapToInt(AtomicInteger::get).sum(); int maxLassosPerLoop = lassosPerLoop.values().stream().mapToInt(AtomicInteger::get).max().orElse(0); String loopsWithMaxLassos = lassosPerLoop.entrySet().stream() .filter(e -> e.getValue().get() == maxLassosPerLoop).map(Entry::getKey) .map(l -> l.getLoopHeads().toString()).collect(Collectors.joining(", ")); pOut.println("Number of analysed lassos: " + format(lassos)); if (loops > 0) { pOut.println(" Avg number of lassos per loop: " + div(lassos, loops)); } pOut.println(" Max number of lassos per loop: " + format(maxLassosPerLoop) + " \t for loops " + loopsWithMaxLassos); if (loops > 0) { pOut.println(" Avg number of lassos per iteration: " + div(lassos, iterations)); } pOut.println(" Max number of lassos per iteration: " + format(maxLassosPerIteration.get())); pOut.println(); pOut.println("Total time for lassos analysis: " + lassoTime); pOut.println(" Avg time per iteration: " + format(lassoTime.getAvgTime())); pOut.println(" Max time per iteration: " + format(lassoTime.getMaxTime())); pOut.println(" Time for lassos construction: " + lassoConstructionTime); pOut.println(" Avg time for lasso construction per iteration: " + format(lassoConstructionTime.getAvgTime())); pOut.println(" Max time for lasso construction per iteration: " + format(lassoConstructionTime.getMaxTime())); pOut.println(" Total time for non-termination analysis: " + lassoNonTerminationTime); pOut.println(" Avg time for non-termination analysis per lasso:" + format(lassoNonTerminationTime.getAvgTime())); pOut.println(" Max time for non-termination analysis per lasso:" + format(lassoNonTerminationTime.getMaxTime())); pOut.println(" Total time for termination analysis: " + lassoTerminationTime); pOut.println( " Avg time for termination analysis per lasso: " + format(lassoTerminationTime.getAvgTime())); pOut.println( " Max time for termination analysis per lasso: " + format(lassoTerminationTime.getMaxTime())); pOut.println(); int totoalTerminationArguments = terminationArguments.size(); int maxTerminationArgumentsPerLoop = terminationArguments.asMap().values().stream() .mapToInt(Collection::size).max().orElse(0); String loopsWithMaxTerminationArguments = terminationArguments.asMap().entrySet().stream() .filter(e -> e.getValue().size() == maxTerminationArgumentsPerLoop).map(Entry::getKey) .map(l -> l.getLoopHeads().toString()).collect(Collectors.joining(", ")); pOut.println("Total number of termination arguments: " + format(totoalTerminationArguments)); if (loops > 0) { pOut.println(" Avg termination arguments per loop: " + div(totoalTerminationArguments, loops)); } pOut.println(" Max termination arguments per loop: " + format(maxTerminationArgumentsPerLoop) + " \t for loops " + loopsWithMaxTerminationArguments); pOut.println(); Map<String, Integer> terminationArguementTypes = Maps.newHashMap(); for (TerminationArgument terminationArgument : terminationArguments.values()) { String name = terminationArgument.getRankingFunction().getName(); terminationArguementTypes.merge(name, 1, Integer::sum); } for (Entry<String, Integer> terminationArgument : terminationArguementTypes.entrySet()) { String name = terminationArgument.getKey(); String whiteSpaces = Strings.repeat(" ", 49 - name.length()); pOut.println(" " + name + ":" + whiteSpaces + format(terminationArgument.getValue())); } exportSynthesizedArguments(); }