本文整理匯總了Java中org.apache.commons.lang.math.NumberUtils.stringToInt方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberUtils.stringToInt方法的具體用法?Java NumberUtils.stringToInt怎麽用?Java NumberUtils.stringToInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.math.NumberUtils
的用法示例。
在下文中一共展示了NumberUtils.stringToInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newQuestion
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Display empty page for new daco question.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
protected ActionForward newQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
DacoQuestionForm questionForm = (DacoQuestionForm) form;
questionForm.setSessionMapID(sessionMapID);
short type = (short) NumberUtils.stringToInt(request.getParameter(DacoConstants.QUESTION_TYPE));
if (type == DacoConstants.QUESTION_TYPE_RADIO || type == DacoConstants.QUESTION_TYPE_DROPDOWN
|| type == DacoConstants.QUESTION_TYPE_CHECKBOX) {
List answerOptionList = new ArrayList(DacoConstants.INIT_ANSWER_OPTION_COUNT);
for (int index = 0; index < DacoConstants.INIT_ANSWER_OPTION_COUNT; index++) {
answerOptionList.add("");
}
request.setAttribute(DacoConstants.ATTR_ANSWER_OPTION_LIST, answerOptionList);
}
return findForward(type, mapping);
}
示例2: editQuestion
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Display edit page for existed daco question.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
protected ActionForward editQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
int questionIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_QUESTION_INDEX), -1);
DacoQuestion question = null;
DacoQuestionForm questionForm = (DacoQuestionForm) form;
if (questionIndex != -1) {
SortedSet<DacoQuestion> questionSet = getQuestionList(sessionMap);
List<DacoQuestion> questionList = new ArrayList<DacoQuestion>(questionSet);
question = questionList.get(questionIndex);
if (question != null) {
populateQuestionToForm(questionIndex, question, questionForm, request);
}
}
return findForward(question == null ? -1 : question.getType(), mapping);
}
示例3: removeItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Remove kaltura 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.
*/
public ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, KalturaConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
.getAttribute(sessionMapID);
request.setAttribute(KalturaConstants.ATTR_SESSION_MAP_ID, sessionMapID);
int itemIdx = NumberUtils.stringToInt(request.getParameter(KalturaConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
SortedSet<KalturaItem> itemList = getItemList(sessionMap);
List<KalturaItem> rList = new ArrayList<KalturaItem>(itemList);
KalturaItem item = rList.remove(itemIdx);
itemList.clear();
itemList.addAll(rList);
// add to delList
List<KalturaItem> delList = getDeletedItemList(sessionMap);
delList.add(item);
}
return mapping.findForward(KalturaConstants.ITEM_LIST);
}
示例4: removeItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Remove resource 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.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ResourceConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
int itemIdx = NumberUtils.stringToInt(request.getParameter(ResourceConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
SortedSet<ResourceItem> resourceList = getResourceItemList(sessionMap);
List<ResourceItem> rList = new ArrayList<ResourceItem>(resourceList);
ResourceItem item = rList.remove(itemIdx);
resourceList.clear();
resourceList.addAll(rList);
// add to delList
List delList = getDeletedResourceItemList(sessionMap);
delList.add(item);
}
request.setAttribute(ResourceConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ResourceConstants.SUCCESS);
}
示例5: removeQuestion
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Remove daco question 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.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
protected ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
int questionIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_QUESTION_INDEX), -1);
if (questionIndex != -1) {
SortedSet<DacoQuestion> questionSet = getQuestionList(sessionMap);
List<DacoQuestion> questionList = new ArrayList<DacoQuestion>(questionSet);
DacoQuestion question = questionList.remove(questionIndex);
questionSet.clear();
questionSet.addAll(questionList);
// add to delList
List deletedList = getDeletedDacoQuestionList(sessionMap);
deletedList.add(question);
}
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(DacoConstants.SUCCESS);
}
示例6: editCondition
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Display edit page for an existing condition.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private ActionForward editCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
ForumConditionForm ForumConditionForm = (ForumConditionForm) form;
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<ForumCondition>(conditionSet);
condition = conditionList.get(orderId);
if (condition != null) {
populateConditionToForm(orderId, condition, ForumConditionForm, request);
}
}
populateFormWithPossibleItems(form, request);
return condition == null ? null : mapping.findForward("addcondition");
}
示例7: removeAnswerOption
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Ajax call, remove the given line of instruction of resource item.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
protected ActionForward removeAnswerOption(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
int count = NumberUtils.stringToInt(request.getParameter(DacoConstants.ANSWER_OPTION_COUNT), 0);
int removeIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_ANSWER_OPTION_INDEX), -1);
List answerOptionList = new ArrayList(count - 1);
for (int index = 1; index <= count; index++) {
if (index != removeIndex) {
String answerOption = request.getParameter(DacoConstants.ANSWER_OPTION_DESC_PREFIX + index);
answerOptionList.add(answerOption == null ? "" : answerOption);
}
}
request.setAttribute(DacoConstants.ATTR_ANSWER_OPTION_LIST, answerOptionList);
return mapping.findForward(DacoConstants.SUCCESS);
}
示例8: switchTopic
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchTopic(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
int itemIdx = NumberUtils.stringToInt(request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX), -1);
if (itemIdx != -1) {
Set topics = getTopics(sessionMap);
List<MessageDTO> rList = new ArrayList<MessageDTO>(topics);
MessageDTO newMsg = rList.get(itemIdx);
// get current and the target item, and switch their sequence
MessageDTO item = rList.get(itemIdx);
MessageDTO repItem;
if (up) {
repItem = rList.get(--itemIdx);
} else {
repItem = rList.get(++itemIdx);
}
int upSeqId = repItem.getMessage().getSequenceId();
repItem.getMessage().setSequenceId(item.getMessage().getSequenceId());
item.getMessage().setSequenceId(upSeqId);
// put back list, it will be sorted again
topics.clear();
topics.addAll(rList);
}
request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward("success");
}
示例9: switchItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ChatConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
int orderId = NumberUtils.stringToInt(request.getParameter(ChatConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
SortedSet<ChatCondition> conditionSet = getChatConditionSet(sessionMap);
List<ChatCondition> conditionList = new ArrayList<ChatCondition>(conditionSet);
// get current and the target item, and switch their sequnece
ChatCondition condition = conditionList.get(orderId);
ChatCondition repCondition;
if (up) {
repCondition = conditionList.get(--orderId);
} else {
repCondition = conditionList.get(++orderId);
}
int upSeqId = repCondition.getOrderId();
repCondition.setOrderId(condition.getOrderId());
condition.setOrderId(upSeqId);
// put back list, it will be sorted again
conditionSet.clear();
conditionSet.addAll(conditionList);
}
request.setAttribute(ChatConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ChatConstants.SUCCESS);
}
示例10: switchItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// 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);
if (sequenceId != -1) {
SortedSet<TaskListCondition> conditionList = getTaskListConditionList(sessionMap);
List<TaskListCondition> rList = new ArrayList<TaskListCondition>(conditionList);
// get current and the target item, and switch their sequnece
TaskListCondition condition = rList.get(sequenceId);
TaskListCondition repCondition;
if (up) {
repCondition = rList.get(--sequenceId);
} else {
repCondition = rList.get(++sequenceId);
}
int upSeqId = repCondition.getSequenceId();
repCondition.setSequenceId(condition.getSequenceId());
condition.setSequenceId(upSeqId);
// put back list, it will be sorted again
conditionList.clear();
conditionList.addAll(rList);
}
request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(TaskListConstants.SUCCESS);
}
示例11: removeCondition
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Remove condition 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.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
int orderId = NumberUtils.stringToInt(request.getParameter(SurveyConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
SortedSet<SurveyCondition> conditionSet = getSurveyConditionSet(sessionMap);
List<SurveyCondition> conditionList = new ArrayList<SurveyCondition>(conditionSet);
SurveyCondition condition = conditionList.remove(orderId);
for (SurveyCondition otherCondition : conditionSet) {
if (otherCondition.getOrderId() > orderId) {
otherCondition.setOrderId(otherCondition.getOrderId() - 1);
}
}
conditionSet.clear();
conditionSet.addAll(conditionList);
// add to delList
List deletedList = getDeletedSurveyConditionList(sessionMap);
deletedList.add(condition);
}
request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(SurveyConstants.SUCCESS);
}
示例12: switchItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, KalturaConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
request.setAttribute(KalturaConstants.ATTR_SESSION_MAP_ID, sessionMapID);
int itemIdx = NumberUtils.stringToInt(request.getParameter(KalturaConstants.PARAM_ITEM_INDEX), -1);
if (itemIdx != -1) {
SortedSet<KalturaItem> kalturaList = getItemList(sessionMap);
List<KalturaItem> rList = new ArrayList<KalturaItem>(kalturaList);
// get current and the target item, and switch their sequnece
KalturaItem item = rList.get(itemIdx);
KalturaItem repItem;
if (up) {
repItem = rList.get(--itemIdx);
} else {
repItem = rList.get(++itemIdx);
}
int upSeqId = repItem.getSequenceId();
repItem.setSequenceId(item.getSequenceId());
item.setSequenceId(upSeqId);
// put back list, it will be sorted again
kalturaList.clear();
kalturaList.addAll(rList);
}
return mapping.findForward(KalturaConstants.ITEM_LIST);
}
示例13: switchItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
SortedSet<NotebookCondition> conditionSet = getNotebookConditionSet(sessionMap);
List<NotebookCondition> conditionList = new ArrayList<NotebookCondition>(conditionSet);
// get current and the target item, and switch their sequnece
NotebookCondition condition = conditionList.get(orderId);
NotebookCondition repCondition;
if (up) {
repCondition = conditionList.get(--orderId);
} else {
repCondition = conditionList.get(++orderId);
}
int upSeqId = repCondition.getOrderId();
repCondition.setOrderId(condition.getOrderId());
condition.setOrderId(upSeqId);
// put back list, it will be sorted again
conditionSet.clear();
conditionSet.addAll(conditionList);
}
request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(NotebookConstants.SUCCESS);
}
示例14: removeCondition
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Remove condition 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.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
int orderId = NumberUtils.stringToInt(request.getParameter(ForumConstants.PARAM_ORDER_ID), -1);
if (orderId != -1) {
SortedSet<ForumCondition> conditionSet = getForumConditionSet(sessionMap);
List<ForumCondition> conditionList = new ArrayList<ForumCondition>(conditionSet);
ForumCondition condition = conditionList.remove(orderId);
for (ForumCondition otherCondition : conditionSet) {
if (otherCondition.getOrderId() > orderId) {
otherCondition.setOrderId(otherCondition.getOrderId() - 1);
}
}
conditionSet.clear();
conditionSet.addAll(conditionList);
// add to delList
List deletedList = getDeletedForumConditionList(sessionMap);
deletedList.add(condition);
}
request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ForumConstants.SUCCESS);
}
示例15: reviewItem
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Display main frame to display instrcution and item content.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws IOException
*/
private ActionForward reviewItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException {
String mode = request.getParameter(AttributeNames.ATTR_MODE);
String sessionMapID = WebUtil.readStrParam(request, CommonCartridgeConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
CommonCartridgeItem item = getCommonCartridgeItem(request, sessionMap, mode);
String idStr = request.getParameter(CommonCartridgeConstants.ATTR_TOOL_SESSION_ID);
Long sessionId = NumberUtils.createLong(idStr);
// mark this item access flag if it is learner
if (ToolAccessMode.LEARNER.toString().equals(mode)) {
ICommonCartridgeService service = getCommonCartridgeService();
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
service.setItemAccess(item.getUid(), new Long(user.getUserID().intValue()), sessionId);
}
if (item == null) {
return mapping.findForward(CommonCartridgeConstants.ERROR);
}
// set url to content frame
int itemIdx = NumberUtils.stringToInt(request.getParameter(CommonCartridgeConstants.PARAM_ITEM_INDEX));
short type = item.getType();
String url = null;
switch (type) {
case CommonCartridgeConstants.RESOURCE_TYPE_BASIC_LTI:
if (item.isOpenUrlNewWindow()) {
url = "/openUrlPopup.do?";
} else {
url = "/launchBasicLTI.do?";
}
if (CommonCartridgeConstants.MODE_AUTHOR_SESSION.equals(mode)) {
url += AttributeNames.ATTR_MODE + "=" + mode + "&" + CommonCartridgeConstants.PARAM_ITEM_INDEX + "="
+ itemIdx + "&" + CommonCartridgeConstants.ATTR_SESSION_MAP_ID + "=" + sessionMapID;
} else {
url += CommonCartridgeConstants.PARAM_RESOURCE_ITEM_UID + "=" + item.getUid() + "&"
+ CommonCartridgeConstants.ATTR_SESSION_MAP_ID + "=" + sessionMapID;
}
break;
case CommonCartridgeConstants.RESOURCE_TYPE_COMMON_CARTRIDGE:
url = "/download/?uuid=" + item.getFileUuid() + "&preferDownload=false";
break;
}
request.setAttribute(CommonCartridgeConstants.ATTR_RESOURCE_REVIEW_URL, url);
// these attribute will be use to instruction navigator page
request.setAttribute(AttributeNames.ATTR_MODE, mode);
request.setAttribute(CommonCartridgeConstants.PARAM_ITEM_INDEX, itemIdx);
Long itemUid = NumberUtils.createLong(request.getParameter(CommonCartridgeConstants.PARAM_RESOURCE_ITEM_UID));
request.setAttribute(CommonCartridgeConstants.PARAM_RESOURCE_ITEM_UID, itemUid);
request.setAttribute(CommonCartridgeConstants.ATTR_TOOL_SESSION_ID, sessionId);
request.setAttribute(CommonCartridgeConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(CommonCartridgeConstants.SUCCESS);
}