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


Java StringUtils.repeat方法代码示例

本文整理汇总了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);
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:18,代码来源:PartitionedTablePathResolver.java

示例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
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:TestProtoBufRpc.java

示例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
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestProtoBufRpc.java

示例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();
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:BoxCrudTest.java

示例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);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:15,代码来源:ExtCellUpdateTest.java

示例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);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:15,代码来源:ExtCellCreateTest.java

示例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));
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:32,代码来源:ChangelogStatementConsumer.java

示例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;
}
 
开发者ID:avast,项目名称:hdfs-shell,代码行数:78,代码来源:PathCompleter.java

示例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;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:4,代码来源:RandomNamedGraphServer.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:DurationFormatUtils.java


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