本文整理汇总了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 () );
}
示例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();
}
示例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");
}
示例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);
}
示例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();
}
}
示例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');
}
示例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();
}
示例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;
}
示例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(")\"");
}
示例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;
}
示例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);
}
示例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();
}
示例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));
}
示例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));
}
}
}