本文整理汇总了Java中org.apache.commons.lang.StringUtils.isNumeric方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isNumeric方法的具体用法?Java StringUtils.isNumeric怎么用?Java StringUtils.isNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isNumeric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFieldFormat
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static void checkFieldFormat(VirtualizationConnectorDto dto) throws VmidcBrokerInvalidEntryException {
ValidateUtil.checkForValidIpAddressFormat(dto.getProviderIP());
if (dto.getType().isOpenstack() && dto.getProviderAttributes() != null) {
String rabbitMqPort = dto.getProviderAttributes().get(ATTRIBUTE_KEY_RABBITMQ_PORT);
if (!StringUtils.isNumeric(rabbitMqPort)) {
throw new VmidcBrokerInvalidEntryException(
ATTRIBUTE_KEY_RABBITMQ_PORT + " expected to be an Integer. Value is: " + rabbitMqPort);
}
String rabbitMQIP = dto.getProviderAttributes().get(ATTRIBUTE_KEY_RABBITMQ_IP);
if (!StringUtils.isBlank(rabbitMQIP)) {
ValidateUtil.checkForValidIpAddressFormat(rabbitMQIP);
}
}
}
示例2: isValidIp
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static boolean isValidIp(String ip) {
try {
if (StringUtils.isNotBlank(ip)) {
String[] fieldArr = ip.split("\\.");
if (fieldArr.length == 4) {
for (String field : fieldArr) {
if (!StringUtils.isNumeric(field)) {
return false;
}
}
return true;
}
}
} catch (Exception e) {
logger.error("ip:{} is illegal", ip);
}
return false;
}
示例3: toDataForm
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void toDataForm(HttpServletRequest request, HttpServletResponse response) throws Exception {
String modelId= request.getParameter("modelId");
Model model = modelService.get(Integer.parseInt(modelId));
Column column = new Column();
column.setModelId(model.getId());
List<Column> columns = columnService.findList(column);
request.setAttribute("columns", columns);
request.setAttribute("model", model);
Data entity = new Data();
String id = request.getParameter("id");
if (StringUtils.isNotEmpty(id) && StringUtils.isNumeric(id)) {
entity.setTableName(model.getTableName());
entity.setId(Integer.parseInt(id));
entity = dataService.get(entity);
}
request.setAttribute("entity", entity);
request.getRequestDispatcher(prefix + "manage/dataForm.jsp").forward(request, response);
}
示例4: formColumn
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void formColumn(HttpServletRequest request, HttpServletResponse response) throws Exception {
Column column = new Column();
String modelId = request.getParameter("modelId");
column.setModelId(Integer.parseInt(modelId));
Cfg tableCfg = new Cfg();
tableCfg.setC(3);
List<Cfg> types = cfgService.findList(tableCfg);
request.setAttribute("types", types);
tableCfg.setC(1);
List<Cfg> maps = cfgService.findList(tableCfg);
request.setAttribute("maps", maps);
String id = request.getParameter("id");
if (StringUtils.isNumeric(id)) {
column = columnService.get(Integer.parseInt(id));
}
request.setAttribute("entity", column);
request.getRequestDispatcher(prefix + "model/formColumn.jsp").forward(request, response);
}
示例5: formModel
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void formModel(HttpServletRequest request, HttpServletResponse response) throws Exception {
Model model = new Model();
String id = request.getParameter("id");
if (StringUtils.isNumeric(id)) {
model = modelService.get(Integer.parseInt(id));
} else {
//新增时的父节点
String parentId = request.getParameter("parentId");
model.setParentId(Integer.parseInt(parentId));
}
request.setAttribute("entity", model);
request.getRequestDispatcher(prefix + "model/formModel.jsp").forward(request, response);
}
示例6: saveModel
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void saveModel(HttpServletRequest request, HttpServletResponse response) throws Exception {
Model model = new Model();
String id = request.getParameter("id");
if (StringUtils.isNotEmpty(id)) {
model.setId(Integer.parseInt(id));
}
String parentId = request.getParameter("parentId");
if (StringUtils.isNumeric(parentId)) {
model.setParentId(Integer.parseInt(parentId));
}
String name = request.getParameter("name");
model.setName(name);
String tableName = request.getParameter("tableName");
model.setTableName(tableName);
String seq = request.getParameter("seq");
if (StringUtils.isNumeric(seq)) {
model.setSeq(Integer.parseInt(seq));
}
String remark = request.getParameter("remark");
model.setRemark(remark);
modelService.save(model);
this.write(new Ajax(true, "保存成功"), response);
}
示例7: FirstSpiritConnectionRule
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Instantiates a new First spirit connection rule.
*
* @param host the host, e.g. localhost
* @param port the port, e.g. 1088
* @param mode the mode
* @param login the login, e.g. Admin
* @param password the password, e.g. Admin
*/
public FirstSpiritConnectionRule(final String host, final String port, final ConnectionMode mode, final String login, final String password) {
if (StringUtils.isBlank(host)) {
throw new IllegalArgumentException("host can not be null or empty");
}
if (StringUtils.isBlank(port)) {
throw new IllegalArgumentException("port can not be null or empty");
}
if (!StringUtils.isNumeric(port)) {
throw new IllegalArgumentException("port must be numeric");
}
if (StringUtils.isBlank(login)) {
throw new IllegalArgumentException("login can not be null or empty");
}
if (StringUtils.isBlank(password)) {
throw new IllegalArgumentException("password can not be null or empty");
}
this.host = host;
this.port = Integer.parseInt(port);
this.mode = Objects.requireNonNull(mode, "mode can not be null");
this.login = login;
this.password = password;
commands = new ConcurrentHashMap<>();
populateMap(commands);
}
示例8: 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
示例9: getBalance
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Override
public int getBalance(MsgChannelEntity channel) {
if(channel==null){
return 0;
}
NameValuePair[] data = {
new NameValuePair("account", channel.getUsername()),
new NameValuePair("password", channel.getPassword()),
new NameValuePair("format", "json")
};
String submitResult=null;
int count=0;
//三次尝试
do{
count++;
submitResult= Sendsms.send(data, channel.getUrl4query());
}while(StringUtils.isEmpty(submitResult)&&count<RESENDCOUNT);
//确认服务器没有相应
if(StringUtils.isEmpty(submitResult)){
throw new RRException("服务器没有响应");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
Map<String, Object> maps = (Map)JSON.parse(submitResult);
String code =String.valueOf(maps.get("code")).trim();
String num =String.valueOf(maps.get("num")).trim();
if(!"2".equals(code)){
throw new RRException("channelId:"+channel.getChannelId()+"查询异常,code:"+maps.get("code")+"异常描述:"+maps.get("msg"));
}
if(StringUtils.isEmpty(num)||!StringUtils.isNumeric(num)){
throw new RRException("channelId:"+channel.getChannelId()+"查询异常,换回num值为"+maps.get("num"));
}
return Integer.parseInt(num);
}
示例10: saveColumn
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void saveColumn(HttpServletRequest request, HttpServletResponse response) throws Exception {
Column column = new Column();
String id = request.getParameter("id");
if (StringUtils.isNotEmpty(id)) {
column.setId(Integer.parseInt(id));
}
String modelId = request.getParameter("modelId");
column.setModelId(Integer.parseInt(modelId));
String name = request.getParameter("name");
column.setName(name);
String type = request.getParameter("type");
column.setType(type);
String mappingData = request.getParameter("mappingData");
column.setMappingData(mappingData);
String sql = request.getParameter("sql");
column.setSql(sql);
String seq = request.getParameter("seq");
if (StringUtils.isNumeric(seq)) {
column.setSeq(Integer.parseInt(seq));
}
String width = request.getParameter("width");
if (StringUtils.isNumeric(width)) {
column.setWidth(Integer.parseInt(width));
}
String allowBlank = request.getParameter("allowBlank");
column.setAllowBlank(allowBlank);
String listShow = request.getParameter("listShow");
column.setListShow(listShow);
String remark = request.getParameter("remark");
column.setRemark(remark);
columnService.save(column);
this.write(new Ajax(true, "保存成功"), response);
}
示例11: mapId
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private String mapId(String id) {
if (id == null || id.startsWith(CoverArtController.ALBUM_COVERART_PREFIX) ||
id.startsWith(CoverArtController.ARTIST_COVERART_PREFIX) || StringUtils.isNumeric(id)) {
return id;
}
try {
String path = StringUtil.utf8HexDecode(id);
MediaFile mediaFile = mediaFileService.getMediaFile(path);
return String.valueOf(mediaFile.getId());
} catch (Exception x) {
return id;
}
}
示例12: addItemToPlaylist
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void addItemToPlaylist(int playlistId, String id, int index) {
if (StringUtils.isBlank(id)) {
return;
}
GetMetadata parameters = new GetMetadata();
parameters.setId(id);
parameters.setIndex(0);
parameters.setCount(Integer.MAX_VALUE);
GetMetadataResponse metadata = getMetadata(parameters);
List<MediaFile> newSongs = new ArrayList<MediaFile>();
for (AbstractMedia media : metadata.getGetMetadataResult().getMediaCollectionOrMediaMetadata()) {
if (StringUtils.isNumeric(media.getId())) {
MediaFile mediaFile = mediaFileService.getMediaFile(Integer.parseInt(media.getId()));
if (mediaFile != null && mediaFile.isFile()) {
newSongs.add(mediaFile);
}
}
}
List<MediaFile> existingSongs = playlistService.getFilesInPlaylist(playlistId);
if (index == -1) {
index = existingSongs.size();
}
existingSongs.addAll(index, newSongs);
playlistService.setFilesInPlaylist(playlistId, existingSongs);
}
示例13: incrementSubVersion
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private String incrementSubVersion(final String subVersion) {
if (StringUtils.isNumeric(subVersion)) {
return Integer.toString(Integer.parseInt(subVersion) + 1);
}
final String headVersionPart = StringUtils.substringBeforeLast(subVersion, ".");
final String tailVersionPart = StringUtils.substringAfterLast(subVersion, ".");
final Integer newSubVersion = Integer.parseInt(tailVersionPart) + 1;
return headVersionPart + "." + newSubVersion.toString();
}
示例14: getDBAdditionalParamValue
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Converts the String to {@link BigInteger}
* @param propertyName
* @param nameOfFeild
* @param fieldKey
* @return
*/
public BigInteger getDBAdditionalParamValue(String propertyName , String nameOfField, String fieldKey){
Map<String,String> propertyValue = (Map<String, String>) properties.get(propertyName);
if (StringUtils.isNotBlank(propertyValue.get(nameOfField)) && StringUtils.isNumeric(propertyValue.get(nameOfField))) {
BigInteger bigInteger = new BigInteger(String.valueOf(propertyValue.get(nameOfField)));
return bigInteger;
} else if (ParameterUtil.isParameter(propertyValue.get(nameOfField))) {
ComponentXpath.INSTANCE.getXpathMap()
.put((ComponentXpathConstants.COMPONENT_XPATH_BOOLEAN.value().replace(ID, component.getComponentId()))
.replace(Constants.PARAM_PROPERTY_NAME, fieldKey),
new ComponentsAttributeAndValue(null, propertyValue.get(nameOfField)));
return null;
}
return null;
}
示例15: needsAnonymization
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* Checks if the data needs anonymization. Typically, data types which are
* numeric in nature doesn't need anonymization.
*/
public static boolean needsAnonymization(String data) {
// Numeric data doesn't need anonymization
// Currently this doesnt support inputs like
// - 12.3
// - 12.3f
// - 90L
// - 1D
if (StringUtils.isNumeric(data)) {
return false;
}
return true; // by default return true
}