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:com.google.sites.liberation.util.XmlElement.java

/**
 * Appends this XmlElement (and any children) to an Appendable.
 *//*w  w w  . jav  a 2s . c om*/
public void appendTo(Appendable a) throws IOException {
    a.append('<').append(elementType);
    for (Map.Entry<String, String> attribute : attributes.entrySet()) {
        a.append(' ').append(attribute.getKey()).append("=\"").append(attribute.getValue()).append("\"");
    }
    if (children.isEmpty()) {
        a.append(" />");
    } else {
        a.append(">");
        for (Pair<Object, ChildType> pair : children) {
            Object child = pair.getFirst();
            ChildType type = pair.getSecond();
            if (type == ChildType.ELEMENT) {
                ((XmlElement) child).appendTo(a);
            } else {
                a.append((String) child);
            }
        }
        a.append("</").append(elementType).append('>');
    }
}

From source file:org.shredzone.cilla.site.renderer.PaginatorStrategyImpl.java

@Override
public void pageLink(Appendable out, String url, int current, int selected) throws IOException {
    if (needsSeparator) {
        out.append("&middot;&middot;&middot;");
        needsSeparator = false;/* w  ww.  j  a v  a  2 s.  c  o  m*/
    }

    if (current == selected) {
        out.append("<span class=\"button button-disabled\"><b>");
        out.append(String.valueOf(current + 1));
        out.append("</b></span>&nbsp;");
    } else {
        out.append("<a class=\"button\" href=\"").append(url).append("\">");
        out.append(String.valueOf(current + 1));
        out.append("</a>&nbsp;");
    }
}

From source file:org.cytoscape.task.internal.export.TunableAbstractCyWriter.java

@Override
public final ValidationState getValidationState(final Appendable msg) {
    if (getExportFileFormat() == null) {
        try {//from  ww  w .ja  v  a 2s.c  om
            msg.append("Select a file type.");
        } catch (final Exception e) {
            /* Intentionally empty. */
        }
        return ValidationState.INVALID;
    }

    if (outputFile == null) {
        try {
            msg.append("Enter the file address.");
        } catch (final Exception e) {
            /* Intentionally empty. */
        }
        return ValidationState.INVALID;
    }

    boolean isFileChanged = false;
    // Make sure we have the right extension, if not, then force it:
    if (!fileExtensionIsOk(outputFile)) {
        outputFile = addOrReplaceExtension(outputFile);
        isFileChanged = true;
    }
    if (isFileChanged && outputFile.exists()) {
        try {
            msg.append("File already exists, are you sure you want to overwrite it?");
        } catch (final Exception e) {
            /* Intentionally empty. */
        }
        return ValidationState.REQUEST_CONFIRMATION;
    } else
        return ValidationState.OK;
}

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

private void appendTitlesTable(@NonNull Appendable s) throws IOException {
    s.append("\t\t\t<tr>\n");
    s.append("\t\t\t\t<td><b>Resource</b></td>\n");
    s.append("\t\t\t\t<td><b>Invariant</b></td>\n");
    s.append("\t\t\t\t<td><b>Expression</b></td>\n");
    s.append("\t\t\t\t<td><b>Severity</b></td>\n");
    s.append("\t\t\t\t<td><b>Message</b></td>\n");
    s.append("\t\t\t</tr>\n");
}

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

void appendRoot(Appendable out, DbEntity rootEntity) throws IOException {
    out.append(rootEntity.getFullyQualifiedName());
    out.append(' ').append(rootNode.getTargetTableAlias());
}

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

private void appendLogFile(LeafConstrainingNode node, @NonNull Appendable s, String severity)
        throws IOException {
    s.append("\t\t\t<tr>\n");
    Resource resource = node.getConstraintResource();
    if (resource != null) {
        s.append("\t\t\t<td> Resource: " + resource.getURI().lastSegment() + "</td>\n");
    } else {/*  ww  w.j a  v  a  2s. com*/
        s.append("\t\t\t\t<td>" + ValidityMessages.ValidityView_Constraints_LabelProvider_NonExistentResource
                + "</td>\n");
    }
    s.append("\t\t\t\t<td>" + node.getLabel() + "</td>\n");

    String expression = node.getConstraintString();
    if (expression != null) {
        s.append("\t\t\t\t<td>" + expression + "</td>\n");
    } else {
        s.append("\t\t\t\t<td>" + ValidityMessages.ValidityView_Constraints_LabelProvider_ExpressionNotAvailable
                + "</td>\n");
    }
    s.append("\t\t\t\t<td>" + severity + "</td>\n");
    s.append("\t\t\t\t<td>" + StringEscapeUtils.escapeHtml(getMessage(node.getWorstResult())) + "</td>\n");
    s.append("\t\t\t</tr>\n");
}

From source file:com.github.xbn.text.padchop.VzblPadChop.java

private static final void appendPadChoppedXWDbg(VzblPadChop vpc, Appendable to_appendTo, int goal_len,
        String so_far) throws IOException {
    if (vpc.doPadFirst()) {
        so_far = vpc.getPad().getPadded(goal_len, so_far);
        vpc.getDebugAptr().appentln("<VPC> pad-first: Padded:  [" + so_far + "]");
        so_far = vpc.getChop().getChopped(goal_len, so_far);
        vpc.getDebugAptr().appentln("<VPC> pad-first: Chopped: [" + so_far + "]");
    } else {// w  w w  .j a  v a2s  . c om
        so_far = vpc.getChop().getChopped(goal_len, so_far);
        vpc.getDebugAptr().appentln("<VPC> chop-first: Chopped: [" + so_far + "]");
        so_far = vpc.getPad().getPadded(goal_len, so_far);
        vpc.getDebugAptr().appentln("<VPC> chop-first: Padded:  [" + so_far + "]");
    }
    to_appendTo.append(so_far);
}

From source file:com.google.walkaround.wave.server.servlet.UndercurrentHandler.java

private HtmlClosure inlineNocacheJs() {
    return new HtmlClosure() {
        @Override/*from w w w.j  ava  2  s  . c  o m*/
        public void write(Appendable out, GxpContext gxpContext) throws IOException {
            out.append("<script type='text/javascript'>\n");
            // No need to escape this, GWT's nocache javascript is already escaped for
            // the purpose of direct inclusion into script elements.
            out.append(nocacheJs);
            out.append("</script>");
        }
    };
}

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

private void convertTrades(final Appendable buffer, final TradesVO tradesVO, final long totalTrades)
        throws IOException {

    buffer.append(" count=" + tradesVO.getCount());
    if (tradesVO.getCount() != totalTrades) {
        buffer.append("(" + twoDigitFormat.format(100.0 * tradesVO.getCount() / totalTrades) + "%)");
    }//from w  w w.  ja  va2  s .  co  m
    buffer.append(" totalProfit=" + twoDigitFormat.format(tradesVO.getTotalProfit()));
    buffer.append(" avgProfit=" + twoDigitFormat.format(tradesVO.getAvgProfit()));
    buffer.append(" avgProfitPct=" + twoDigitFormat.format(tradesVO.getAvgProfitPct() * 100) + "%");
    buffer.append("\r\n");
}

From source file:at.ac.univie.isc.asio.web.HttpServer.java

@Override
public Appendable appendTo(final Appendable sink) throws IOException {
    sink.append(capturedExchanges);
    capturedExchanges.setLength(0);//from   w w  w.j av a  2  s.c om
    return sink;
}