當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。