Example usage for java.io StringWriter append

List of usage examples for java.io StringWriter append

Introduction

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

Prototype

public StringWriter append(char c) 

Source Link

Document

Appends the specified character to this writer.

Usage

From source file:org.n0pe.asadmin.commands.CreateAuthRealm.java

public String[] getParameters() {
    if (StringUtils.isEmpty(className)) {
        throw new IllegalStateException();
    }/*from  www.j  a  v  a 2 s. co  m*/
    final String[] params;
    if (properties != null && !properties.isEmpty()) {
        final StringWriter sw = new StringWriter();
        String key;
        for (final Iterator it = properties.keySet().iterator(); it.hasNext();) {
            key = (String) it.next();
            sw.append(key).append("=").append(Util.quoteCommandArgument((String) properties.get(key)));
            if (it.hasNext()) {
                sw.append(":");
            }
        }
        params = new String[] { CLASSNAME_OPT, className, PROPERTY_OPT, sw.toString(), realmName };

    } else {
        params = new String[] { CLASSNAME_OPT, className, realmName };
    }
    return params;
}

From source file:org.betaconceptframework.astroboa.serializer.XmlSerializer.java

public XmlSerializer(StringWriter writer, boolean prettyPrint) {

    this.prettyPrint = prettyPrint;

    this.writer = writer;

    writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");

    number_of_spaces_to_use_for_identation.push(1);

}

From source file:com.scistor.tab.auth.licensing.LicenseValidator.java

public License decryptAndVerifyLicense(InputStream inputStream) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
    StringWriter writer = null;
    while (true) {
        String line = reader.readLine();
        if (line.startsWith("------ END")) {
            break;
        }//from   www .  jav a2 s. c  o  m
        if (writer != null) {
            writer.append(line);
        }
        if (line.trim().isEmpty()) {
            writer = new StringWriter(1024);
        }
    }

    byte[] licenseData = Base64.decodeBase64(writer.toString());
    SignedLicense signedLicense = (SignedLicense) new ObjectSerializer().readObject(SignedLicense.class,
            licenseData);
    return LicenseManager.getInstance().decryptAndVerifyLicense(signedLicense);
}

From source file:org.rascalmpl.library.experiments.Compiler.RVM.Interpreter.help.HelpManager.java

void genSearchTerms(String[] words, StringWriter w) {
    w.append("<i>");
    for (int i = 1; i < words.length; i++) {
        w.append(words[i]).append(" ");
    }/*from   ww w .  j  av a 2 s.  co m*/
    w.append("</i>\n");
}

From source file:edu.harvard.i2b2.eclipse.plugins.patientSet.workplaceMessaging.WorkplaceRequestData.java

/**
 * Function to generate i2b2 message header message number
 * /*w  w  w  .j a  v a2 s  .co m*/
 * @return String
 */
public String generateMessageId() {
    StringWriter strWriter = new StringWriter();
    for (int i = 0; i < 20; i++) {
        int num = getValidAcsiiValue();
        strWriter.append((char) num);
    }
    return strWriter.toString();
}

From source file:org.springframework.integration.handler.LoggingHandler.java

private Object createLogMessage(Message<?> message) {
    Object logMessage = this.expression.getValue(this.evaluationContext, message);
    if (logMessage instanceof Throwable) {
        StringWriter stringWriter = new StringWriter();
        if (logMessage instanceof AggregateMessageDeliveryException) {
            stringWriter.append(((Throwable) logMessage).getMessage());
            for (Exception exception : ((AggregateMessageDeliveryException) logMessage)
                    .getAggregatedExceptions()) {
                exception.printStackTrace(new PrintWriter(stringWriter, true));
            }/*from   w w  w.j  a  v  a2s . co m*/
        } else {
            ((Throwable) logMessage).printStackTrace(new PrintWriter(stringWriter, true));
        }
        logMessage = stringWriter.toString();
    }
    return logMessage;
}

From source file:com.espertech.esper.epl.expression.ExprEvaluatorProxy.java

public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {

    if (m.equals(targetEvaluate)) {
        Object result = m.invoke(evaluator, args);
        if (auditLog.isInfoEnabled()) {
            auditLog.info(//from   w ww. j  a  v  a 2 s  . c  o m
                    "Statement " + statementName + " expression " + expressionToString + " result " + result);
        }
        return result;
    }

    if (m.equals(targetEvaluateCollEvents)) {
        Object result = m.invoke(evaluator, args);
        if (auditLog.isInfoEnabled()) {
            Collection<EventBean> resultBeans = (Collection<EventBean>) result;
            String out = "null";
            if (resultBeans != null) {
                if (resultBeans.isEmpty()) {
                    out = "{}";
                } else {
                    StringWriter buf = new StringWriter();
                    int count = 0;
                    for (EventBean event : resultBeans) {
                        buf.append(" Event ");
                        buf.append(Integer.toString(count++));
                        buf.append(":");
                        EventBeanUtility.appendEvent(buf, event);
                    }
                    out = buf.toString();
                }
            }
            auditLog.info(
                    "Statement " + statementName + " expression " + expressionToString + " result " + out);
        }
        return result;
    }

    if (m.equals(targetEvaluateCollScalar)) {
        Object result = m.invoke(evaluator, args);
        if (auditLog.isInfoEnabled()) {
            auditLog.info(
                    "Statement " + statementName + " expression " + expressionToString + " result " + result);
        }
        return result;
    }

    if (m.equals(targetEvaluateBean)) {
        Object result = m.invoke(evaluator, args);
        if (auditLog.isInfoEnabled()) {
            String out = "null";
            if (result != null) {
                StringWriter buf = new StringWriter();
                EventBeanUtility.appendEvent(buf, (EventBean) result);
                out = buf.toString();
            }
            auditLog.info(
                    "Statement " + statementName + " expression " + expressionToString + " result " + out);
        }
        return result;
    }
    return m.invoke(evaluator, args);
}

From source file:de.quist.samy.remocon.RemoteSession.java

private String getTextPayload(String text) throws IOException {
    StringWriter writer = new StringWriter();
    writer.append((char) 0x01);
    writer.append((char) 0x00);
    writeBase64Text(writer, text);
    writer.flush();// www  .ja va  2  s  . c  o  m
    return writer.toString();
}

From source file:de.quist.samy.remocon.RemoteSession.java

private String getKeyPayload(Key key) throws IOException {
    StringWriter writer = new StringWriter();
    writer.append((char) 0x00);
    writer.append((char) 0x00);
    writer.append((char) 0x00);
    writeBase64Text(writer, key.getValue());
    writer.flush();//from www .j ava  2 s.  com
    return writer.toString();
}

From source file:org.rascalmpl.library.experiments.Compiler.RVM.Interpreter.help.HelpManager.java

void genPrelude(StringWriter w) {
    w.append("<head>\n");
    w.append("<title>Rascal Help</title>");
    w.append("<link rel=\"stylesheet\" href=\"css/style.css\"/>");
    w.append("<link rel=\"stylesheet\" href=\"css/font-awesome.min.css\"/>");
    w.append("<link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\"/>");
    w.append("</head>\n");
    w.append("<body class=\"book toc2 toc-left\">");

    w.append(Concept.getHomeLink());/* w ww.j av a 2  s .  c  om*/
    w.append(Concept.getSearchForm());

    w.append("<div id=\"toc\" class=\"toc2\">");
    w.append("</div>");
}