org.apache.commons.lang.math.NumberUtils Java Examples

The following examples show how to use org.apache.commons.lang.math.NumberUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LatestForkUsecAlertStrategy.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Override
public List<InstanceAlertValueResult> checkConfig(InstanceAlertConfig instanceAlertConfig, AlertConfigBaseData alertConfigBaseData) {
    Object object = getValueFromRedisInfo(alertConfigBaseData.getStandardStats(), RedisInfoEnum.latest_fork_usec.getValue());
    if (object == null) {
        return null;
    }
    // 关系比对
    long latestForkUsec = NumberUtils.toLong(object.toString());
    boolean compareRight = isCompareLongRight(instanceAlertConfig, latestForkUsec);
    if (compareRight) {
        return null;
    }
    InstanceInfo instanceInfo = alertConfigBaseData.getInstanceInfo();
    return Arrays.asList(new InstanceAlertValueResult(instanceAlertConfig, instanceInfo, String.valueOf(latestForkUsec),
            instanceInfo.getAppId(), EMPTY));
}
 
Example #2
Source File: ShareCategoryService.java    From FlyCms with MIT License 6 votes vote down vote up
@Transactional
public DataVo editShareCategory(ShareCategory shareCategory){
    DataVo data = DataVo.failure("操作失败");
    if(this.checkShareCategoryByName(shareCategory.getName(),shareCategory.getId())){
        return data = DataVo.failure("分类名称不得重复");
    }
    if (StringUtils.isBlank(shareCategory.getId().toString())) {
        return data = DataVo.failure("分类id不能为空");
    }
    if (!NumberUtils.isNumber(shareCategory.getId().toString())) {
        return data = DataVo.failure("分类id错误!");
    }
    //转换为数组
    String[] str = shareCategory.getCategoryId().split(",");
    if((Integer.valueOf(str[str.length - 1])).equals(shareCategory.getId())){
        return data = DataVo.failure("不能选自己为父级目录");
    }
    shareCategory.setFatherId(Long.parseLong(str[str.length - 1]));
    shareCategoryDao.editShareCategoryById(shareCategory);
    if(shareCategory.getId()>0){
        data = DataVo.success("更新成功");
    }else{
        data = DataVo.failure("添加失败!");
    }
    return data;
}
 
Example #3
Source File: AuthoringConditionController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Display edit page for an existing condition.
    */
   @RequestMapping("/editCondition")
   public String editCondition(@ModelAttribute ForumConditionForm forumConditionForm, HttpServletRequest request) {

String sessionMapID = forumConditionForm.getSessionMapID();
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);

int orderId = NumberUtils.stringToInt(request.getParameter(ForumConstants.PARAM_ORDER_ID), -1);
ForumCondition condition = null;
if (orderId != -1) {
    SortedSet<ForumCondition> conditionSet = getForumConditionSet(sessionMap);
    List<ForumCondition> conditionList = new ArrayList<>(conditionSet);
    condition = conditionList.get(orderId);
    if (condition != null) {
	populateConditionToForm(orderId, condition, forumConditionForm, request);
    }
}

populateFormWithPossibleItems(forumConditionForm, request);
return condition == null ? null : "jsps/authoring/addCondition";
   }
 
Example #4
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Ajax call, remove the given line of instruction of survey item.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   @RequestMapping(value = "/removeInstruction")
   public String removeInstruction(HttpServletRequest request) {
int count = NumberUtils.stringToInt(request.getParameter(AuthoringController.INSTRUCTION_ITEM_COUNT), 0);
int removeIdx = NumberUtils.stringToInt(request.getParameter("removeIdx"), -1);
List instructionList = new ArrayList(count - 1);
for (int idx = 0; idx < count; idx++) {
    String item = request.getParameter(AuthoringController.INSTRUCTION_ITEM_DESC_PREFIX + idx);
    if (idx == removeIdx) {
	continue;
    }
    if (item == null) {
	instructionList.add("");
    } else {
	instructionList.add(item);
    }
}
request.setAttribute(SurveyConstants.ATTR_INSTRUCTION_LIST, instructionList);
return "pages/authoring/parts/instructions";
   }
 
Example #5
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String[] args, ConsoleReader reader) throws Exception
{
  if (currentApp == null) {
    throw new CliException("No application selected");
  }
  if (!NumberUtils.isDigits(args[1])) {
    throw new CliException("Operator ID must be a number");
  }
  StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
  uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(args[1]).path("properties");
  final JSONObject request = new JSONObject();
  request.put(args[2], args[3]);
  JSONObject response = getResource(uriSpec, currentApp, new WebServicesClient.WebServicesHandler<JSONObject>()
  {
    @Override
    public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz)
    {
      return webResource.accept(MediaType.APPLICATION_JSON).post(JSONObject.class, request);
    }

  });
  printJson(response);

}
 
Example #6
Source File: ScriptPlugin.java    From SuitAgent with Apache License 2.0 6 votes vote down vote up
/**
 * 执行返回数字类型的脚本
 * @param script
 * @return
 */
private DetectResult.Metric executeNumberScript(Script script,int step) {
    if (script != null && script.isValid()){
        try {
            String cmd = "";
            if (script.getScriptType() == ScriptType.SHELL){
                cmd = "sh " + script.getPath();
            }
            if (script.getScriptType() == ScriptType.PYTHON){
                cmd = "python " + script.getPath();
            }
            CommandUtilForUnix.ExecuteResult executeResult = CommandUtilForUnix.execWithReadTimeLimit(cmd,false,5);
            String value = executeResult.msg.trim();
            if (NumberUtils.isNumber(value)){
                return new DetectResult.Metric(script.getMetric(),value, CounterType.valueOf(script.getCounterType()), script.getTags(),step);
            }
        } catch (Exception e) {
            log.error("脚本执行异常",e);
        }
    }
    return null;
}
 
Example #7
Source File: AuthoringTaskListConditionController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Display edit page for existed taskList item.
    */
   @RequestMapping(path = "/editCondition", method = RequestMethod.POST)
   public String editCondition(@ModelAttribute TaskListConditionForm taskListConditionForm,
    HttpServletRequest request) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

int sequenceId = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_SEQUENCE_ID), -1);
TaskListCondition item = null;
if (sequenceId != -1) {
    SortedSet<TaskListCondition> conditionList = getTaskListConditionList(sessionMap);
    List<TaskListCondition> rList = new ArrayList<>(conditionList);
    item = rList.get(sequenceId);
    if (item != null) {
	populateConditionToForm(sequenceId, item, taskListConditionForm, request);
    }
}

populateFormWithPossibleItems(taskListConditionForm, request);
return item == null ? null : "pages/authoring/parts/addcondition";
   }
 
Example #8
Source File: FavoriteController.java    From FlyCms with MIT License 6 votes vote down vote up
@ResponseBody
@PostMapping(value = "/ucenter/favorite/add")
public DataVo addFavorite(@RequestParam(value = "id", required = false) String id,@RequestParam(value = "type", required = false) String type) {
    DataVo data = DataVo.failure("操作失败");
    try {
        if (!NumberUtils.isNumber(id)) {
            return data=DataVo.failure("话题id参数错误");
        }
        if (!NumberUtils.isNumber(type)) {
            return data=DataVo.failure("话题id参数错误");
        }
        if(getUser()==null){
            return data=DataVo.failure("请登陆后关注");
        }
        data=favoriteService.addFavorite(getUser().getUserId(),Integer.valueOf(type),Long.parseLong(id));
    } catch (Exception e) {
        data = DataVo.failure(e.getMessage());
    }
    return data;
}
 
Example #9
Source File: ConversionUtils.java    From usergrid with Apache License 2.0 6 votes vote down vote up
public static int getInt( Object obj ) {
    if ( obj instanceof Integer ) {
        return ( Integer ) obj;
    }
    if ( obj instanceof Number ) {
        return ( ( Number ) obj ).intValue();
    }
    if ( obj instanceof String ) {
        return NumberUtils.toInt( ( String ) obj );
    }
    if ( obj instanceof Date ) {
        return ( int ) ( ( Date ) obj ).getTime();
    }
    if ( obj instanceof byte[] ) {
        return getInt( ( byte[] ) obj );
    }
    if ( obj instanceof ByteBuffer ) {
        return getInt( ( ByteBuffer ) obj );
    }
    return 0;
}
 
Example #10
Source File: Metrics.java    From SuitAgent with Apache License 2.0 6 votes vote down vote up
private Collection<? extends FalconReportObject> getGlobalStatus() throws SQLException, ClassNotFoundException {
        Set<FalconReportObject> reportObjectSet = new HashSet<>();
        String sql = "SHOW /*!50001 GLOBAL */ STATUS";
        PreparedStatement pstmt = connection.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()){
            String value = rs.getString(2);
            if (NumberUtils.isNumber(value)){
                String metric = rs.getString(1);
                FalconReportObject falconReportObject = new FalconReportObject();
                MetricsCommon.setReportCommonValue(falconReportObject,plugin.step());
                falconReportObject.setCounterType(CounterType.GAUGE);
                //时间戳会统一上报
//                falconReportObject.setTimestamp(System.currentTimeMillis() / 1000);
                falconReportObject.setMetric(metric);
                falconReportObject.setValue(value);
                falconReportObject.appendTags(MetricsCommon.getTags(plugin.agentSignName(),plugin,plugin.serverName()));
                reportObjectSet.add(falconReportObject);
            }
        }
        rs.close();
        pstmt.close();
        return reportObjectSet;
    }
 
Example #11
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Display edit page for existed taskList item.
    */
   @RequestMapping("editItemInit")
   public String editItemInit(@ModelAttribute TaskListItemForm taskListItemForm, HttpServletRequest request) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_ITEM_INDEX), -1);
TaskListItem item = null;
if (itemIdx != -1) {
    SortedSet<TaskListItem> taskListList = getTaskListItemList(sessionMap);
    List<TaskListItem> rList = new ArrayList<>(taskListList);
    item = rList.get(itemIdx);
    if (item != null) {
	populateItemToForm(itemIdx, item, taskListItemForm, request);
    }
}

return item == null ? null : "pages/authoring/parts/addtask";
   }
 
Example #12
Source File: SetShopCartCommandImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) {
    if (parameters.containsKey(getCmdKey())) {
        final Long value = NumberUtils.createLong(String.valueOf(parameters.get(getCmdKey())));
        if (value != null && !value.equals(shoppingCart.getShoppingContext().getShopId())) {

            shoppingCart.getShoppingContext().clearContext(); // If we are setting new shop we must re-authenticate

            final Shop shop = shopService.getById(value);

            final MutableShoppingContext ctx = shoppingCart.getShoppingContext();
            ctx.setShopId(shop.getShopId());
            ctx.setShopCode(shop.getCode());

            setDefaultOrderInfoOptions(shoppingCart);
            setDefaultTaxOptions(shoppingCart);

            markDirty(shoppingCart);
        }
    }
}
 
Example #13
Source File: NumericValidator.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
private int checkNumeric(Object paramValue, VNumeric vNumeric) {
    boolean _matched = false;
    boolean _flag = false;
    try {
        Number _number = NumberUtils.createNumber(BlurObject.bind(paramValue).toStringValue());
        if (_number == null) {
            _matched = true;
            _flag = true;
        } else {
            if (vNumeric.min() > 0 && _number.doubleValue() < vNumeric.min()) {
                _matched = true;
            } else if (vNumeric.max() > 0 && _number.doubleValue() > vNumeric.max()) {
                _matched = true;
            }
        }
    } catch (Exception e) {
        _matched = true;
        _flag = true;
    }
    return _matched ? (_flag ? 2 : 1) : 0;
}
 
Example #14
Source File: AppManageController.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
/**
 * 添加扩容配置
 * 
 * @param appScaleText 扩容配置
 * @param appAuditId 审批id
 */
@RequestMapping(value = "/addAppScaleApply")
public ModelAndView doAddAppScaleApply(HttpServletRequest request,
		HttpServletResponse response, Model model, String appScaleText,
		Long appAuditId, Long appId) {
    AppUser appUser = getUserInfo(request);
       logger.error("user {} appScaleApplay : appScaleText={},appAuditId:{}", appUser.getName(), appScaleText, appAuditId);
       boolean isSuccess = false;
	if (appAuditId != null && StringUtils.isNotBlank(appScaleText)) {
		int mem = NumberUtils.toInt(appScaleText, 0);
		try {
		    isSuccess = appDeployCenter.verticalExpansion(appId, appAuditId, mem);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
	} else {
		logger.error("appScaleApplay error param: appScaleText={},appAuditId:{}", appScaleText, appAuditId);
	}
       logger.error("user {} appScaleApplay: appScaleText={},appAuditId:{}, result is {}", appUser.getName(), appScaleText, appAuditId, isSuccess);
	return new ModelAndView("redirect:/manage/app/auditList");
}
 
Example #15
Source File: Metrics.java    From SuitAgent with Apache License 2.0 6 votes vote down vote up
private Collection<? extends FalconReportObject> getGlobalVariables() throws SQLException, ClassNotFoundException {
        Set<FalconReportObject> reportObjectSet = new HashSet<>();
        String sql = "SHOW /*!50001 GLOBAL */ VARIABLES";
        PreparedStatement pstmt = connection.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()){
            String metric = rs.getString(1);
            String value = rs.getString(2);
            if (NumberUtils.isNumber(value)){
                //收集值为数字的结果
                FalconReportObject falconReportObject = new FalconReportObject();
                MetricsCommon.setReportCommonValue(falconReportObject,plugin.step());
                falconReportObject.setCounterType(CounterType.GAUGE);
                //时间戳会统一上报
//                falconReportObject.setTimestamp(System.currentTimeMillis() / 1000);
                falconReportObject.setMetric(metric);
                falconReportObject.setValue(value);
                falconReportObject.appendTags(MetricsCommon.getTags(plugin.agentSignName(),plugin,plugin.serverName()));
                reportObjectSet.add(falconReportObject);
            }
        }
        rs.close();
        pstmt.close();
        return reportObjectSet;
    }
 
Example #16
Source File: QuestionAdminController.java    From FlyCms with MIT License 6 votes vote down vote up
@PostMapping("/question-status")
@ResponseBody
public DataVo updateQuestionStatusById(@RequestParam(value = "id", required = false) String id,
                                       @RequestParam(value = "status", required = false) String status,
                                       @RequestParam(value = "recommend", defaultValue = "0") String recommend) throws Exception{
    DataVo data = DataVo.failure("操作失败");
    if (!NumberUtils.isNumber(id)) {
        return data = DataVo.failure("id参数错误");
    }
    if (!NumberUtils.isNumber(status)) {
        return data = DataVo.failure("审核状态参数错误");
    }
    if (!StringUtils.isBlank(recommend)) {
        if (!NumberUtils.isNumber(recommend)) {
            return data = DataVo.failure("推荐参数错误");
        }
    }
    data = questionService.updateQuestionStatusById(Long.parseLong(id),Integer.valueOf(status),Integer.valueOf(recommend));
    return data;
}
 
Example #17
Source File: AuthoringController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Remove imageGallery item from HttpSession list and update page display. As authoring rule, all persist only
    * happen when user submit whole page. So this remove is just impact HttpSession values.
    */
   @RequestMapping("/removeImage")
   public String removeImage(HttpServletRequest request) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ImageGalleryConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

int itemIdx = NumberUtils.stringToInt(request.getParameter(ImageGalleryConstants.PARAM_IMAGE_INDEX), -1);
if (itemIdx != -1) {
    SortedSet<ImageGalleryItem> imageGalleryList = getImageList(sessionMap);
    List<ImageGalleryItem> rList = new ArrayList<>(imageGalleryList);
    ImageGalleryItem item = rList.remove(itemIdx);
    imageGalleryList.clear();
    imageGalleryList.addAll(rList);
    // add to delList
    List<ImageGalleryItem> delList = getDeletedImageGalleryItemList(sessionMap);
    delList.add(item);
}

request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return "pages/authoring/parts/itemlist";
   }
 
Example #18
Source File: AppManageController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/appDaily")
public ModelAndView appDaily(HttpServletRequest request, HttpServletResponse response, Model model) throws ParseException {
 AppUser userInfo = getUserInfo(request);
    logger.warn("user {} want to send appdaily", userInfo.getName());
    if (ConstUtils.SUPER_MANAGER.contains(userInfo.getName())) {
        Date startDate;
        Date endDate;
        String startDateParam = request.getParameter("startDate");
        String endDateParam = request.getParameter("endDate");
        if (StringUtils.isBlank(startDateParam) || StringUtils.isBlank(endDateParam)) {
            endDate = new Date();
            startDate = DateUtils.addDays(endDate, -1);
        } else {
            startDate = DateUtil.parseYYYY_MM_dd(startDateParam);
            endDate = DateUtil.parseYYYY_MM_dd(endDateParam);
        }
        long appId = NumberUtils.toLong(request.getParameter("appId"));
        if (appId > 0) {
            appDailyDataCenter.sendAppDailyEmail(appId, startDate, endDate);
        } else {
            appDailyDataCenter.sendAppDailyEmail();
        }
        model.addAttribute("msg", "success!");
    } else {
        model.addAttribute("msg", "no power!");
    }
    return new ModelAndView("");
}
 
Example #19
Source File: ScoreColorSaveOrUpdateAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
private void checkFields() throws ControllerException {
	this.getCheckFieldHandler()
	.add("score", BscNumberFieldCheckUtils.class, this.getText("MESSAGE.BSC_PROG001D0004Q_score") )
	.process().throwMessage();
	
	this.getCheckFieldHandler()
	.single("score", ( NumberUtils.toLong(this.getFields().get("score"), 0) < BscConstants.SCORE_COLOR_MIN_VALUE ), this.getText("MESSAGE.BSC_PROG001D0004Q_score_msg1") + " " + BscConstants.SCORE_COLOR_MIN_VALUE )
	.single("score", ( NumberUtils.toLong(this.getFields().get("score"), 0) > BscConstants.SCORE_COLOR_MAX_VALUE ), this.getText("MESSAGE.BSC_PROG001D0004Q_score_msg2") + " " + BscConstants.SCORE_COLOR_MAX_VALUE )
	.throwMessage();
	
	if ( StringUtils.isBlank(this.getFields().get("bgColor")) || StringUtils.isBlank(this.getFields().get("fontColor")) ) {
		super.throwMessage( this.getText("MESSAGE.BSC_PROG001D0004Q_bgColorfontColor_msg") );
	}
}
 
Example #20
Source File: ElectronicInvoiceRejectDocument.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
public PurchaseOrderDocument getCurrentPurchaseOrderDocument() {

        if (StringUtils.isEmpty(getInvoicePurchaseOrderNumber()) ||
            !NumberUtils.isDigits(getInvoicePurchaseOrderNumber())){
            currentPurchaseOrderDocument = null;
        }else if (currentPurchaseOrderDocument == null) {
            currentPurchaseOrderDocument = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(new Integer(getInvoicePurchaseOrderNumber()));
        }else if (!StringUtils.equals(getInvoicePurchaseOrderNumber(), currentPurchaseOrderDocument.getPurapDocumentIdentifier().toString())){
            currentPurchaseOrderDocument = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(new Integer(getInvoicePurchaseOrderNumber()));
        }

        return currentPurchaseOrderDocument;
    }
 
Example #21
Source File: CasLoginAct.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
private Integer getCookieErrorRemaining(HttpServletRequest request,
		HttpServletResponse response) {
	Cookie cookie = CookieUtils.getCookie(request, COOKIE_ERROR_REMAINING);
	if (cookie != null) {
		String value = cookie.getValue();
		if (NumberUtils.isDigits(value)) {
			return Integer.parseInt(value);
		}
	}
	return null;
}
 
Example #22
Source File: InstanceAlertValueController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
private InstanceAlertConfig getInstanceAlertConfig(HttpServletRequest request) {
    // 相关参数
    Date now = new Date();
    String alertConfig = request.getParameter("alertConfig");
    String alertValue = request.getParameter("alertValue");
    RedisAlertConfigEnum redisAlertConfigEnum = RedisAlertConfigEnum.getRedisAlertConfig(alertConfig);
    String configInfo = redisAlertConfigEnum == null ? "" : redisAlertConfigEnum.getInfo();
    int compareType = NumberUtils.toInt(request.getParameter("compareType"));
    int checkCycle = NumberUtils.toInt(request.getParameter("checkCycle"));
    int instanceId = 0;
    int type = NumberUtils.toInt(request.getParameter("type"));
    if (InstanceAlertTypeEnum.INSTANCE_ALERT.getValue() == type) {
        String hostPort = request.getParameter("instanceHostPort");
        InstanceInfo instanceInfo = getInstanceInfo(hostPort);
        instanceId = instanceInfo.getId();
    }
    // 生成对象
    InstanceAlertConfig instanceAlertConfig = new InstanceAlertConfig();
    instanceAlertConfig.setAlertConfig(alertConfig);
    instanceAlertConfig.setAlertValue(alertValue);
    instanceAlertConfig.setConfigInfo(configInfo);
    instanceAlertConfig.setCompareType(compareType);
    instanceAlertConfig.setInstanceId(instanceId);
    instanceAlertConfig.setCheckCycle(checkCycle);
    instanceAlertConfig.setLastCheckTime(now);
    instanceAlertConfig.setType(type);
    instanceAlertConfig.setUpdateTime(now);
    instanceAlertConfig.setStatus(InstanceAlertStatusEnum.YES.getValue());
    return instanceAlertConfig;
}
 
Example #23
Source File: TestReviewRole.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public void setFromAmount(String fromAmount) {
    if(StringUtils.isNotEmpty(fromAmount) && NumberUtils.isNumber( fromAmount ) ) {
        this.fromAmount = new KualiDecimal(fromAmount);
    }
    else {
        this.fromAmount = null;
    }
}
 
Example #24
Source File: Config.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
public Integer getPort() {
	String port = getAttr().get(EMAIL_HOST);
	if (StringUtils.isNotBlank(port) && NumberUtils.isDigits(port)) {
		return Integer.parseInt(port);
	} else {
		return null;
	}
}
 
Example #25
Source File: BaseController.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
protected TimeBetween getJsonTimeBetween(HttpServletRequest request) throws ParseException {
    String startDateParam = request.getParameter("startDate");
    String endDateParam = request.getParameter("endDate");
    Date startDate = DateUtil.parseYYYY_MM_dd(startDateParam);
    Date endDate = DateUtil.parseYYYY_MM_dd(endDateParam);
    long beginTime = NumberUtils.toLong(DateUtil.formatYYYYMMddHHMM(startDate));
    long endTime = NumberUtils.toLong(DateUtil.formatYYYYMMddHHMM(endDate));
    return new TimeBetween(beginTime, endTime, startDate, endDate);
}
 
Example #26
Source File: ShopEntity.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
protected Set<Long> getCsvValuesTrimmedAsSetLong(final String attributeKey) {
    final List<String> csv = getCsvValuesTrimmedAsListRaw(getAttributeValueByCode(attributeKey));
    if (CollectionUtils.isNotEmpty(csv)) {
        final Set<Long> set = new HashSet<>();
        for (final String item : csv) {
            set.add(NumberUtils.toLong(item));
        }
        return Collections.unmodifiableSet(set);
    }
    return Collections.emptySet();
}
 
Example #27
Source File: Server.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
private String parseULimit(String line, String prefix, String flag) {
	String result = null;
	if(line.startsWith(prefix)) {
		String[] tmp = line.split("\\s+");
		if(tmp.length > 0) {
			int v = NumberUtils.toInt(tmp[tmp.length - 1]);
			if(v > 0) {
				result = flag + "," + v +";";
			}
		}
	}
	return result;
}
 
Example #28
Source File: SystemPropertyUtilsImpl.java    From IridiumApplicationTesting with MIT License 5 votes vote down vote up
@Override
public int getPropertyAsInt(final String name, final int defaultValue) {
	checkArgument(StringUtils.isNotBlank(name));

	return Optional.ofNullable(SYSTEM_PROPERTY_UTILS.getProperty(name))
		.map(String::toLowerCase)
		.map(String::trim)
		.map(NumberUtils::toInt)
		.orElse(defaultValue);
}
 
Example #29
Source File: DynamicPortal.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
protected void handleStartStopDynamic(Player player, String... params) {
	if (params.length != 2 || !NumberUtils.isDigits(params[1])) {
		showHelp(player);
		return;
	}

	int dynamicRiftId = NumberUtils.toInt(params[1]);
	if (!isValidDynamicPortalLocationId(player, dynamicRiftId)) {
		showHelp(player);
		return;
	} 
	if (COMMAND_OPEN.equalsIgnoreCase(params[0])) {
		if (DynamicPortalService.getInstance().isDynamicPortalInProgress(dynamicRiftId)) {
			PacketSendUtility.sendMessage(player, "Dynamic Portal " + dynamicRiftId + " is already start");
		} 
		else {
			PacketSendUtility.sendMessage(player, "Dynamic Portal " + dynamicRiftId + " started!");
			DynamicPortalService.getInstance().startDynamicPortal(dynamicRiftId);
		}
	} 
	else if (COMMAND_CLOSE.equalsIgnoreCase(params[0])) {
		if (!DynamicPortalService.getInstance().isDynamicPortalInProgress(dynamicRiftId)) {
			PacketSendUtility.sendMessage(player, "Dynamic Portal " + dynamicRiftId + " is not start!");
		} 
		else {
			PacketSendUtility.sendMessage(player, "Dynamic Portal " + dynamicRiftId + " stopped!");
			DynamicPortalService.getInstance().stopDynamicPortal(dynamicRiftId);
		}
	}
}
 
Example #30
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(String[] args, ConsoleReader reader) throws Exception
{
  if (currentApp == null) {
    throw new CliException("No application selected");
  }
  if (!NumberUtils.isDigits(args[1])) {
    throw new CliException("Operator ID must be a number");
  }
  String[] newArgs = new String[args.length - 1];
  System.arraycopy(args, 1, newArgs, 0, args.length - 1);
  PosixParser parser = new PosixParser();
  CommandLine line = parser.parse(GET_PHYSICAL_PROPERTY_OPTIONS.options, newArgs);
  String waitTime = line.getOptionValue(GET_PHYSICAL_PROPERTY_OPTIONS.waitTime.getOpt());
  String propertyName = line.getOptionValue(GET_PHYSICAL_PROPERTY_OPTIONS.propertyName.getOpt());
  StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
  uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(args[1]).path("properties");
  if (propertyName != null) {
    uriSpec = uriSpec.queryParam("propertyName", propertyName);
  }
  if (waitTime != null) {
    uriSpec = uriSpec.queryParam("waitTime", waitTime);
  }

  try {
    JSONObject response = getResource(uriSpec, currentApp);
    printJson(response);
  } catch (Exception e) {
    throw new CliException("Failed web service request for appid " + currentApp.getApplicationId().toString(), e);
  }
}