Example usage for java.lang Appendable append

List of usage examples for java.lang Appendable append

Introduction

In this page you can find the example usage for java.lang Appendable append.

Prototype

Appendable append(char c) throws IOException;

Source Link

Document

Appends the specified character to this Appendable .

Usage

From source file:org.apache.cayenne.access.trans.JoinStack.java

void appendRootWithQuoteSqlIdentifiers(Appendable out, DbEntity rootEntity) throws IOException {

    if (rootEntity.getSchema() != null) {
        out.append(strategy.quoteString(rootEntity.getSchema()));
        out.append(".");
    }//from ww w .  ja v  a2  s. c om
    out.append(strategy.quoteString(rootEntity.getName()));
    out.append(' ');
    out.append(strategy.quoteString(rootNode.getTargetTableAlias()));
}

From source file:org.ramadda.repository.monitor.FtpAction.java

/**
 * _more_//w w w. j a  va  2  s.c  o  m
 *
 * @param monitor _more_
 * @param sb _more_
 *
 * @throws Exception _more_
 */
@Override
public void addToEditForm(EntryMonitor monitor, Appendable sb) throws Exception {
    sb.append(HtmlUtils.formTable());
    sb.append(HtmlUtils.colspan("FTP Action", 2));

    sb.append(HtmlUtils.formEntry(monitor.getRepository().msgLabel("FTP Server"),
            HtmlUtils.input(getArgId(PROP_FTP_SERVER), server, HtmlUtils.SIZE_60)));
    sb.append(HtmlUtils.formEntry(monitor.getRepository().msgLabel("FTP Directory"),
            HtmlUtils.input(getArgId(PROP_FTP_DIRECTORY), directory, HtmlUtils.SIZE_60)));
    String tooltip = "macros: ${from_day}  ${from_month} ${from_year} ${from_monthname}  <br>"
            + "${to_day}  ${to_month} ${to_year} ${to_monthname} <br> " + "${filename}  ${fileextension} etc";

    sb.append(HtmlUtils.formEntry(monitor.getRepository().msgLabel("File Name Template"), HtmlUtils.input(
            getArgId(PROP_FTP_FILETEMPLATE), fileTemplate, HtmlUtils.SIZE_60 + HtmlUtils.title(tooltip))));
    sb.append(HtmlUtils.formEntry(monitor.getRepository().msgLabel("User ID"),
            HtmlUtils.input(getArgId(PROP_FTP_USER), user, HtmlUtils.SIZE_60)));
    sb.append(HtmlUtils.formEntry(monitor.getRepository().msgLabel("Password"),
            HtmlUtils.password(getArgId(PROP_FTP_PASSWORD), password, HtmlUtils.SIZE_20)));

    sb.append(HtmlUtils.formTableClose());
}

From source file:com.github.xbn.regexutil.RegexGroupExtractor.java

/**
   <p>Append the next set of groups, joined into a single string and followed by some new-lines--for debugging and testing.</p>
        //from w ww.  j a  va2 s. c o  m
   <p>This<ol>
 <li>Calls
 <br/> &nbsp; &nbsp; <code>to_appendTo.append({@link #nextAsJoined(String) nextAsJoined}(separator))</code></li>
 <li><i><b>Returns</b></i>
 <br/> &nbsp; &nbsp; <code>{@link com.github.xbn.io.IOUtil IOUtil}.{@link com.github.xbn.io.IOUtil#appendNewLinesX(int, Appendable) appendNewLinesX}(new_lineCount, to_appendTo)</code></li>
   </ol></p>
        
 * @exception  RTIOException  If a {@code java.io.IOException} is thrown for any reason.
 */
public Appendable appendNextAsJoinedlns(int new_lineCount, Appendable to_appendTo, String separator) {
    try {
        to_appendTo.append(nextAsJoined(separator));
        return IOUtil.appendNewLinesX(new_lineCount, to_appendTo);
    } catch (IOException iox) {
        throw new RTIOException("appendNextAsJoinedlns", iox);
    }
}

From source file:com.asakusafw.dmdl.thundergate.emitter.RecordLockDdlEmitter.java

/**
 * Appends DDL contents into the target writer.
 * @param appendable the target writer//w  w  w  . j  a  v a2  s  . c o  m
 * @throws IOException if failed to append to the writer by I/O error
 */
public void appendTo(Appendable appendable) throws IOException {
    if (appendable == null) {
        throw new IllegalArgumentException("appendable must not be null"); //$NON-NLS-1$
    }
    for (String tableName : tableNames) {
        String ddl = TEMPLATE_CONTENTS.replaceAll(TEMPLATE_TABLE_NAME_PLACEHOLDER, tableName);
        appendable.append(ddl);
    }
}

From source file:ch.algotrader.simulation.SimulationResultFormatter.java

public void formatLong(final Appendable buffer, final SimulationResultVO resultVO,
        final CommonConfig commonConfig) throws IOException {

    buffer.append("execution time (min): " + (new DecimalFormat("0.00")).format(resultVO.getMins()) + "\r\n");

    if (resultVO.getAllTrades().getCount() == 0) {
        buffer.append("no trades took place! \r\n");
        return;/*from w  w  w  .  j a  v  a  2s.  co  m*/
    }

    buffer.append("dataSet: " + commonConfig.getDataSet() + "\r\n");

    double netLiqValue = resultVO.getNetLiqValue();
    buffer.append("netLiqValue=" + twoDigitFormat.format(netLiqValue) + "\r\n");

    // monthlyPerformances
    Collection<PeriodPerformanceVO> monthlyPerformances = resultVO.getMonthlyPerformances();
    double maxDrawDownM = 0d;
    double bestMonthlyPerformance = Double.NEGATIVE_INFINITY;
    int positiveMonths = 0;
    int negativeMonths = 0;
    if ((monthlyPerformances != null)) {
        StringBuilder dateBuffer = new StringBuilder("month-year:         ");
        StringBuilder performanceBuffer = new StringBuilder("monthlyPerformance: ");
        for (PeriodPerformanceVO monthlyPerformance : monthlyPerformances) {
            maxDrawDownM = Math.min(maxDrawDownM, monthlyPerformance.getValue());
            bestMonthlyPerformance = Math.max(bestMonthlyPerformance, monthlyPerformance.getValue());
            monthFormat.formatTo(DateTimeLegacy.toLocalDate(monthlyPerformance.getDate()), dateBuffer);
            performanceBuffer.append(
                    StringUtils.leftPad(twoDigitFormat.format(monthlyPerformance.getValue() * 100), 6) + "% ");
            if (monthlyPerformance.getValue() > 0) {
                positiveMonths++;
            } else {
                negativeMonths++;
            }
        }
        buffer.append(dateBuffer.toString() + "\r\n");
        buffer.append(performanceBuffer.toString() + "\r\n");
    }

    // yearlyPerformances
    int positiveYears = 0;
    int negativeYears = 0;
    Collection<PeriodPerformanceVO> yearlyPerformances = resultVO.getYearlyPerformances();
    if ((yearlyPerformances != null)) {
        StringBuilder dateBuffer = new StringBuilder("year:               ");
        StringBuilder performanceBuffer = new StringBuilder("yearlyPerformance:  ");
        for (PeriodPerformanceVO yearlyPerformance : yearlyPerformances) {
            yearFormat.formatTo(DateTimeLegacy.toGMTDate(yearlyPerformance.getDate()), dateBuffer);
            performanceBuffer.append(
                    StringUtils.leftPad(twoDigitFormat.format(yearlyPerformance.getValue() * 100), 6) + "% ");
            if (yearlyPerformance.getValue() > 0) {
                positiveYears++;
            } else {
                negativeYears++;
            }
        }
        buffer.append(dateBuffer.toString() + "\r\n");
        buffer.append(performanceBuffer.toString() + "\r\n");
    }

    if ((monthlyPerformances != null)) {
        buffer.append("posMonths=" + positiveMonths + " negMonths=" + negativeMonths);
        if ((yearlyPerformances != null)) {
            buffer.append(" posYears=" + positiveYears + " negYears=" + negativeYears);
        }
        buffer.append("\r\n");
    }

    PerformanceKeysVO performanceKeys = resultVO.getPerformanceKeys();
    MaxDrawDownVO maxDrawDownVO = resultVO.getMaxDrawDown();
    if (performanceKeys != null && maxDrawDownVO != null) {
        buffer.append("avgM=" + twoDigitFormat.format(performanceKeys.getAvgM() * 100) + "%");
        buffer.append(" stdM=" + twoDigitFormat.format(performanceKeys.getStdM() * 100) + "%");
        buffer.append(" avgY=" + twoDigitFormat.format(performanceKeys.getAvgY() * 100) + "%");
        buffer.append(" stdY=" + twoDigitFormat.format(performanceKeys.getStdY() * 100) + "% ");
        buffer.append(" sharpeRatio=" + twoDigitFormat.format(performanceKeys.getSharpeRatio()) + "\r\n");

        buffer.append("maxMonthlyDrawDown=" + twoDigitFormat.format(-maxDrawDownM * 100) + "%");
        buffer.append(" bestMonthlyPerformance=" + twoDigitFormat.format(bestMonthlyPerformance * 100) + "%");
        buffer.append(" maxDrawDown=" + twoDigitFormat.format(maxDrawDownVO.getAmount() * 100) + "%");
        buffer.append(
                " maxDrawDownPeriod=" + twoDigitFormat.format(maxDrawDownVO.getPeriod() / 86400000) + "days");
        buffer.append(
                " colmarRatio=" + twoDigitFormat.format(performanceKeys.getAvgY() / maxDrawDownVO.getAmount()));

        buffer.append("\r\n");
    }

    buffer.append("WinningTrades:");
    convertTrades(buffer, resultVO.getWinningTrades(), resultVO.getAllTrades().getCount());

    buffer.append("LoosingTrades:");
    convertTrades(buffer, resultVO.getLoosingTrades(), resultVO.getAllTrades().getCount());

    buffer.append("AllTrades:");
    convertTrades(buffer, resultVO.getAllTrades(), resultVO.getAllTrades().getCount());

    for (Map.Entry<String, Object> entry : resultVO.getStrategyResults().entrySet()) {
        buffer.append(entry.getKey() + "=" + entry.getValue() + " ");
    }
}

From source file:org.auraframework.http.AuraContextFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws ServletException, IOException {

    if (Aura.getContextService().isEstablished()) {
        LOG.error("Aura context was not released correctly! New context will NOT be created.");
        chain.doFilter(req, res);/*  w w  w. j  a v a2 s. c om*/
        return;
    }

    LoggingService loggingService = Aura.getLoggingService();
    try {
        startContext(req, res, chain);
        HttpServletRequest request = (HttpServletRequest) req;
        loggingService.setValue(LoggingService.REQUEST_METHOD, request.getMethod());
        loggingService.setValue(LoggingService.AURA_REQUEST_URI, request.getRequestURI());
        loggingService.setValue(LoggingService.AURA_REQUEST_QUERY, request.getQueryString());
        chain.doFilter(req, res);
    } catch (InvalidParamException e) {
        HttpServletResponse response = (HttpServletResponse) res;
        response.setStatus(500);
        Appendable out = response.getWriter();
        out.append(e.getMessage());
        return;
    } finally {
        try {
            if (loggingService != null) {
                try {
                    loggingService.setValue(LoggingService.STATUS,
                            String.valueOf(((HttpServletResponse) res).getStatus()));
                } catch (Throwable t) {
                    // ignore.
                }
                loggingService.flush(); // flush out logging values
            }
        } finally {
            endContext();
        }
    }
}

From source file:com.bigml.histogram.Bin.java

/**
 * Append a text representation of this bin to the specified appendable.
 *
 * @param appendable appendable to append to, must not be null
 * @param format decimal format, must not be null
 * @throws IOException if an error occurs
 *///from   w  w w  .  jav  a  2 s  .  c o  m
public void appendTo(final Appendable appendable, final DecimalFormat format) throws IOException {
    if (appendable == null) {
        throw new NullPointerException("appendable must not be null");
    }
    if (format == null) {
        throw new NullPointerException("format must not be null");
    }
    appendable.append(format.format(_mean));
    appendable.append("\t");
    appendable.append(format.format(_count));
    appendable.append("\t");
    _target.appendTo(appendable, format);
    appendable.append("\n");
}

From source file:com.github.xbn.list.lister.ListLister.java

/**
<pre>getOverallConfig()//  ww  w. jav a  2 s . c o  m
getIfNull()               <i>(short circuit)</i>
getIfNonNull()              <i>(short circuit)</i>
getVVForElementLength()   <i>(short circuit)</i>
   getIfElementLength()
getIndexFilter()
getValueFilter()
getElementConfig()
getOverallConfig()
getVPCFinalOutput()
getPrefix()
getPostfix()</pre>
 */
public static final <E> Appendable appendX(ListLister<E> lister, Appendable to_appendTo, List<E> list)
        throws IOException {
    LLCfgOverall<E> llco = null;
    try {
        llco = lister.getOverallConfig();
    } catch (RuntimeException rx) {
        throw CrashIfObject.nullOrReturnCause(lister, "lister", null, rx);
    }

    if (list == null) {
        return StringWithNullDefault.append(to_appendTo, llco.getIfNull(), null);
    }

    ListLister.lr4SZ_MRK.replaceWith(list.size());

    StringWithNullDefault.append(to_appendTo, llco.getPrefix(), null);

    Appendable apblTmp = (llco.getVPCFinalOutput().doesNothing() ? to_appendTo : new StringBuilder());

    if (llco.getIfNonNull() != null) {
        return lr4SZ_MRK.appendReplaced(apblTmp, llco.getIfNonNull());
    }

    if (llco.getVVForElementLength().getRuleType().isRestricted()
            && llco.getVVForElementLength().isValid(list.size())) {
        return lr4SZ_MRK.appendReplaced(apblTmp, llco.getIfElementLength());
    }

    String sBetween = StringWithNullDefault.get(lister.getBetween(), null);

    boolean bFilterUsed = (lister.getIndexFilter().getRuleType().isRestricted()
            || lister.getValueFilter().getRuleType().isRestricted());

    int ix = -1;
    if (!bFilterUsed) {
        boolean b1stLmntWritten = false;
        for (E e : list) {
            ix++; //First iteration: Was -1, now 0
            if (!lister.getIndexFilter().isValid(ix) || !lister.getValueFilter().isValid(e)) {
                continue;
            }

            if (b1stLmntWritten) {
                apblTmp.append(sBetween);
            } else {
                b1stLmntWritten = true;
            }

            appendElement(lister.getElementConfig(), apblTmp, ix, e);
        }

        //ELSE: bFilterUsed is false
    } else {
        for (E e : list) {
            if (ix > -1) {
                apblTmp.append(sBetween);
            }
            //First iteration: Was -1, now 0
            appendElement(lister.getElementConfig(), apblTmp, ++ix, e);
        }
    }

    if (!llco.getVPCFinalOutput().doesNothing()) {
        llco.getVPCFinalOutput().append(to_appendTo, apblTmp.toString());
    }

    return StringWithNullDefault.append(to_appendTo, llco.getPostfix(), null);
}

From source file:com.bigml.histogram.NumericTarget.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 w w .  j av a  2s .  c om*/
    if (format == null) {
        throw new NullPointerException("format must not be null");
    }
    if (_sum != null) {
        appendable.append(format.format(_sum));
        appendable.append("\t");
        appendable.append(format.format(_sumSquares));
    }
}

From source file:org.eclipse.ocl.examples.emf.validation.validity.export.HTMLExporter.java

/**
 * Returns a stream containing the initial contents to be given to new
 * exported validation results file resource instances.
 * /*ww  w .j  a va 2 s . c  o  m*/
 * @throws IOException 
 */
@Override
public void createContents(@NonNull Appendable html, @NonNull RootNode rootNode,
        @Nullable String exportedFileName) throws IOException {
    html.append("<html>\n");
    html.append("\t<head></head>\n");
    html.append("\t<body>\n");
    html.append("\t\t<h1>1. GENERAL INFORMATION</h1>\n");

    html.append("\t\t<table border=\"1\">\n");

    if (exportedFileName != null) {
        html.append("\t\t\t<tr>\n");
        html.append("\t\t\t\t<td><b>Output file name: </b></td>\n");
        html.append("\t\t\t\t<td>" + exportedFileName + "</td>\n");
        html.append("\t\t\t</tr>\n");
    }

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Author: </b></td>\n");
    html.append("\t\t\t\t<td>" + System.getProperty("user.name") + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t</table>\n");

    html.append("\n");
    html.append("\n");

    html.append("\t\t<h1>2. RESOURCES USED</h1>\n");
    html.append("\t\t\t<h2>2.1. Model checked</h2>\n");

    html.append("\t\t\t<ul>\n");
    List<String> uriStrings = new ArrayList<String>();
    for (RootValidatableNode rootValidatableNode : rootNode.getValidatableNodes()) {
        Resource eResource = rootValidatableNode.getConstrainedObject().eResource();
        uriStrings.add(eResource.getURI().toString());
    }
    Collections.sort(uriStrings);
    for (String uriString : uriStrings) {
        html.append("\t\t\t\t<li>" + uriString + "</li>\n");
    }

    html.append("\t\t\t</ul>\n");

    html.append("<br/>\n");

    html.append("\t\t<h1>3. METRICS</h1>\n");
    html.append("\t\t<table border=\"1\">\n");

    int total = getConstraintCount();
    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Total number of evaluated constraints: </b></td>\n");
    html.append("\t\t\t\t<td>" + total + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Number of Success: </b></td>\n");
    html.append("\t\t\t\t<td>" + validationSuccess.size() + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Number of Infos: </b></td>\n");
    html.append("\t\t\t\t<td>" + validationInfos.size() + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Number of Warnings: </b></td>\n");
    html.append("\t\t\t\t<td>" + validationWarnings.size() + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Number of Errors: </b></td>\n");
    html.append("\t\t\t\t<td>" + validationErrors.size() + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t\t<tr>\n");
    html.append("\t\t\t\t<td><b>Number of Failures: </b></td>\n");
    html.append("\t\t\t\t<td>" + validationFailures.size() + "</td>\n");
    html.append("\t\t\t</tr>\n");

    html.append("\t\t</table>\n");

    html.append("\t\t<h1>4. LOGS</h1>\n");

    if (validationSuccess.size() == total) {
        html.append("<p>No log to display: models has been successfully validated.</p>\n");
    } else {
        int section = 1;
        Set<Object> loggedConstrainingObjects = new HashSet<Object>();
        if (!validationInfos.isEmpty()) {
            html.append("\t\t<h2>4." + section + ". Infos</h2>\n");
            html.append("\t\t<table border=\"1\">\n");
            appendTitlesTable(html);
            for (LeafConstrainingNode infoNode : validationInfos) {
                if (loggedConstrainingObjects.add(infoNode.getConstrainingObject())) {
                    appendLogFile(infoNode, html, Severity.INFO.getLiteral());
                }
            }
            html.append("\t\t</table>\n");
            section++;
        }
        if (!validationWarnings.isEmpty()) {
            html.append("\t\t<h2>4." + section + ". Warnings</h2>\n");
            html.append("\t\t<table border=\"1\">\n");
            appendTitlesTable(html);
            for (LeafConstrainingNode warningNode : validationWarnings) {
                if (loggedConstrainingObjects.add(warningNode.getConstrainingObject())) {
                    appendLogFile(warningNode, html, Severity.WARNING.getLiteral());
                }
            }
            html.append("\t\t</table>\n");
            section++;
        }
        if (!validationErrors.isEmpty()) {
            html.append("\t\t<h2>4." + section + ". Errors</h2>\n");
            html.append("\t\t<table border=\"1\">\n");
            appendTitlesTable(html);
            for (LeafConstrainingNode errorNode : validationErrors) {
                if (loggedConstrainingObjects.add(errorNode.getConstrainingObject())) {
                    appendLogFile(errorNode, html, Severity.ERROR.getLiteral());
                }
            }
            html.append("\t\t</table>\n");
            section++;
        }
        if (!validationFailures.isEmpty()) {
            html.append("\t\t<h2>4." + section + ". Failures</h2>\n");
            html.append("\t\t<table border=\"1\">\n");
            appendTitlesTable(html);
            for (LeafConstrainingNode failureNode : validationFailures) {
                if (loggedConstrainingObjects.add(failureNode.getConstrainingObject())) {
                    appendLogFile(failureNode, html, Severity.FATAL.getLiteral());
                }
            }
            html.append("\t\t</table>\n");
            section++;
        }
    }
    html.append("</body>\n");
    html.append("</html>\n");
}