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


Java StringUtils.rightPad方法代码示例

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


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

示例1: getRow

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TableListing.java

示例2: getInvalidSecretKeyTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidSecretKeyTestData() {
    String[] invalidSecretKeys = new String[]{null, "", StringUtils.rightPad("key", 156, 'e')};

    List<Object[]> result = new ArrayList<Object[]>();

    for(String invalidSecretKey : invalidSecretKeys) {
        DistributedApplianceDto daDto = createDistributedApplianceDto();
        daDto.setSecretKey(invalidSecretKey);

        String errorMessage = "Secret Key " +
                (invalidSecretKey == null || invalidSecretKey.length() < 155 ?
                        EMPTY_VALUE_ERROR_MESSAGE : INVALID_FIELD_LENGTH_ERROR_MESSAGE);

        result.add(new Object[] {daDto,  VmidcBrokerInvalidEntryException.class, errorMessage});
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:19,代码来源:DistributedApplianceDtoValidatorTestData.java

示例3: getInvalidNameTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidNameTestData() {
    String[] invalidNames = new String[]{null, "", "1ab", "#bc", "-ab", "ab12_", "ab a", StringUtils.rightPad("dtoName", 14, 'e')};

    List<Object[]> result = new ArrayList<Object[]>();

    for(String invalidName : invalidNames) {
        DistributedApplianceDto daDto = createDistributedApplianceDto();
        daDto.setName(invalidName);
        String errorMessage = invalidName == null || invalidName == "" ?
                "Distributed Appliance Name " + EMPTY_VALUE_ERROR_MESSAGE :
                    "Invalid Distributed Appliance Name: "
                    + invalidName
                    + "DA name must not exceed 13 characters, must start with a letter, and can only contain numbers, letters and dash(-).";

        Class<?> expectedException = invalidName == null || invalidName == "" ?
                VmidcBrokerInvalidEntryException.class : VmidcBrokerValidationException.class;

        result.add(new Object[] {daDto,  expectedException, errorMessage});
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:DistributedApplianceDtoValidatorTestData.java

示例4: getInvalidNameTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidNameTestData() {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithoutSDN();
        vcDto.setName(invalidName);
        String errorMessage = invalidName == null || invalidName == ""
                ? Server.PRODUCT_NAME + ": " + "Name " + EMPTY_VALUE_ERROR_MESSAGE
                        : Server.PRODUCT_NAME + ": " + "Name" + " length should not exceed " + ValidateUtil.DEFAULT_MAX_LEN
                        + " characters. The provided field exceeds this limit by "
                        + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例5: getInvalidControllerPasswordTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidControllerPasswordTestData() {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<Object[]>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithSDN();
        vcDto.setControllerPassword(invalidName);
        String errorMessage = invalidName == null || invalidName == ""
                ? Server.PRODUCT_NAME + ": " + "Controller Password " + EMPTY_VALUE_ERROR_MESSAGE
                        : Server.PRODUCT_NAME + ": " + "Controller Password" + " length should not exceed "
                        + ValidateUtil.DEFAULT_MAX_LEN + " characters. The provided field exceeds this limit by "
                        + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例6: getInvalidProviderPaswordTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidProviderPaswordTestData() {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<Object[]>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithSDN();
        vcDto.setProviderPassword(invalidName);
        String errorMessage = invalidName == null || invalidName == ""
                ? Server.PRODUCT_NAME + ": " + "Provider Password " + EMPTY_VALUE_ERROR_MESSAGE
                        : Server.PRODUCT_NAME + ": " + "Provider Password" + " length should not exceed "
                        + ValidateUtil.DEFAULT_MAX_LEN + " characters. The provided field exceeds this limit by "
                        + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例7: getInvalidControllerUserNameTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidControllerUserNameTestData() throws Exception {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<Object[]>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithSDN();
        vcDto.setControllerUser(invalidName);
        String errorMessage = invalidName == null || invalidName == ""
                ? Server.PRODUCT_NAME + ": " + "Controller User Name " + EMPTY_VALUE_ERROR_MESSAGE
                        : Server.PRODUCT_NAME + ": " + "Controller User Name" + " length should not exceed "
                        + ValidateUtil.DEFAULT_MAX_LEN + " characters. The provided field exceeds this limit by "
                        + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例8: getInvalidProviderUserNameTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidProviderUserNameTestData() {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<Object[]>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithSDN();
        vcDto.setProviderUser(invalidName);
        String errorMessage = invalidName == null || invalidName == ""
                ? Server.PRODUCT_NAME + ": " + "Provider User Name " + EMPTY_VALUE_ERROR_MESSAGE
                        : Server.PRODUCT_NAME + ": " + "Provider User Name" + " length should not exceed "
                        + ValidateUtil.DEFAULT_MAX_LEN + " characters. The provided field exceeds this limit by "
                        + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例9: subscribeNewsColumn

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@RequestMapping(path = "/channel/news/subscribe", method = RequestMethod.POST)
public AppClientDataRsp subscribeNewsColumn(@RequestBody ChannelRequestBase request) {
  AppClientDataRsp response = new AppClientDataRsp();
  String rsp = StringUtils.rightPad("edge test", 1024, "*");
  response.setRsp(rsp);
  return response;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:Impl.java

示例10: preModify

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void preModify( UserType userType ) {
	String xml = getUserMetadataXML(userType);
	if( xml.length()>=1000&&xml.length()<=2000 ) {
		xml=StringUtils.rightPad( xml, 4000-xml.length() );
	}
	
	userType.setUserMetadataXML(xml);
}
 
开发者ID:yswang0927,项目名称:ralasafe,代码行数:9,代码来源:UserTypeManagerImpl.java

示例11: shouldNotReturnADtoWhenResponseIs_Nonsense

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test
public void shouldNotReturnADtoWhenResponseIs_Nonsense() {
    final SamlResponseDto samlResponseDto = new SamlResponseDto(StringUtils.rightPad("test", 2000, "x"));

    Response clientResponse = postToSamlEngine(samlResponseDto);

    assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
    ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
    assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:11,代码来源:MatchingServiceResponseTranslatorResourceTest.java

示例12: getInvalidMqPortTestData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
static List<Object[]> getInvalidMqPortTestData() {
    String[] invalidNames = new String[] { null, "",
            StringUtils.rightPad("dtoName", ValidateUtil.DEFAULT_MAX_LEN + 10, 'e') };

    List<Object[]> result = new ArrayList<>();

    for (String invalidName : invalidNames) {
        VirtualizationConnectorDto vcDto = VirtualizationConnectorDtoValidatorTestData.generateOpenStackVCWithoutSDN();
        vcDto.getProviderAttributes().put(ATTRIBUTE_KEY_RABBITMQ_PORT, invalidName);

        String errorMessage;
        if (invalidName == null || invalidName.equals("")) {
            errorMessage = Server.PRODUCT_NAME + ": " + "Rabbit MQ Port " + EMPTY_VALUE_ERROR_MESSAGE;
        } else if (!StringUtils.isNumeric(invalidName)) {
            errorMessage = ATTRIBUTE_KEY_RABBITMQ_PORT
                    + " expected to be an Integer. Value is: " + invalidName;
        } else {
            errorMessage = Server.PRODUCT_NAME + ": " + ATTRIBUTE_KEY_RABBITMQ_PORT
                    + " length should not exceed " + ValidateUtil.DEFAULT_MAX_LEN
                    + " characters. The provided field exceeds this limit by "
                    + (invalidName.length() - ValidateUtil.DEFAULT_MAX_LEN) + " characters.";
        }

        Class<?> expectedException = VmidcBrokerInvalidEntryException.class;

        result.add(new Object[] { vcDto, expectedException, errorMessage });
    }

    return result;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:VirtualizationConnectorDtoValidatorParameterizedTest.java

示例13: prepareJavadoc

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Create Javadoc from input string
 *
 * @param query   string to create javadoc from
 * @param padding number of space symbols to pad from the left
 * @return prepared javadoc string
 */
public static String prepareJavadoc(String query, int padding) {
    String pad = StringUtils.rightPad("", padding);
    StringBuilder sb = new StringBuilder(pad + "/**" + "\n");
    String[] spl = query.split("\n");
    for (String string : spl) {
        string = string.replace("*/", "* /").replaceAll("\t", "    ");
        sb.append(pad).append(" * ").append(string).append("\n");
    }
    sb.append(pad).append(" */");
    return sb.toString();

}
 
开发者ID:nds842,项目名称:sql-first-mapper,代码行数:20,代码来源:MiscUtils.java

示例14: testValidateforCreate_UsingApplianceModelTooLong_ThrowsVmidcBrokerInvalidEntryException

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test
public void testValidateforCreate_UsingApplianceModelTooLong_ThrowsVmidcBrokerInvalidEntryException() throws Exception {
    ApplianceDto dto = new ApplianceDto(StringUtils.rightPad("m", ValidateUtil.DEFAULT_MAX_LEN + 1, 'e'), UUID.randomUUID().toString(), UUID.randomUUID().toString());
    testValidateforCreate_UsingFieldTooLong_ThrowsVmidcBrokerInvalidEntryException(dto, "Appliance Model");
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:6,代码来源:ApplianceDtoValidatorTest.java

示例15: testValidateforCreate_UsingApplianceManagerVersionTooLong_ThrowsVmidcBrokerInvalidEntryException

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test
public void testValidateforCreate_UsingApplianceManagerVersionTooLong_ThrowsVmidcBrokerInvalidEntryException() throws Exception {
    ApplianceDto dto = new ApplianceDto(UUID.randomUUID().toString(), UUID.randomUUID().toString(), StringUtils.rightPad("m", ValidateUtil.DEFAULT_MAX_LEN + 1, 'e'));
    testValidateforCreate_UsingFieldTooLong_ThrowsVmidcBrokerInvalidEntryException(dto, "Appliance Manager Version");
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:6,代码来源:ApplianceDtoValidatorTest.java


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