当前位置: 首页>>代码示例>>Java>>正文


Java StringWriter.append方法代码示例

本文整理汇总了Java中java.io.StringWriter.append方法的典型用法代码示例。如果您正苦于以下问题:Java StringWriter.append方法的具体用法?Java StringWriter.append怎么用?Java StringWriter.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.StringWriter的用法示例。


在下文中一共展示了StringWriter.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createChecksumContent

import java.io.StringWriter; //导入方法依赖的package包/类
protected ContentProvider createChecksumContent () throws IOException
{
    if ( this.checkSums.isEmpty () )
    {
        return ContentProvider.NULL_CONTENT;
    }

    final StringWriter sw = new StringWriter ();

    for ( final Map.Entry<String, String> entry : this.checkSums.entrySet () )
    {
        final String filename = entry.getKey ().substring ( 2 ); // without the leading dot and slash

        sw.append ( entry.getValue () );
        sw.append ( "  " );
        sw.append ( filename );
        sw.append ( '\n' );
    }

    sw.close ();

    return new StaticContentProvider ( sw.toString () );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:DebianPackageWriter.java

示例2: createLocalNew

import java.io.StringWriter; //导入方法依赖的package包/类
private static String createLocalNew(final Class<? extends Invoke> type, final Function fxn) {
    final String identifier = makeInstanceName(fxn);
    StringWriter out = new StringWriter();

    out.append(String.format("%3$s[] argCoders = new %3$s[%1$d + %2$s.length];\n", fxn.args.size(), VARARGS_NAME, Coder.class.getCanonicalName()));

    for(int i = 0; i < fxn.args.size(); i++)
        out.append(String.format("argCoders[%1$d] = %2$s;\n", i, fxn.args.get(0).type.getJType().getCoderDescriptor().getCoderInstanceName()));

    if(fxn.variadic){
        out.append(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)\n", fxn.args.size(), VARARGS_NAME));
        out.append(String.format("\targCoders[i] = %1$s.getCoderAtRuntime(%2$s[i - %3$s]);\n", Coder.class.getCanonicalName(), VARARGS_NAME, fxn.args.size()));
    }

    out.append("final " + type.getCanonicalName() + " " + identifier + " = new " + type.getCanonicalName() + "(" + firstArg(fxn) + ", \"" + fxn.name + "\", "
            + fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName() + ", argCoders);");

    return out.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:FunctionGenerator.java

示例3: _outputSVGDocumentCreate

import java.io.StringWriter; //导入方法依赖的package包/类
protected void _outputSVGDocumentCreate(
  FacesContext context,
  StringWriter sw,
  UIComponent  component,
  FacesBean    bean
  ) throws IOException
{
  sw.append("ApacheChart.createSVG(\"");
  String clientId = component.getClientId(context);
  sw.append(clientId);
  sw.append("\",\"svgChart");
  sw.append(clientId);
  sw.append("\",\"");
  String templateURL = getTemplateSource(component, bean);
  templateURL = context.getExternalContext().encodeResourceURL(templateURL);
  sw.append(templateURL);
  sw.append("\",\"width:100%; height:100%;\"");
  sw.append(",null);\n");
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:ChartRenderer.java

示例4: escapeAndAppendString

import java.io.StringWriter; //导入方法依赖的package包/类
private static void escapeAndAppendString(final String string, final StringWriter writer) {
    final int N = string.length();
    final char NE = (char)ESCAPE_TABLE.length;
    final String[] escapes = ESCAPE_TABLE;
    int lastPos = 0;
    int pos;
    for (pos=0; pos<N; pos++) {
        char c = string.charAt(pos);
        if (c >= NE) continue;
        String escape = escapes[c];
        if (escape == null) continue;
        if (lastPos < pos) writer.append(string, lastPos, pos);
        lastPos = pos + 1;
        writer.append(escape);
    }
    if (lastPos < pos) writer.append(string, lastPos, pos);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:18,代码来源:XmlDb.java

示例5: generateVersionXMLFiles

import java.io.StringWriter; //导入方法依赖的package包/类
private void generateVersionXMLFiles() throws IOException {
    FileSet fs = new FileSet();
    fs.setIncludes("**/*.jar");
    for (File directory : jarDirectories) {
        fs.setDir(directory);
        DirectoryScanner scan = fs.getDirectoryScanner(getProject());
        StringWriter writeVersionXML = new StringWriter();
        writeVersionXML.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        writeVersionXML.append("<jnlp-versions>\n");
        for (String jarName : scan.getIncludedFiles()) {
            File jar = new File(scan.getBasedir(), jarName);
            JarFile jarFile = new JarFile(jar);
            String version = getJarVersion(jarFile);
            if (version != null) {
                writeVersionXML.append("    <resource>\n        <pattern>\n            <name>");
                writeVersionXML.append(jar.getName());
                writeVersionXML.append("</name>\n            <version-id>");
                writeVersionXML.append(version);
                writeVersionXML.append("</version-id>\n        </pattern>\n        <file>");
                writeVersionXML.append(jar.getName());
                writeVersionXML.append("</file>\n    </resource>\n");
            } else {
                writeVersionXML.append("    <!-- No version found for ");
                writeVersionXML.append(jar.getName());
                writeVersionXML.append(" -->\n");
            }
        }
        writeVersionXML.append("</jnlp-versions>\n");
        writeVersionXML.close();

        File versionXML = new File(directory, "version.xml");
        FileWriter w = new FileWriter(versionXML);
        w.write(writeVersionXML.toString());
        w.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:MakeJNLP.java

示例6: generateEdgeLine

import java.io.StringWriter; //导入方法依赖的package包/类
public static void generateEdgeLine(StringWriter sw, ObjectMapper mapper, EdgeBean eBean) throws JsonGenerationException, JsonMappingException, IOException {
    sw.getBuffer().setLength(0);
    
    sw.append('E'); // Record type
    sw.append('=');
    
    mapper.writeValue(sw, eBean);
    
    sw.append('#');
    
    int hashCode = sw.toString().hashCode(); 
    sw.append(toHex(hashCode));
    sw.append('\n');
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:15,代码来源:Record.java

示例7: printStruct

import java.io.StringWriter; //导入方法依赖的package包/类
protected String printStruct(NStruct nt, char open, char close){
    StringWriter sw = new StringWriter();
    sw.append(open);
    sw.append(nt.name);
    if(nt.fields.size() > 0){
        sw.append('=');
        for(NField f : nt.fields){
            if(f.name != null && f.name.length() > 0)
                sw.append("\"" + f.name + "\"");
            sw.append(print(f.type));
        }
    }
    sw.append(close);
    return sw.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:NTypePrinter.java

示例8: handleRequestInternal

import java.io.StringWriter; //导入方法依赖的package包/类
/**
 * Handle request.
 *
 * @param request the request
 * @param response the response
 * @return the model and view
 * @throws Exception the exception
 */
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(
        final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

    final Map<String, Object> list = getBeans(this.applicationContext);
    LOGGER.debug("Found [{}] beans to report", list.size());

    final JsonSerializer<Object> serializer = new BeanObjectJsonSerializer();
    final StringBuilder builder = new StringBuilder();
    builder.append('[');

    final Set<Map.Entry<String, Object>> entries = list.entrySet();
    final Iterator<Map.Entry<String, Object>> it = entries.iterator();

    while (it.hasNext()) {
        final Map.Entry<String, Object> entry = it.next();
        final Object obj = entry.getValue();

        final StringWriter writer = new StringWriter();
        writer.append('{');
        writer.append('\"' + entry.getKey() + "\":");
        serializer.toJson(writer, obj);
        writer.append('}');
        builder.append(writer);

        if (it.hasNext()) {
            builder.append(',');
        }
    }
    builder.append(']');
    final ModelAndView mv = new ModelAndView(VIEW_CONFIG);
    final String jsonData = StringEscapeUtils.escapeJson(builder.toString());

    mv.addObject("jsonData", jsonData);
    mv.addObject("properties", casProperties.entrySet());
    return mv;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:47,代码来源:InternalConfigStateController.java

示例9: preprocess

import java.io.StringWriter; //导入方法依赖的package包/类
private StringWriter preprocess(final Path filePath, final String currentIndent) throws IOException {
    final StringWriter stringWriter = new StringWriter();

    for (final String line : Files.readAllLines(filePath)) {
        final Matcher matcher = INCLUDE_TAG_PATTERN.matcher(line);

        if (line.startsWith("extends:")) {
            stringWriter.append(line).append("?include").append("\n");
            continue;
        }
        if (!line.startsWith("#%RAML 1.0 DataType")) {
            if (matcher.matches()) {
                final String indent = matcher.group(1) + "  ";
                final Path includePath = filePath.getParent().resolve(matcher.group(3));
                stringWriter.append(currentIndent).append(matcher.group(1)).append(matcher.group(2));
                if (!includePath.getFileName().toString().endsWith(".raml")) {
                    stringWriter.append(" |");
                }
                stringWriter.append("\n");
                final StringWriter includeWriter = preprocess(includePath, currentIndent + indent);
                stringWriter.append(includeWriter.toString()).append("\n");
            } else {
                stringWriter.append(currentIndent).append(line).append("\n");
            }
        }
    }
    return stringWriter;
}
 
开发者ID:vrapio,项目名称:vrap,代码行数:29,代码来源:IncludeResolver.java

示例10: _writeJSColor

import java.io.StringWriter; //导入方法依赖的package包/类
/**
 * Encodes a Color in JavaScript Object Notation.
 *
 * @param sw           the StringWriter
 * @param color        the color value
 */
static private void _writeJSColor(
  StringWriter sw,
  Color        color
  ) throws IOException
{
  sw.append("\"RGB(");
  sw.append(String.valueOf(color.getRed()));
  sw.append(",");
  sw.append(String.valueOf(color.getGreen()));
  sw.append(",");
  sw.append(String.valueOf(color.getBlue()));
  sw.append(")\"");
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:ChartRenderer.java

示例11: describeBest

import java.io.StringWriter; //导入方法依赖的package包/类
public String describeBest() {
    Solver<ConferenceData> solver = this.solver;
    if (solver == null) {
        return "";
    }
    ConferenceData currentBest = solver.getBestSolution();
    if (currentBest == prevBest) {
        return prevBestDescr;
    }
    prevBest = currentBest;
    currentBest.sort();

    StringWriter sw = new StringWriter();

    ScoreDirector<ConferenceData> scorer = solver.getScoreDirectorFactory().buildScoreDirector();
    scorer.setWorkingSolution(currentBest);
    Collection<ConstraintMatchTotal> totals = scorer.getConstraintMatchTotals();
    Map<Object, Indictment> map = scorer.getIndictmentMap();

    sw.append("<html><body style='font-family:monospace'>");
    for (ConstraintMatchTotal total : totals) {
        sw.append(String.valueOf(total.getScoreTotal())).append("\t").append(total.getConstraintName()).append("<br>");
    }
    sw.append("<br>");
    currentBest.print(sw, map);
    sw.append("</body></html>");
    prevBestDescr = sw.toString();
    return prevBestDescr;
}
 
开发者ID:vlsi,项目名称:confplanner,代码行数:30,代码来源:SolverAction.java

示例12: publishHtmlReport

import java.io.StringWriter; //导入方法依赖的package包/类
public void publishHtmlReport(StringWriter writer)
{
    final int failedNumber = getTestCaseNumber(NumberType.FAILED);
    writer.append("\n\n<h1>" + scriptContent + "</h1>\n");
    writer.append("<p><b>Name</b>: " + scriptName + "</p>\n");
    writer.append("<p><b>Number of test cases</b>: " + getTestCaseNumber(NumberType.TOTAL) + "</p>\n");
    writer.append("<table border = \"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
    String title = "    <tr>";
    for (String t : TestCase.PARAMETERS)
    {
        title += "<td><b>" + t + "</b></td>";
    }
    title += "</tr>\n";
    writer.append(title);
    for (TestCase tc : testCases)
    {
        tc.publishHtmlReport(writer);
    }
    writer.append("</table>\n");
    String status = "<p><b>Status</b>: ";
    if (failedNumber == 0)
    {
        status += "<font color=\"green\">PASSED</font>";
    }
    else
    {
        status += "<font color=\"red\">FAILED</font>";
    }
    status += " (passed: " + getTestCaseNumber(NumberType.PASSED) + ", failed: " + failedNumber + ")</p>\n";
    writer.append(status);
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:32,代码来源:TestScript.java

示例13: objCEncoding

import java.io.StringWriter; //导入方法依赖的package包/类
private static String objCEncoding(final Coder[] elementCoders) {
    StringWriter str = new StringWriter();
    str.append("{?=");
    for(Coder c : elementCoders)
        str.append(c.getObjCEncoding());
    str.append("}");
    return str.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:Coder.java

示例14: _writeJSDouble

import java.io.StringWriter; //导入方法依赖的package包/类
/**
 * Encodes a float in JavaScript Object Notation.
 *
 * @param sw           the StringWriter
 * @param value         the float value
 */
static private void _writeJSDouble(
  StringWriter sw,
  Double       value
  ) throws IOException
{
  sw.append(String.valueOf(value));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:14,代码来源:ChartRenderer.java

示例15: _writeJSObject

import java.io.StringWriter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static private void _writeJSObject(
  StringWriter sw,
  Object       attrValue
  ) throws IOException
{
  if (attrValue == null)
  {
    sw.append("null");
  }
  else
  {
    if (attrValue instanceof String)
    {
      _writeJSString(sw, ((String)attrValue));
      return;
    }
    Class valueClass = attrValue.getClass();
    if (Boolean.class == valueClass)
    {
      _writeJSBoolean(sw, (Boolean)attrValue);
    }
    else if (Integer.class == valueClass)
    {
      _writeJSInt(sw, (Integer)attrValue);
    }
    else if (Double.class == valueClass)
    {
      _writeJSDouble(sw, (Double)attrValue);
    }
    else if (Color.class == valueClass)
    {
      _writeJSColor(sw, ((Color)attrValue));
    }
    else if (Collection.class.isAssignableFrom(valueClass))
    {
      _writeJSCollection(sw, ((Collection)attrValue));
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:41,代码来源:ChartRenderer.java


注:本文中的java.io.StringWriter.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。