Example usage for java.io Writer append

List of usage examples for java.io Writer append

Introduction

In this page you can find the example usage for java.io Writer append.

Prototype

public Writer append(char c) throws IOException 

Source Link

Document

Appends the specified character to this writer.

Usage

From source file:com.igormaznitsa.mindmap.model.Extra.java

public final void write(@Nonnull final Writer out) throws IOException {
    out.append("- ").append(getType().name()).append(NEXT_LINE); //NOI18N
    out.append(ModelUtils.makePreBlock(provideAsStringForSave()));
}

From source file:com.bstek.dorado.view.TopViewOutputter.java

@Override
public void output(Object object, OutputContext context) throws Exception {
    View view = (View) object;
    if (StringUtils.isEmpty(view.getId())) {
        view.setId("viewMain");
    }/*from   ww  w.j  a  v  a 2s . co m*/

    context.addDependsPackage("widget");

    DoradoContext doradoContext = DoradoContext.getCurrent();
    int currentClientType = VariantUtils.toInt(doradoContext.getAttribute(ClientType.CURRENT_CLIENT_TYPE_KEY));
    if ((currentClientType == 0 || ClientType.supports(currentClientType, ClientType.DESKTOP))
            && WebConfigure.getBoolean("view.debugEnabled")) {
        context.addDependsPackage("debugger");
    }

    Writer writer = context.getWriter();
    writer.append("dorado.onInit(function(){\n");
    writer.append("try{\n");

    ViewOutputter outputter = (ViewOutputter) clientOutputHelper.getOutputter(view.getClass());
    outputter.outputView(view, context);

    writer.append("view.set(\"renderOn\",\"#doradoView\");\n");

    ViewRenderMode renderMode = view.getRenderMode();
    if (renderMode == ViewRenderMode.onCreate) {
        writer.append("view.render();\n");
    } else if (renderMode == ViewRenderMode.onDataLoaded) {
        writer.append("view.loadData();\n");
    }

    writer.append("}\n").append("catch(e){").append("dorado.Exception.processException(e);}\n");
    writer.append("});\n");

    context.addDependsPackage("common");

    Set<String> dependsPackages = context.getDependsPackages();
    if (dependsPackages != null && !dependsPackages.isEmpty()) {
        writer.append("$import(\"").append(StringUtils.join(dependsPackages, ',')).append("\");\n");
    }
}

From source file:org.formix.dsx.XmlText.java

@Override
public void write(Writer writer) throws IOException {
    writer.append(this.toXml());
}

From source file:org.jboss.windup.reporting.html.freemarker.SourceModificationSerializer.java

@Override
public void execute(Environment env, Map map, TemplateModel[] templateModel,
        TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {

    if (!map.containsKey("modification")) {
        return;/*from   w  ww.  j a v  a 2  s  .c o  m*/
    }
    if (map.get("modification") == null) {
        return;
    }
    SimpleSequence stringModel = (SimpleSequence) map.get("modification");

    List<Boolean> sourceModification = stringModel.toList();

    Writer writer = env.getOut();
    if (sourceModification != null) {
        writer.append("<div class='sourceView'>");
        for (Boolean sourceMod : sourceModification) {
            writer.append("<div class='sourceBlock ");
            if (sourceMod) {
                writer.append("redSourceBlock");
            } else {
                writer.append("greenSourceBlock");
            }
            writer.append("'></div>");
        }
        writer.append("</div>");
    }
}

From source file:com.android.email.mail.transport.Rfc822Output.java

/**
 * Write a single attachment and its payload
 *///from ww  w .j a v a 2s . c  om
private static void writeOneAttachment(Context context, Writer writer, OutputStream out, Attachment attachment)
        throws IOException, MessagingException {
    writeHeader(writer, "Content-Type", attachment.mMimeType + ";\n name=\"" + attachment.mFileName + "\"");
    writeHeader(writer, "Content-Transfer-Encoding", "base64");
    // Most attachments (real files) will send Content-Disposition.  The suppression option
    // is used when sending calendar invites.
    if ((attachment.mFlags & Attachment.FLAG_ICS_ALTERNATIVE_PART) == 0) {
        writeHeader(writer, "Content-Disposition", "attachment;" + "\n filename=\"" + attachment.mFileName
                + "\";" + "\n size=" + Long.toString(attachment.mSize));
    }
    writeHeader(writer, "Content-ID", attachment.mContentId);
    writer.append("\r\n");

    // Set up input stream and write it out via base64
    InputStream inStream = null;
    try {
        // Use content, if provided; otherwise, use the contentUri
        if (attachment.mContentBytes != null) {
            inStream = new ByteArrayInputStream(attachment.mContentBytes);
        } else {
            // try to open the file
            Uri fileUri = Uri.parse(attachment.mContentUri);
            inStream = context.getContentResolver().openInputStream(fileUri);
        }
        // switch to output stream for base64 text output
        writer.flush();
        Base64OutputStream base64Out = new Base64OutputStream(out, Base64.CRLF | Base64.NO_CLOSE);
        // copy base64 data and close up
        IOUtils.copy(inStream, base64Out);
        base64Out.close();

        // The old Base64OutputStream wrote an extra CRLF after
        // the output.  It's not required by the base-64 spec; not
        // sure if it's required by RFC 822 or not.
        out.write('\r');
        out.write('\n');
        out.flush();
    } catch (FileNotFoundException fnfe) {
        // Ignore this - empty file is OK
    } catch (IOException ioe) {
        throw new MessagingException("Invalid attachment.", ioe);
    }
}

From source file:uniol.apt.ui.impl.returns.IsomorphismReturnValueTransformation.java

@Override
public void transform(Writer output, Isomorphism isomorphism) throws IOException {
    boolean first = true;

    output.append("[");
    MapIterator<State, State> iterator = isomorphism.mapIterator();
    while (iterator.hasNext()) {
        State n = iterator.next();
        State m = iterator.getValue();
        if (!first)
            output.append(", ");
        output.append(n.getId());/*from  w ww. j  a v  a2 s .com*/
        output.append("=");
        output.append(m.getId());
        first = false;
    }

    output.append("]");
}

From source file:com.bstek.dorado.view.resolver.DefaultClientSettingsOutputter.java

@Override
public void output(Writer writer) throws IOException {
    DoradoContext context = DoradoContext.getCurrent();

    writer.append("\"common.debugEnabled\":").append(String.valueOf(Configure.getBoolean("view.debugEnabled")));

    writeSetting(writer, "common.showExceptionStackTrace", Configure.getBoolean("view.showExceptionStackTrace"),
            false);//from  w  w w . ja va2s . com
    writeSetting(writer, "common.enterAsTab", Configure.getBoolean("view.enterAsTab"), false);
    writeSetting(writer, "common.preventBackspace", Configure.getBoolean("view.preventBackspace"), true);

    String contextPath = Configure.getString("web.contextPath");
    if (StringUtils.isEmpty(contextPath)) {
        contextPath = context.getRequest().getContextPath();
    }
    writeSetting(writer, "common.contextPath", contextPath, true);

    writeSetting(writer, "common.abortAsyncLoadingOnSyncLoading",
            Configure.getBoolean("view.abortAsyncLoadingOnSyncLoading"), false);

    writeSetting(writer, "widget.skinRoot", ">dorado/client/skins/", true);
    writeSetting(writer, "widget.skin", context.getAttribute("view.skin"), true);
}

From source file:com.cloudera.oryx.rdf.serving.generation.RDFGenerationManager.java

public synchronized void append(CharSequence example) throws IOException {
    Writer appender = getAppender();
    if (appender != null) {
        appender.append(example + "\n");
    }/* w  w  w  .ja v a 2s .co  m*/
    decrementCountdownToUpload();
}

From source file:org.sonar.api.profiles.XMLProfileSerializer.java

private void appendFooter(Writer writer) throws IOException {
    writer.append("</profile>");
}

From source file:org.sonar.api.profiles.XMLProfileSerializer.java

private void appendHeader(RulesProfile profile, Writer writer) throws IOException {
    writer.append(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!-- Generated by Sonar -->" + "<profile><name>");
    StringEscapeUtils.escapeXml(writer, profile.getName());
    writer.append("</name><language>");
    StringEscapeUtils.escapeXml(writer, profile.getLanguage());
    writer.append("</language>");
}