List of usage examples for java.lang Appendable append
Appendable append(char c) throws IOException;
From source file:com.bigml.histogram.GroupTarget.java
@Override protected void appendTo(final Appendable appendable, final DecimalFormat format) throws IOException { if (appendable == null) { throw new NullPointerException("appendable must not be null"); }/* w ww . j av a 2 s. c o m*/ if (format == null) { throw new NullPointerException("format must not be null"); } for (Target target : _target) { target.appendTo(appendable, format); appendable.append("\t"); } }
From source file:ch.algotrader.simulation.SimulationResultFormatter.java
public void formatShort(final Appendable buffer, final SimulationResultVO resultVO) throws IOException { PerformanceKeysVO performanceKeys = resultVO.getPerformanceKeys(); MaxDrawDownVO maxDrawDownVO = resultVO.getMaxDrawDown(); if (resultVO.getAllTrades().getCount() == 0) { buffer.append("no trades took place!"); return;//from w w w .j a v a2 s.co m } Collection<PeriodPerformanceVO> periodPerformanceVOs = resultVO.getMonthlyPerformances(); double maxDrawDownM = 0d; double bestMonthlyPerformance = Double.NEGATIVE_INFINITY; if ((periodPerformanceVOs != null)) { for (PeriodPerformanceVO PeriodPerformanceVO : periodPerformanceVOs) { maxDrawDownM = Math.min(maxDrawDownM, PeriodPerformanceVO.getValue()); bestMonthlyPerformance = Math.max(bestMonthlyPerformance, PeriodPerformanceVO.getValue()); } } buffer.append("avgY=" + twoDigitFormat.format(performanceKeys.getAvgY() * 100.0) + "%"); buffer.append(" stdY=" + twoDigitFormat.format(performanceKeys.getStdY() * 100) + "%"); buffer.append(" sharpe=" + twoDigitFormat.format(performanceKeys.getSharpeRatio())); buffer.append(" maxDDM=" + twoDigitFormat.format(-maxDrawDownM * 100) + "%"); buffer.append(" bestMP=" + twoDigitFormat.format(bestMonthlyPerformance * 100) + "%"); buffer.append(" maxDD=" + twoDigitFormat.format(maxDrawDownVO.getAmount() * 100.0) + "%"); buffer.append(" maxDDPer=" + twoDigitFormat.format(maxDrawDownVO.getPeriod() / 86400000)); buffer.append(" winTrds=" + resultVO.getWinningTrades().getCount()); buffer.append( " winTrdsPct=" + twoDigitFormat.format( 100.0 * resultVO.getWinningTrades().getCount() / resultVO.getAllTrades().getCount()) + "%"); buffer.append(" avgPPctWin=" + twoDigitFormat.format(resultVO.getWinningTrades().getAvgProfitPct() * 100.0) + "%"); buffer.append(" losTrds=" + resultVO.getLoosingTrades().getCount()); buffer.append( " losTrdsPct=" + twoDigitFormat.format( 100.0 * resultVO.getLoosingTrades().getCount() / resultVO.getAllTrades().getCount()) + "%"); buffer.append(" avgPPctLoos=" + twoDigitFormat.format(resultVO.getLoosingTrades().getAvgProfitPct() * 100.0) + "%"); buffer.append(" totalTrds=" + resultVO.getAllTrades().getCount()); for (Map.Entry<String, Object> entry : resultVO.getStrategyResults().entrySet()) { buffer.append(" " + entry.getKey() + "=" + entry.getValue()); } }
From source file:org.efaps.wikiutil.export.latex.WikiPage2Tex.java
/** * * @param _out appendable instance to the Latex file * @param _paragraphs list of paragraphs to append * @throws IOException if write failed/*www. j av a 2 s.c om*/ */ protected void appendParagraph(final Appendable _out, final AbstractParagraphList<?> _paragraphs) throws IOException { for (final Paragraph paragraph : _paragraphs.getParagraphs()) { _out.append("\n\n"); for (final AbstractLineElement element : paragraph.getElements()) { this.appendLineElement(_out, element); } } }
From source file:org.efaps.wikiutil.export.latex.WikiPage2Tex.java
/** * * @param _out appendable instance to the Latex file * @param _element line element of a paragraph to append * @throws IOException if write failed/* w ww.jav a 2s .c om*/ */ protected void appendLineElement(final Appendable _out, final AbstractLineElement _element) throws IOException { if (_element instanceof ExternalLink) { _out.append("\\url{").append(((ExternalLink) _element).getURL().toExternalForm()).append("}"); } else if (_element instanceof ExternalLinkWithDescription) { _out.append("\\href{").append(((ExternalLinkWithDescription) _element).getURL().toExternalForm()) .append("}{").append(this.escape(((ExternalLinkWithDescription) _element).getDescription())) .append("}"); } else if (_element instanceof ListBulleted) { _out.append("\\begin{itemize}\n"); for (final ListEntry entry : ((ListBulleted) _element).getEntries()) { _out.append("\\item {"); this.appendParagraph(_out, entry); _out.append("}\n"); } _out.append("\\end{itemize}\n"); } else if (_element instanceof Image) { _out.append(" \\includegraphics[width=\\textwidth]{").append(this.getImage(((Image) _element).getURL())) .append("} "); } else if (_element instanceof InternalLink) { _out.append(this.escape(((InternalLink) _element).getLink())); } else if (_element instanceof InternalLinkWithDescription) { _out.append(this.escape(((InternalLinkWithDescription) _element).getDescription())); } else if (_element instanceof NewLine) { _out.append(" \\newline "); } else if (_element instanceof Preformat) { _out.append("\n\\begin{lstlisting}\n").append(((Preformat) _element).getCode()) .append("\n\\end{lstlisting}\n"); } else if (_element instanceof Table) { this.appendTable(_out, (Table) _element); } else if (_element instanceof TextString) { _out.append(this.escape(((TextString) _element).getText())); } else if (_element instanceof TypefaceBold) { _out.append("{\\bfseries "); for (final AbstractLineElement element : ((TypefaceBold) _element).getElements()) { this.appendLineElement(_out, element); } _out.append("}"); } else if (_element instanceof TypefaceItalic) { _out.append("{\\it "); for (final AbstractLineElement element : ((TypefaceItalic) _element).getElements()) { this.appendLineElement(_out, element); } _out.append("}"); } else if (_element instanceof TypefaceCode) { _out.append("{\\tt "); for (final AbstractLineElement element : ((TypefaceCode) _element).getElements()) { this.appendLineElement(_out, element); } _out.append("}"); } else { System.err.println("unknown class " + _element); } }
From source file:org.efaps.wikiutil.export.latex.WikiPage2Tex.java
/** * * @param _out appendable instance to the Latex file * @param _section section to append * @param _level level of the section header / title * @throws IOException if write failed// w w w . j a v a 2 s . c o m */ protected void appendSection(final Appendable _out, final Section _section, final int _level) throws IOException { // title for (final AbstractLineElement element : _section.getHeadings()) { _out.append(WikiPage2Tex.STRUCTURE[this.structureLevel + _level]).append("{"); this.appendLineElement(_out, element); _out.append("}\n"); } // text this.appendParagraph(_out, _section); // sub sections for (final Section section : _section.getSubSections()) { this.appendSection(_out, section, _level + 1); } }
From source file:py.una.pol.karaku.controller.KarakuAdvancedController.java
/** * Agrega la llamada a la funcin js "equalColumnWidth()" dentro del * listener "ready" de JQuery. Desgraciadamente esta es la nica forma que * proporciona RichFaces para agregar mtodos al ready que crea l mismo. * // ww w . j a va 2 s . com * Este mtodo se debera llamar desde la vistas donde exista alguna lista * con extendedDataTable. */ public void columnFix() { JavaScriptService jsService = ServiceTracker.getService(JavaScriptService.class); JSObject js = new JSObject("name") { @Override public void appendScript(Appendable target) throws IOException { CharSequence cs = JSFUNCTION; target.append(cs); } @Override public void appendScriptToStringBuilder(StringBuilder stringBuilder) { stringBuilder.append(JSFUNCTION); } }; jsService.addPageReadyScript(FacesContext.getCurrentInstance(), js); }
From source file:com.thoughtworks.go.server.service.CcTrayService.java
public Appendable renderCCTrayXML(String siteUrlPrefix, String userName, Appendable appendable, Consumer<String> etagConsumer) { boolean isSecurityEnabled = goConfigService.isSecurityEnabled(); List<ProjectStatus> statuses = ccTrayCache.allEntriesInOrder(); String hashCodes = statuses.stream().map(ProjectStatus::hashCode).map(Object::toString) .collect(Collectors.joining("/")); String etag = DigestUtils.sha256Hex(siteUrlPrefix + "/" + hashCodes); etagConsumer.accept(etag);//from w w w .ja v a 2 s. co m try { appendable.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); appendable.append("\n"); appendable.append("<Projects>"); appendable.append("\n"); for (ProjectStatus status : statuses) { if (!isSecurityEnabled || status.canBeViewedBy(userName)) { String xmlRepresentation = status.xmlRepresentation().replaceAll(ProjectStatus.SITE_URL_PREFIX, siteUrlPrefix); if (!StringUtils.isBlank(xmlRepresentation)) { appendable.append(" ").append(xmlRepresentation).append("\n"); } } } appendable.append("</Projects>"); } catch (IOException e) { // ignore. `StringBuilder#append` does not throw } return appendable; }
From source file:org.apache.logging.log4j.core.util.datetime.FastDatePrinter.java
/** * Appends two digits to the given buffer. * * @param buffer the buffer to append to. * @param value the value to append digits from. */// www .jav a 2 s. c om private static void appendDigits(final Appendable buffer, final int value) throws IOException { buffer.append((char) (value / 10 + '0')); buffer.append((char) (value % 10 + '0')); }
From source file:com.bigml.histogram.MapCategoricalTarget.java
@Override protected void appendTo(final Appendable appendable, final DecimalFormat format) throws IOException { if (appendable == null) { throw new NullPointerException("appendable must not be null"); }/*from w ww . j a v a 2 s . c om*/ if (format == null) { throw new NullPointerException("format must not be null"); } for (Entry<Object, Double> categoryCount : _counts.entrySet()) { Object category = categoryCount.getKey(); double count = categoryCount.getValue(); appendable.append(String.valueOf(category)); appendable.append("\t"); appendable.append(format.format(count)); } }
From source file:de.micromata.genome.util.runtime.debug.PoorMansStackTraceProfiler.java
/** * Dump stack trace part.//ww w . j av a2 s .co m * * @param sb the sb * @param maxDepth the max depth * @param minHitCount the min hit count * @throws IOException Signals that an I/O exception has occurred. */ public void dumpStackTracePart(Appendable sb, int maxDepth, int minHitCount) throws IOException { for (Map.Entry<StackTraceElement, StackTracePart> e : trees.entrySet()) { sb.append("\nThread Tree\n"); e.getValue().dump(sb, " ", maxDepth, minHitCount); } }