本文整理汇总了Java中org.apache.commons.lang.StringUtils.repeat方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.repeat方法的具体用法?Java StringUtils.repeat怎么用?Java StringUtils.repeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.repeat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PartitionedTablePathResolver
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
PartitionedTablePathResolver(IMetaStoreClient metastore, Table table)
throws NoSuchObjectException, MetaException, TException {
this.metastore = metastore;
this.table = table;
LOG.debug("Table '{}' is partitioned", Warehouse.getQualifiedName(table));
tableBaseLocation = locationAsPath(table);
List<Partition> onePartition = metastore.listPartitions(table.getDbName(), table.getTableName(), (short) 1);
if (onePartition.isEmpty()) {
LOG.warn("Table '{}' has no partitions, perhaps you can simply delete: {}.", Warehouse.getQualifiedName(table),
tableBaseLocation);
throw new ConfigurationException();
}
Path partitionLocation = locationAsPath(onePartition.get(0));
int branches = partitionLocation.depth() - tableBaseLocation.depth();
String globSuffix = StringUtils.repeat("*", "/", branches);
globPath = new Path(tableBaseLocation, globSuffix);
}
示例2: testExtraLongRpc
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test(timeout=6000)
public void testExtraLongRpc() throws Exception {
TestRpcService2 client = getClient2();
final String shortString = StringUtils.repeat("X", 4);
// short message goes through
EchoResponseProto echoResponse = client.echo2(null,
newEchoRequest(shortString));
Assert.assertEquals(shortString, echoResponse.getMessage());
final String longString = StringUtils.repeat("X", 4096);
try {
client.echo2(null, newEchoRequest(longString));
Assert.fail("expected extra-long RPC to fail");
} catch (ServiceException se) {
// expected
}
}
示例3: testValidate_WithInvalidNameLenghtMax_ThrowsVmidcBrokerValidationException
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test
public void testValidate_WithInvalidNameLenghtMax_ThrowsVmidcBrokerValidationException() throws Exception {
AddOrUpdateServiceFunctionChainRequest request = new AddOrUpdateServiceFunctionChainRequest();
BaseDto dto = new BaseDto();
String name = StringUtils.repeat("s", 15);
request.setName(name);
dto.setParentId(1L);
request.setDto(dto);
// Arrange.
this.exception.expect(VmidcBrokerValidationException.class);
this.exception.expectMessage("Invalid Service Function Name: " + request.getName()
+ "SFC name must not exceed 13 characters, must start with a letter, and can only contain numbers, letters and dash(-).");
// Act.
this.validator.validate(request);
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:18,代码来源:ServiceFunctionChainRequestValidatorTest.java
示例4: testExtraLongRpc
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test(timeout=6000)
public void testExtraLongRpc() throws Exception {
TestRpcService2 client = getClient2();
final String shortString = StringUtils.repeat("X", 4);
EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
.setMessage(shortString).build();
// short message goes through
EchoResponseProto echoResponse = client.echo2(null, echoRequest);
Assert.assertEquals(shortString, echoResponse.getMessage());
final String longString = StringUtils.repeat("X", 4096);
echoRequest = EchoRequestProto.newBuilder()
.setMessage(longString).build();
try {
echoResponse = client.echo2(null, echoRequest);
Assert.fail("expected extra-long RPC to fail");
} catch (ServiceException se) {
// expected
}
}
示例5:
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* BOX新規登録時にSchemaに1024文字を指定して場合_201になることを確認.
*/
@Test
public void BOX新規登録時にSchemaに1024文字を指定して場合_201になることを確認() {
PersoniumRequest req = PersoniumRequest.post(UrlUtils.cellCtl(CELL_NAME, ENTITY_TYPE_BOX));
String schema = "http://" + StringUtils.repeat("x", 1012) + ".com/";
String[] key = {"Name", "Schema" };
String[] value = {"testBox", schema };
req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN).addJsonBody(key, value);
try {
PersoniumResponse res = request(req);
// 400になることを確認
assertEquals(HttpStatus.SC_CREATED, res.getStatusCode());
} finally {
deleteBoxRequest("testBox").returns();
}
}
示例6:
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Urlが1024文字の場合正常に作成されること.
*/
@Test
public final void Urlが1024文字の場合正常に作成されること() {
String newCellUrl = "http://localhost:8080/personium-core/testcell1" + StringUtils.repeat("a", 977) + "/";
try {
ExtCellUtils.create(token, cellName, extCellUrl, HttpStatus.SC_CREATED);
ExtCellUtils.update(token, cellName, extCellUrl, newCellUrl, HttpStatus.SC_NO_CONTENT);
} finally {
ExtCellUtils.delete(token, cellName, newCellUrl, -1);
}
}
示例7:
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Urlが1024文字の場合正常に作成されること.
*/
@Test
public final void Urlが1024文字の場合正常に作成されること() {
String extCellUrl = "http://localhost:8080/personium-core/testcell1"
+ StringUtils.repeat("a", 977) + TRAILING_SLASH;
try {
ExtCellUtils.create(token, cellName, extCellUrl, HttpStatus.SC_CREATED);
} finally {
ExtCellUtils.delete(token, cellName, extCellUrl, -1);
}
}
示例8: writeWrapped
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Writes one or more lines of text, applying line wrapping.
*/
private void writeWrapped(final String text) {
// Handle the case of multiple lines
if (text.contains(SystemUtils.LINE_SEPARATOR)) {
for (String line : text.split(SystemUtils.LINE_SEPARATOR)) {
writeWrapped(line);
}
return;
}
// Write anything below the wrapping limit
if (text.length() < LINE_LENGTH) {
outputStream.println(text);
return;
}
// Measure the indent to use on the split lines
int indent = 0;
while (indent < text.length() && text.charAt(indent) == ' ') {
indent++;
}
indent += 2;
// Split the line, preserving the indent on new lines
final String firstLineIndent = text.substring(0, indent);
final String lineSeparator = SystemUtils.LINE_SEPARATOR + StringUtils.repeat(" ", indent);
outputStream.println(firstLineIndent + WordUtils.wrap(text.substring(indent), LINE_LENGTH - indent, lineSeparator, false));
}
示例9: analyzePossibilities
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private int analyzePossibilities(String buffer, int cursor, List<String> candidates) throws IOException {
if (cursor == 0) {
return -1;
}
final String[] args = buffer.substring(0, Math.min(cursor, buffer.length())).split(" |,", 1000);
if (args.length <= 1) {
return -1;
}
String val = args[args.length - 1];
if ("".equals(val) || " ".equals(val) || ",".equals(val)) {
val = ".";
}
boolean isAbsolute = val.startsWith("/");
if (val.startsWith("-")) {
return -1;
}
final int found = val.lastIndexOf('/');
final String core;
final String rest;
if (found == -1) {
//it's relative
core = contextCommands.getCurrentDir();
rest = val;
} else {
final String firstPart = val.substring(0, found + 1);
core = (isAbsolute) ? firstPart : new Path(contextCommands.getCurrentDir(), firstPart).toUri().getPath();
rest = val.length() == 1 ? "" : val.substring(found + 1);
}
final FileSystem fs = FileSystem.get(contextCommands.getConfiguration());
final Path f = new Path(val);
boolean folderFound = false;
if (fs.exists(f) && fs.getFileStatus(f).isDirectory() && !val.endsWith("/") && !val.equals(".")) {
folderFound = true;
}
final Path pathCore = new Path(core);
if (!fs.exists(pathCore)) {
return -1;
}
final String[] suggestions = getSuggestions(rest, fs, pathCore);
String commonPrefix = StringUtils.getCommonPrefix(suggestions);
if (StringUtils.isNotEmpty(commonPrefix) && !commonPrefix.equals(rest)) {
commonPrefix = rest.isEmpty() || rest.equals(".") ? commonPrefix : commonPrefix.substring(rest.length());
candidates.add(commonPrefix);
return cursor;
} else {
if (suggestions.length > 1) {
if (StringUtils.isNotEmpty(commonPrefix) && commonPrefix.equals(rest)) { //problem candidatelistcompletionhandler
for (int i = 0; i < suggestions.length; i++) {
suggestions[i] = StringUtils.repeat(" ", i) + suggestions[i];
}
}
candidates.addAll(removeSlash(suggestions));
} else {
if (folderFound) {
candidates.add("/");
return cursor;
} else {
if (suggestions.length > 0) {
suggestions[0] = rest.isEmpty() || rest.equals(".") ? suggestions[0] : suggestions[0].substring(rest.length());
candidates.addAll(Arrays.asList(suggestions));
}
}
}
}
return suggestions.length == 0 ? -1 : cursor;
}
示例10: paddedByte
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private String paddedByte(final int b, final XoRoShiRo128PlusRandomGenerator random) {
return padding ? "" + b : StringUtils.repeat("0", random.nextInt(2)) + b;
}
示例11: toString
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Represents this token as a String.
*
* @return String representation of the token
*/
public String toString() {
return StringUtils.repeat(this.value.toString(), this.count);
}