當前位置: 首頁>>代碼示例>>Java>>正文


Java NumberUtils.createLong方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.math.NumberUtils.createLong方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberUtils.createLong方法的具體用法?Java NumberUtils.createLong怎麽用?Java NumberUtils.createLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.math.NumberUtils的用法示例。


在下文中一共展示了NumberUtils.createLong方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getResourceItem

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Return resoruce item according to ToolAccessMode.
    *
    * @param request
    * @param sessionMap
    * @param mode
    * @return
    */
   private ResourceItem getResourceItem(HttpServletRequest request, SessionMap<String, Object> sessionMap,
    String mode) {
ResourceItem item = null;
if (ResourceConstants.MODE_AUTHOR_SESSION.equals(mode)) {
    int itemIdx = NumberUtils.stringToInt(request.getParameter(ResourceConstants.PARAM_ITEM_INDEX), 0);
    // authoring: does not save item yet, so only has ItemList from session and identity by Index
    List<ResourceItem> resourceList = new ArrayList<ResourceItem>(getResourceItemList(sessionMap));
    item = resourceList.get(itemIdx);
} else {
    Long itemUid = NumberUtils.createLong(request.getParameter(ResourceConstants.PARAM_RESOURCE_ITEM_UID));
    // get back the resource and item list and display them on page
    IResourceService service = getResourceService();
    item = service.getResourceItemByUid(itemUid);
}
return item;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:ViewItemAction.java

示例2: getCommonCartridgeItem

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Return resoruce item according to ToolAccessMode.
    *
    * @param request
    * @param sessionMap
    * @param mode
    * @return
    */
   private CommonCartridgeItem getCommonCartridgeItem(HttpServletRequest request, SessionMap sessionMap, String mode) {
CommonCartridgeItem item = null;
if (CommonCartridgeConstants.MODE_AUTHOR_SESSION.equals(mode)) {
    int itemIdx = NumberUtils.stringToInt(request.getParameter(CommonCartridgeConstants.PARAM_ITEM_INDEX), 0);
    // authoring: does not save item yet, so only has ItemList from session and identity by Index
    List<CommonCartridgeItem> commonCartridgeList = new ArrayList<CommonCartridgeItem>(
	    getCommonCartridgeItemList(sessionMap));
    item = commonCartridgeList.get(itemIdx);
} else {
    Long itemUid = NumberUtils
	    .createLong(request.getParameter(CommonCartridgeConstants.PARAM_RESOURCE_ITEM_UID));
    // get back the commonCartridge and item list and display them on page
    ICommonCartridgeService service = getCommonCartridgeService();
    item = service.getCommonCartridgeItemByUid(itemUid);
}
return item;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:ViewItemAction.java

示例3: marshal

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
@Override
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
    if (source != null) {
	String className = source.getClass().getName();
	try {
	    for (NameInfo name : fileHandleClassList) {
		if (name.className.equals(className)) {
		    Long uuid = NumberUtils.createLong(BeanUtils.getProperty(source, name.uuidFieldName));
		    if (uuid != null) {
			// version id is optional
			Long version = null;
			if (name.versionFieldName != null) {
			    version = NumberUtils
				    .createLong(BeanUtils.getProperty(source, name.versionFieldName));
			}
			log.debug("XStream get file node [" + uuid + "," + version + "].");
			fileNodes.add(ExportToolContentService.this.new ValueInfo(uuid, version));
		    }
		}
	    }
	} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
	    log.error("Error while marshalling a file", e);
	}
    }

    defaultConverter.marshal(source, writer, context);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:ExportToolContentService.java

示例4: 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
    */
   private ActionForward reviewItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
String mode = request.getParameter(AttributeNames.ATTR_MODE);

String sessionMapID = WebUtil.readStrParam(request, ResourceConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);

ResourceItem item = getResourceItem(request, sessionMap, mode);

String idStr = request.getParameter(ResourceConstants.ATTR_TOOL_SESSION_ID);
Long sessionId = NumberUtils.createLong(idStr);
// mark this item access flag if it is learner
if (ToolAccessMode.LEARNER.toString().equals(mode)) {
    IResourceService service = getResourceService();
    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(ResourceConstants.ERROR);
}
if (item.getType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT) {
    sessionMap.put(ResourceConstants.ATT_LEARNING_OBJECT, item);
}
// set url to content frame

int itemIdx = NumberUtils.stringToInt(request.getParameter(ResourceConstants.PARAM_ITEM_INDEX));
request.setAttribute(ResourceConstants.ATTR_RESOURCE_REVIEW_URL,
	getReviewUrl(item, sessionMapID, mode, itemIdx));

request.setAttribute(ResourceConstants.ATTR_ALLOW_COMMENTS, item.isAllowComments());

// these attribute will be use to instruction navigator page
request.setAttribute(AttributeNames.ATTR_MODE, mode);
request.setAttribute(ResourceConstants.PARAM_ITEM_INDEX, itemIdx);
Long itemUid = NumberUtils.createLong(request.getParameter(ResourceConstants.PARAM_RESOURCE_ITEM_UID));
request.setAttribute(ResourceConstants.PARAM_RESOURCE_ITEM_UID, itemUid);
request.setAttribute(ResourceConstants.ATTR_TOOL_SESSION_ID, sessionId);
request.setAttribute(ResourceConstants.ATTR_SESSION_MAP_ID, sessionMapID);

return mapping.findForward(ResourceConstants.SUCCESS);

   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:56,代碼來源:ViewItemAction.java

示例5: 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);

   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:73,代碼來源:ViewItemAction.java

示例6: recordItemScratched

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Record in DB that leader has scratched specified answer. And return whether scratchie answer is correct or not.
    */
   private ActionForward recordItemScratched(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException, ScratchieApplicationException {
initializeScratchieService();
String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
final Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID));

ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId);

ScratchieUser leader = getCurrentUser(toolSessionId);
// only leader is allowed to scratch answers
if (!toolSession.isUserGroupLeader(leader.getUid())) {
    return null;
}

// check answer is belong to current session
Set<Long> answerUids = (Set<Long>) sessionMap.get(ScratchieConstants.ATTR_ANSWER_UIDS);
if (!answerUids.contains(answerUid)) {
    return null;
}

// Return whether scratchie answer is correct or not
ScratchieAnswer answer = service.getScratchieAnswerByUid(answerUid);
if (answer == null) {
    return null;
}

JSONObject JSONObject = new JSONObject();
JSONObject.put(ScratchieConstants.ATTR_ANSWER_CORRECT, answer.isCorrect());
response.setContentType("application/x-json;charset=utf-8");
response.getWriter().print(JSONObject);

// create a new thread to record item scratched (in order to do this task in parallel not to slow down sending
// response back)
Thread recordItemScratchedThread = new Thread(new Runnable() {
    @Override
    public void run() {
	service.recordItemScratched(toolSessionId, answerUid);
    }
}, "LAMS_recordItemScratched_thread");
recordItemScratchedThread.start();

return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:50,代碼來源:LearningAction.java


注:本文中的org.apache.commons.lang.math.NumberUtils.createLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。