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


Java StrBuilder类代码示例

本文整理汇总了Java中org.apache.commons.lang3.text.StrBuilder的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder类的具体用法?Java StrBuilder怎么用?Java StrBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sendXMLHttpGETRequest

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
public JsonElement sendXMLHttpGETRequest( final String url, final boolean async )
{
    ( ( EventFiringWebDriver ) driver ).manage().timeouts().setScriptTimeout( 20, TimeUnit.SECONDS );
    StrBuilder builder = new StrBuilder( "var callback = arguments[arguments.length - 1];\n" );
    builder.appendln( "var xhr = new XMLHttpRequest();" );
    builder.append( "xhr.open( 'GET', '" ).append( url ).append( "', '" ).append( async ).append( "' );" );
    builder.appendln( "xhr.onreadystatechange = function() { " );
    builder.appendln( "  if (xhr.readyState == 4) { " );
    builder.appendln( "    callback(xhr.responseText);" );
    builder.appendln( "  }" );
    builder.appendln( "}" );
    builder.appendln( "xhr.send();" );

    Object response = executeAsyncScript( builder.toString() );
    Gson gson = new Gson();
    return gson.fromJson( ( String ) response, JsonElement.class );
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:18,代码来源:JavaScriptHelper.java

示例2: readFileWithFileSizeBuffer

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
public static StrBuilder readFileWithFileSizeBuffer(Path file ) throws IOException
{
    FileChannel inChannel = null;
    RandomAccessFile aFile = null;
    StrBuilder builder = new StrBuilder();
    try
    {
        aFile = new RandomAccessFile( file.toString(), "r" );
        inChannel = aFile.getChannel();
        long fileSize = inChannel.size();
        ByteBuffer buffer = ByteBuffer.allocate( ( int ) fileSize );
        inChannel.read( buffer );
        buffer.flip();
        for ( int i = 0; i < fileSize; i++ )
        {
            builder.append( ( char ) buffer.get() );
        }

        return builder.trim();
    }
    finally
    {
        if( null != inChannel ) inChannel.close();
        if( null != aFile ) aFile.close();
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:27,代码来源:FileUtils.java

示例3: amcast

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
/**
 * Atomically multicast command.
 * 
 * @param command
 * @return A FutureDecision that can be waited on
 */
public void amcast(Command command) throws FSError {
	// right now, it either sends to the given partition or to the global
	// ring
	byte ringid = GLOBAL_RING;
	if (command.getInvolvedPartitions().size() == 1) {
		ringid = command.getInvolvedPartitions().iterator().next().byteValue();
	}
	// TODO: right now its not possible to submit to rings the replica is
	// not part of. Make the replica act as a proxy to one of the responsible replicas?
	log.debug(new StrBuilder().append("Submitting command to ring ").append(ringid).toString());
	Proposer p = this.proposers.get(Byte.valueOf(ringid));
	// TSerializer is not threadsafe, create a new one for each amcast. Is
	// this too expensive?
	final TSerializer serializer = new TSerializer();
	try {
		p.propose(serializer.serialize(command));
	} catch (TException e) {
		e.printStackTrace();
		throw new FSError(Errno.EREMOTEIO, "Error serializing message");
	}
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:28,代码来源:CommunicationService.java

示例4: applyRelease

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyRelease(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("release ").append(c.getRelease().getPath()).toString());
	ReleaseCmd rel = c.getRelease();
	FileNode f = openFiles.remove(Long.valueOf(rel.getFileHandle().getId()));
	if (f == null) {
           throw new FSError(FuseException.EBADF, "Bad file descriptor");
       }

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }

	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:21,代码来源:FileSystemReplica.java

示例5: applyTruncate

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyTruncate(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("truncate ").append(c.getTruncate().getPath()).toString());
	TruncateCmd t = c.getTruncate();
	Node f = fs.get(t.getPath());
	if (f == null) {
           throw new FSError(FuseException.ENOENT, "File not found");
       } else if (!f.isFile()) {
           throw new FSError(FuseException.EINVAL, "Not a file");
       }
	((FileNode) f).truncate(t.getSize());
	f.getAttributes().setCtime(c.getReqTime());
	f.getAttributes().setMtime(c.getReqTime());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }

	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:26,代码来源:FileSystemReplica.java

示例6: applyChmod

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyChmod(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("chmod ").append(c.getChmod().getPath()).toString());
	ChmodCmd chmod = c.getChmod();
	Node f = fs.get(chmod.getPath());
	if (f == null) {
           throw new FSError(FuseException.ENOENT, "File not found");
       }
	f.getAttributes().setMode(chmod.getMode());
	f.getAttributes().setCtime(c.getReqTime());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }
	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:22,代码来源:FileSystemReplica.java

示例7: applyReadlink

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyReadlink(Command c, CommandResult res) throws FSError {
    log.debug(new StrBuilder().append("readlink ").append(c.getReadlink().getPath()).toString());

    Node n = fs.get(c.getReadlink().getPath());
    if (!n.isLink()) {
        throw new FSError(FuseException.ENOLINK, "Not a link");
    }
    String response = ((LinkNode) n).getTarget();

    if (c.getInvolvedPartitions().size() > 1) {
        // wait for other signals
        for (Byte part : c.getInvolvedPartitions()) {
            if (part == localPartition)
                continue;
            //this.waitForSignal(c.getReqId(), part.byteValue());
        }
    }
    res.setSuccess(true);
    res.setResponse(response);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:21,代码来源:FileSystemReplica.java

示例8: applyRmdir

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyRmdir(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("rmdir ").append(c.getRmdir().getPath()).toString());

	fs.removeDir(c.getRmdir().getPath());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }
	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:17,代码来源:FileSystemReplica.java

示例9: applyUnlink

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyUnlink(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("unlink ").append(c.getUnlink().getPath()).toString());

	fs.removeFileOrLink(c.getUnlink().getPath());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }
	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:17,代码来源:FileSystemReplica.java

示例10: applyMkdir

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyMkdir(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("mkdir ").append(c.getMkdir().getPath()).toString());

	fs.createDir(c.getMkdir().getPath(), c.getMkdir().getMode(), c.getReqTime(), c.getMkdir().getUid(), c.getMkdir().getGid());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }
	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:17,代码来源:FileSystemReplica.java

示例11: applyGetdir

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyGetdir(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("getdir ").append(c.getGetdir().getPath()).toString());

	Node n = fs.get(c.getGetdir().getPath());
	if (!n.isDir()) {
           throw new FSError(FuseException.ENOTDIR, "Not a directory");
       }
	DirNode dir = (DirNode) n;

	List<DirEntry> entries = new LinkedList<DirEntry>();
	for (String child : dir.getChildren()) {
           entries.add(new DirEntry(child, 0, dir.getChild(child).typeMode()));
       }

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }

	res.setSuccess(true);
	res.setResponse(entries);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:27,代码来源:FileSystemReplica.java

示例12: applyMknod

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private void applyMknod(Command c, CommandResult res) throws FSError {
	log.debug(new StrBuilder().append("mknod ").append(c.getMknod().getPath()).toString());
	// if the create fails here, there is no need for signals,
	// the other partitions also fail
	fs.createFile(c.getMknod().getPath(), c.getMknod().getMode(), c.getReqTime(), c.getMknod().getUid(), c.getMknod().getGid());

	if (c.getInvolvedPartitions().size() > 1) {
           // wait for other signals
           for (Byte part : c.getInvolvedPartitions()) {
               if (part == localPartition)
                   continue;
               //this.waitForSignal(c.getReqId(), part.byteValue());
           }
       }
	res.setSuccess(true);
	res.setResponse(null);
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:18,代码来源:FileSystemReplica.java

示例13: getAlgorithmsListing

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
/**
 * List available algorithms. This is displayed to the user when no valid
 * algorithm is given in the program parameterization.
 *
 * @return usage string listing available algorithms
 */
private static String getAlgorithmsListing() {
	StrBuilder strBuilder = new StrBuilder();

	strBuilder
		.appendNewLine()
		.appendln("Select an algorithm to view usage: flink run examples/flink-gelly-examples_<version>.jar --algorithm <algorithm>")
		.appendNewLine()
		.appendln("Available algorithms:");

	for (Driver algorithm : driverFactory) {
		strBuilder.append("  ")
			.appendFixedWidthPadRight(algorithm.getName(), 30, ' ')
			.append(algorithm.getShortDescription()).appendNewLine();
	}

	return strBuilder.toString();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:Runner.java

示例14: getUsage

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
private static String getUsage(String message) {
	return new StrBuilder()
		.appendNewLine()
		.appendln("A Graph500 generator using the Recursive Matrix (RMat) graph generator.")
		.appendNewLine()
		.appendln(WordUtils.wrap("The graph matrix contains 2^scale vertices although not every vertex will" +
			" be represented in an edge. The number of edges is edge_factor * 2^scale edges" +
			" although some edges may be duplicates.", 80))
		.appendNewLine()
		.appendln("Note: this does not yet implement permutation of vertex labels or edges.")
		.appendNewLine()
		.appendln("usage: Graph500 --directed <true | false> --simplify <true | false> --output <print | hash | csv [options]>")
		.appendNewLine()
		.appendln("options:")
		.appendln("  --output print")
		.appendln("  --output hash")
		.appendln("  --output csv --output_filename FILENAME [--output_line_delimiter LINE_DELIMITER] [--output_field_delimiter FIELD_DELIMITER]")
		.appendNewLine()
		.appendln("Usage error: " + message)
		.toString();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:Graph500.java

示例15: getLongDescription

import org.apache.commons.lang3.text.StrBuilder; //导入依赖的package包/类
@Override
public String getLongDescription() {
	return new StrBuilder()
		.appendln("Computes metrics on a directed or undirected graph.")
		.appendNewLine()
		.appendln("Vertex metrics:")
		.appendln("- number of vertices")
		.appendln("- number of edges")
		.appendln("- number of unidirectional edges (directed only)")
		.appendln("- number of bidirectional edges (directed only)")
		.appendln("- average degree")
		.appendln("- number of triplets")
		.appendln("- maximum degree")
		.appendln("- maximum out degree (directed only)")
		.appendln("- maximum in degree (directed only)")
		.appendln("- maximum number of triplets")
		.appendNewLine()
		.appendln("Edge metrics:")
		.appendln("- number of triangle triplets")
		.appendln("- number of rectangle triplets")
		.appendln("- maximum number of triangle triplets")
		.append("- maximum number of rectangle triplets")
		.toString();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:GraphMetrics.java


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