当前位置: 首页>>代码示例>>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;未经允许,请勿转载。