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.eclipse.gyrex.http.jetty.internal.app.ApplicationHandler.java

@Override
public void dump(final Appendable out, final String indent) throws IOException {
    super.dump(out, indent);
    out.append(indent).append(" |").append('\n');
    out.append(indent).append(" +- mounted urls").append('\n');
    for (final String url : urls) {
        out.append(indent).append(" | ").append(indent).append(" +- ").append(url).append('\n');
    }//from  w  w  w.  j a v a  2  s.  co  m
}

From source file:org.opensingular.form.util.diff.DiffInfo.java

/**
 * Imprime para a sada informa o item atual de forma indentada e depois chama para os demais subitens se
 * existirem./*from  ww  w .  j  a  v a 2  s  .  co  m*/
 */
private void debug(Appendable appendable, int level, boolean showAll, boolean showLabel) {
    if (!showAll && isUnchanged()) {
        return;
    }
    try {
        pad(appendable, level);
        appendType(appendable);
        appendable.append(getPath(showLabel));
        if (StringUtils.isNotBlank(detail)) {
            appendable.append(" : ").append(detail);
        }
        appendable.append('\n');
        if (children != null) {
            for (DiffInfo info : children) {
                info.debug(appendable, level + 1, showAll, showLabel);
            }
        }
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:sadl.input.TimedInput.java

/**
 * Writes the {@link String} representation of the {@link TimedInput} in alternative format as it is required for parsing with
 * {@link TimedInput#parseAlt(Path)}./*from  ww  w.  java 2 s .  com*/
 * 
 * @param bw
 *            The writer where to write the {@link String} representation
 * @param withClassLabel
 *            If {@code true} the {@link ClassLabel} will be appended at the end of each timed sequence
 * @see TimedWord#toString(boolean)
 * @see TimedInput#parseAlt(Path)
 */
public void toFileAlt(Appendable bw, boolean withClassLabel) throws IOException {
    bw.append(Integer.toString(words.size()));
    bw.append(' ');
    bw.append(Integer.toString(alphabet.size()));
    bw.append('\n');
    toFile(bw, word -> word.toStringAlt(withClassLabel));
}

From source file:org.haiku.haikudepotserver.pkg.PkgServiceImpl.java

private void appendEjbqlAllPkgsWhere(Appendable ejbql, List<Object> parameterList, ObjectContext context,
        boolean allowSourceOnly) throws IOException {

    ejbql.append("p.active=true\n");

    if (!allowSourceOnly) {
        ejbql.append("AND EXISTS(");
        ejbql.append("SELECT pv FROM PkgVersion pv WHERE pv.pkg=p AND pv.active=true AND pv.architecture <> ?");
        parameterList.add(Architecture.getByCode(context, Architecture.CODE_SOURCE));
        ejbql.append(Integer.toString(parameterList.size()));
        ejbql.append(")");
    }//from  w  w  w.  j av a 2s. c om

}

From source file:net.sourceforge.seqware.pipeline.plugins.batchmetadatainjection.LaneInfo.java

public void print(Appendable writer, Metadata metadata) throws IOException {
    String studyTypeStr = "<null>";
    if (studyTypeAcc != null && !studyTypeAcc.trim().isEmpty() && StringUtils.isNumeric(studyTypeAcc)) {
        for (StudyType st : metadata.getStudyTypes()) {
            if (st.getStudyTypeId().equals(Integer.parseInt(studyTypeAcc))) {
                studyTypeStr = st.getName();
            }/*from   w ww .j  a  v  a 2  s.c  o m*/
        }
    }

    writer.append("\n\tLaneInfo {");
    writer.append("\n\t\tlaneNumber=").append(laneNumber);
    writer.append("\n\t\tstudyType=").append(studyTypeStr);
    if (samples != null) {
        for (SampleInfo si : samples) {
            si.print(writer, metadata);
        }
    }
    writer.append("\n\t}");
}

From source file:org.ofbiz.widget.WidgetWorker.java

public static void buildHyperlinkUrl(Appendable externalWriter, String target, String targetType,
        Map<String, String> parameterMap, String prefix, boolean fullPath, boolean secure, boolean encode,
        HttpServletRequest request, HttpServletResponse response, Map<String, Object> context)
        throws IOException {

    // We may get an encoded request like: &#47;projectmgr&#47;control&#47;EditTaskContents&#63;workEffortId&#61;10003
    // Try to reducing a possibly encoded string down to its simplest form: /projectmgr/control/EditTaskContents?workEffortId=10003
    // This step make sure the following appending externalLoginKey operation to work correctly
    String localRequestName = StringEscapeUtils.unescapeHtml(target);

    localRequestName = UtilHttp.encodeAmpersands(localRequestName);
    Appendable localWriter = new StringWriter();

    if ("intra-app".equals(targetType)) {
        if (request != null && response != null) {
            ServletContext servletContext = request.getSession().getServletContext();
            RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
            externalWriter
                    .append(rh.makeLink(request, response, "/" + localRequestName, fullPath, secure, encode));
        } else if (prefix != null) {
            externalWriter.append(prefix);
            externalWriter.append(localRequestName);
        } else {/*from  w  ww . j av a  2s  . com*/
            externalWriter.append(localRequestName);
        }
    } else if ("inter-app".equals(targetType)) {
        String fullTarget = localRequestName;
        localWriter.append(fullTarget);
        String externalLoginKey = (String) request.getAttribute("externalLoginKey");
        if (UtilValidate.isNotEmpty(externalLoginKey)) {
            if (fullTarget.indexOf('?') == -1) {
                localWriter.append('?');
            } else {
                localWriter.append("&amp;");
            }
            localWriter.append("externalLoginKey=");
            localWriter.append(externalLoginKey);
        }
    } else if ("content".equals(targetType)) {
        appendContentUrl(localWriter, localRequestName, request);
    } else if ("plain".equals(targetType)) {
        localWriter.append(localRequestName);
    } else {
        localWriter.append(localRequestName);
    }

    if (UtilValidate.isNotEmpty(parameterMap)) {
        String localUrl = localWriter.toString();
        externalWriter.append(localUrl);
        boolean needsAmp = true;
        if (localUrl.indexOf('?') == -1) {
            externalWriter.append('?');
            needsAmp = false;
        }

        for (Map.Entry<String, String> parameter : parameterMap.entrySet()) {
            String parameterValue = null;
            if (parameter.getValue() instanceof String) {
                parameterValue = parameter.getValue();
            } else {
                Object parameterObject = parameter.getValue();

                // skip null values
                if (parameterObject == null)
                    continue;

                if (parameterObject instanceof String[]) {
                    // it's probably a String[], just get the first value
                    String[] parameterArray = (String[]) parameterObject;
                    parameterValue = parameterArray[0];
                    Debug.logInfo("Found String array value for parameter [" + parameter.getKey()
                            + "], using first value: " + parameterValue, module);
                } else {
                    // not a String, and not a String[], just use toString
                    parameterValue = parameterObject.toString();
                }
            }

            if (needsAmp) {
                externalWriter.append("&amp;");
            } else {
                needsAmp = true;
            }
            externalWriter.append(parameter.getKey());
            externalWriter.append('=');
            StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
            if (simpleEncoder != null && parameterValue != null) {
                externalWriter.append(simpleEncoder
                        .encode(URLEncoder.encode(parameterValue, Charset.forName("UTF-8").displayName())));
            } else {
                externalWriter.append(parameterValue);
            }
        }
    } else {
        externalWriter.append(localWriter.toString());
    }
}

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

public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) {

    if (!hasMoreChildren) {
        return;// w w w  . ja va 2 s.c  o m
    }

    Appendable out = (matchingObject) ? new StringBuilder() : this.out;

    try {
        switch (node.getType()) {
        case Expression.AND:
            out.append(" AND ");
            break;
        case Expression.OR:
            out.append(" OR ");
            break;
        case Expression.EQUAL_TO:
            // translate NULL as IS NULL
            if (childIndex == 0 && node.getOperandCount() == 2 && node.getOperand(1) == null) {
                out.append(" IS ");
            } else {
                out.append(" = ");
            }
            break;
        case Expression.NOT_EQUAL_TO:
            // translate NULL as IS NOT NULL
            if (childIndex == 0 && node.getOperandCount() == 2 && node.getOperand(1) == null) {
                out.append(" IS NOT ");
            } else {
                out.append(" <> ");
            }
            break;
        case Expression.LESS_THAN:
            out.append(" < ");
            break;
        case Expression.GREATER_THAN:
            out.append(" > ");
            break;
        case Expression.LESS_THAN_EQUAL_TO:
            out.append(" <= ");
            break;
        case Expression.GREATER_THAN_EQUAL_TO:
            out.append(" >= ");
            break;
        case Expression.IN:
            out.append(" IN ");
            break;
        case Expression.NOT_IN:
            out.append(" NOT IN ");
            break;
        case Expression.LIKE:
            out.append(" LIKE ");
            break;
        case Expression.NOT_LIKE:
            out.append(" NOT LIKE ");
            break;
        case Expression.LIKE_IGNORE_CASE:
            if (caseInsensitive) {
                out.append(" LIKE ");
            } else {
                out.append(") LIKE UPPER(");
            }
            break;
        case Expression.NOT_LIKE_IGNORE_CASE:
            if (caseInsensitive) {
                out.append(" NOT LIKE ");
            } else {
                out.append(") NOT LIKE UPPER(");
            }
            break;
        case Expression.ADD:
            out.append(" + ");
            break;
        case Expression.SUBTRACT:
            out.append(" - ");
            break;
        case Expression.MULTIPLY:
            out.append(" * ");
            break;
        case Expression.DIVIDE:
            out.append(" / ");
            break;
        case Expression.BETWEEN:
            if (childIndex == 0)
                out.append(" BETWEEN ");
            else if (childIndex == 1)
                out.append(" AND ");
            break;
        case Expression.NOT_BETWEEN:
            if (childIndex == 0)
                out.append(" NOT BETWEEN ");
            else if (childIndex == 1)
                out.append(" AND ");
            break;
        case Expression.BITWISE_OR:
            out.append(" ").append(operandForBitwiseOr()).append(" ");
            break;
        case Expression.BITWISE_AND:
            out.append(" ").append(operandForBitwiseAnd()).append(" ");
            break;
        case Expression.BITWISE_XOR:
            out.append(" ").append(operandForBitwiseXor()).append(" ");
            break;
        }
    } catch (IOException ioex) {
        throw new CayenneRuntimeException("Error appending content", ioex);
    }

    if (matchingObject) {
        objectMatchTranslator.setOperation(out.toString());
        objectMatchTranslator.setExpression(node);
    }
}

From source file:sadl.input.TimedInput.java

private void toFile(Appendable a, Function<TimedWord, String> f) throws IOException {
    checkCleared();//from   w  w  w.j a v  a  2  s. c o  m
    for (int i = 0; i < words.size(); i++) {
        a.append(f.apply(words.get(i)));
        if (i < (words.size() - 1)) {
            a.append('\n');
        }
    }
}

From source file:org.efaps.wikiutil.export.latex.WikiPage2Tex.java

/**
 * Appends to <code>_out</code> the Latex code for given
 * <code>_table</code>. As Latex a <code>longtable</code> is used which is
 * automatically sized and which could be on multiple pages.
 *
 * @param _out      appendable instance to the Latex file
 * @param _table    Wiki page table to write
 * @throws IOException if write failed// ww w.  ja v a2  s .  c  om
 */
protected void appendTable(final Appendable _out, final Table _table) throws IOException {
    // calculate table file name
    final String tableName = this.texOut.getName().replace('.', '_') + WikiPage2Tex.PREFIX_TABLE
            + (this.tableCount++);

    // calculate maximum entries in a row
    int max = 0;
    for (final TableRow row : _table.getBodyRows()) {
        if (max < row.getEntries().size()) {
            max = row.getEntries().size();
        }
    }
    _out.append("\n\\begin{filecontents*}{").append(tableName).append(".tex}").append("\n\\begin{longtable}{|");
    for (int idx = 0; idx < max; idx++) {
        _out.append("X|");
    }
    _out.append("}\n\\hline\n\\endhead\n\\hline\n\\endfoot\n");

    for (final TableRow row : _table.getBodyRows()) {
        boolean first = true;
        for (final TableCell cell : row.getEntries()) {
            if (first) {
                first = false;
            } else {
                _out.append(" & ");
            }
            this.appendParagraph(_out, cell);
        }
        _out.append(" \\\\\n\\hline\n");
    }
    _out.append("\\end{longtable}\n").append("\\end{filecontents*}\n").append("\\LTXtable{\\textwidth}{")
            .append(tableName).append("}\n");
}

From source file:sadl.models.pdrta.PDRTA.java

private void writeStatData(Appendable ap, Set<PDRTAState> found) throws IOException {

    // Write min/max time delays as comment
    ap.append("// minTimeDelay=");
    ap.append(Integer.toString(input.getMinTimeDelay()));
    ap.append("\n");
    ap.append("// maxTimeDelay=");
    ap.append(Integer.toString(input.getMaxTimeDelay()));
    ap.append("\n");
    // Write alphabet as comment
    ap.append("// alphabet={");
    ap.append(input.getSymbol(0));//from ww  w.  j av  a  2 s  .co  m
    for (int i = 1; i < input.getAlphSize(); i++) {
        ap.append(",");
        ap.append(input.getSymbol(i));
    }
    ap.append("}\n");
    // Write histogram borders as comment
    ap.append("// histoborders={");
    if (input.getHistBorders().length > 0) {
        ap.append(Integer.toString(input.getHistBorders()[0]));
        for (int i = 1; i < input.getNumHistogramBars() - 1; i++) {
            ap.append(",");
            ap.append(Integer.toString(input.getHistBorders()[i]));
        }
    }
    ap.append("}\n");
    // Write symbol and time distributions for each state as comment
    for (final int key : states.keys()) {
        final PDRTAState s = states.get(key);
        if (found.contains(s)) {
            ap.append("// ");
            ap.append(Integer.toString(key));
            ap.append(" SYM ");
            ap.append(s.getStat().getSymbolProbsString());
            ap.append("\n");
            ap.append("// ");
            ap.append(Integer.toString(key));
            ap.append(" TIME ");
            ap.append(s.getStat().getTimeProbsString());
            ap.append("\n");
        }
    }
}