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


Java NumberUtils.toInt方法代碼示例

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


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

示例1: getUnitsFromRequest

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Get units from <code>HttpRequest</code>
    *
    * @param request
    */
   private TreeSet<AssessmentUnit> getUnitsFromRequest(HttpServletRequest request, boolean isForSaving) {
Map<String, String> paramMap = splitRequestParameter(request, AssessmentConstants.ATTR_UNIT_LIST);

int count = NumberUtils.toInt(paramMap.get(AssessmentConstants.ATTR_UNIT_COUNT));
TreeSet<AssessmentUnit> unitList = new TreeSet<AssessmentUnit>(new SequencableComparator());
for (int i = 0; i < count; i++) {
    String unitStr = paramMap.get(AssessmentConstants.ATTR_UNIT_UNIT_PREFIX + i);
    if (StringUtils.isBlank(unitStr) && isForSaving) {
	continue;
    }

    AssessmentUnit unit = new AssessmentUnit();
    String sequenceId = paramMap.get(AssessmentConstants.ATTR_UNIT_SEQUENCE_ID_PREFIX + i);
    unit.setSequenceId(NumberUtils.toInt(sequenceId));
    unit.setUnit(unitStr);
    float multiplier = Float.valueOf(paramMap.get(AssessmentConstants.ATTR_UNIT_MULTIPLIER_PREFIX + i));
    unit.setMultiplier(multiplier);
    unitList.add(unit);
}

return unitList;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:AuthoringAction.java

示例2: extractCandidateAnswers

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
public List<McOptionDTO> extractCandidateAnswers(HttpServletRequest request, int questionIndex)
    throws UnsupportedEncodingException {
Map<String, String[]> paramMap = request.getParameterMap();
String[] param = paramMap.get(McAppConstants.CANDIDATE_ANSWER_COUNT + questionIndex);

int count = NumberUtils.toInt(param[0]);
int correct = Integer.parseInt(getCorrect(questionIndex - 1));
List<McOptionDTO> candidateAnswerList = new ArrayList<McOptionDTO>();
for (int index = 1; index <= count; index++) {
    param = paramMap.get(McAppConstants.CANDIDATE_ANSWER_PREFIX + questionIndex + "-" + index);
    String answer = param[0];
    if (answer != null) {
	McOptionDTO candidateAnswer = new McOptionDTO();
	candidateAnswer.setCandidateAnswer(answer);
	if (index == correct) {
	    candidateAnswer.setCorrect(McAppConstants.CORRECT);
	}
	candidateAnswerList.add(candidateAnswer);
    }
}
return candidateAnswerList;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:McPedagogicalPlannerForm.java

示例3: removeAnswer

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Ajax call, remove the given answer.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward removeAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

SortedSet<ScratchieAnswer> answerList = getAnswersFromRequest(request, false);

int answerIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1);
if (answerIndex != -1) {
    List<ScratchieAnswer> rList = new ArrayList<ScratchieAnswer>(answerList);
    rList.remove(answerIndex);
    answerList.clear();
    answerList.addAll(rList);
}

request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList);
request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:AuthoringAction.java

示例4: VrapOptions

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
public VrapOptions(String[] args)
{
    final CommandLine cmd;
    final CommandLineParser parser = new DefaultParser();

    options = getOptions();

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        printHelp();

        System.exit(1);
        return;
    }

    dryRun = cmd.hasOption(getDryRunOption().getOpt());
    checkOnly = cmd.hasOption(getCheckOnlyOption().getOpt());
    mode = parseModeOption(cmd.getOptionValue(getModeOption().getOpt(), VrapMode.proxy.name()));
    port = NumberUtils.toInt(cmd.getOptionValue(getPortOption().getOpt()), 5050);
    apiUrl = cmd.getOptionValue(getApiUrlOption().getOpt());
    duplicateDetection = Boolean.valueOf(
            Optional.ofNullable(cmd.getOptionValue(getJsonDuplicateKeyOption().getOpt())).orElse("true")
    );
    sslVerificationMode = parseSslMode(cmd.getOptionValue(getSSLVerificationOption().getOpt(), SSLVerificationMode.normal.name()));
    clientConnectionPoolSize = NumberUtils.toInt(cmd.getOptionValue(getClientConnectionPoolSizeOption().getOpt()), 10);

    if (cmd.hasOption(getHelpOption().getOpt())) {
        printHelp();
        System.exit(0);
    }
    if (cmd.getArgs().length == 0) {
        LOG.error("Missing file input argument.");
        System.exit(1);
    }

    filePath = Paths.get(cmd.getArgs()[0]).toAbsolutePath();
}
 
開發者ID:vrapio,項目名稱:vrap,代碼行數:40,代碼來源:VrapApp.java

示例5: getAnswersFromRequest

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Get answer options from <code>HttpRequest</code>
    *
    * @param request
    * @param isForSaving
    *            whether the blank options will be preserved or not
    *
    */
   private TreeSet<ScratchieAnswer> getAnswersFromRequest(HttpServletRequest request, boolean isForSaving) {
Map<String, String> paramMap = splitRequestParameter(request, ScratchieConstants.ATTR_ANSWER_LIST);
Integer correctAnswerIndex = (paramMap.get(ScratchieConstants.ATTR_ANSWER_CORRECT) == null) ? null
	: NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_CORRECT));

int count = NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_COUNT));
TreeSet<ScratchieAnswer> answerList = new TreeSet<ScratchieAnswer>(new ScratchieAnswerComparator());
for (int i = 0; i < count; i++) {

    String answerDescription = paramMap.get(ScratchieConstants.ATTR_ANSWER_DESCRIPTION_PREFIX + i);
    if ((answerDescription == null) && isForSaving) {
	continue;
    }

    ScratchieAnswer answer = new ScratchieAnswer();
    String uidStr = paramMap.get(ScratchieConstants.ATTR_ANSWER_UID_PREFIX + i);
    if (uidStr != null) {
	Long uid = NumberUtils.toLong(uidStr);
	answer.setUid(uid);
    }
    String orderIdStr = paramMap.get(ScratchieConstants.ATTR_ANSWER_ORDER_ID_PREFIX + i);
    Integer orderId = NumberUtils.toInt(orderIdStr);
    answer.setOrderId(orderId);
    answer.setDescription(answerDescription);
    if ((correctAnswerIndex != null) && correctAnswerIndex.equals(orderId)) {
	answer.setCorrect(true);
    }
    answerList.add(answer);
}

return answerList;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AuthoringAction.java

示例6: getFTableInstance

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
public static FTable getFTableInstance(Configuration conf, String[] cols) {
  aClient = getConnectionFromConf(conf);
  String tableName = conf.get(REGION);
  FTable table = aClient.getFTable(tableName);
  if (table == null) {
    FTableDescriptor tableDescriptor = new FTableDescriptor();
    int redundancy = NumberUtils.toInt(conf.get(MonarchUtils.REDUNDANCY),
      MonarchUtils.REDUNDANCY_DEFAULT);
    tableDescriptor.setRedundantCopies(redundancy);

    int buckets = NumberUtils.toInt(conf.get(MonarchUtils.BUCKETS),
      MonarchUtils.BUCKETS_DEFAULT);
    tableDescriptor.setTotalNumOfSplits(buckets);

    tableDescriptor.setSchema(new Schema(cols));

    Admin admin = aClient.getAdmin();

    String partitionColumn = conf.get(MonarchUtils.MONARCH_PARTITIONING_COLUMN);
    if (partitionColumn != null) {
      tableDescriptor.setPartitioningColumn(partitionColumn);
    }
    final String blockFormat = conf.get(MonarchUtils.BLOCK_FORMAT);
    if (blockFormat != null) {
      tableDescriptor.setBlockFormat(FTableDescriptor.BlockFormat.valueOf(blockFormat.toUpperCase()));
    }
    final String blockSize = conf.get(MonarchUtils.BLOCK_SIZE);
    if (blockSize != null) {
      tableDescriptor.setBlockSize(Integer.getInteger(blockSize, DEFAULT_BLOCK_SIZE));
    }

    table = admin.createFTable(tableName, tableDescriptor);
  }
  return table;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:36,代碼來源:MonarchUtils.java

示例7: intervalSet

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private boolean intervalSet(CommandSender sender, String[] args)
{
    try
    {
        int setting = NumberUtils.toInt(args[2], 1);
        MinecraftServer.getServer().cauldronConfig.set(args[1], setting);
    }
    catch (Exception ex)
    {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        return false;
    }
    return true;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:15,代碼來源:CauldronCommand.java

示例8: editQuestion

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Display edit page for existed assessment question.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward editQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
updateQuestionReferencesGrades(request, sessionMap, false);
String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID);

int questionIdx = NumberUtils.toInt(request.getParameter(AssessmentConstants.PARAM_QUESTION_INDEX), -1);
AssessmentQuestion question = null;
if (questionIdx != -1) {
    SortedSet<AssessmentQuestion> assessmentList = getQuestionList(sessionMap);
    List<AssessmentQuestion> rList = new ArrayList<AssessmentQuestion>(assessmentList);
    question = rList.get(questionIdx);
    if (question != null) {
	AssessmentQuestionForm questionForm = (AssessmentQuestionForm) form;
	populateQuestionToForm(questionIdx, question, questionForm, request);
	questionForm.setContentFolderID(contentFolderID);
    }
}
sessionMap.put(AssessmentConstants.ATTR_QUESTION_TYPE, question.getType());
request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID);
return findForward(question == null ? -1 : question.getType(), mapping);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:AuthoringAction.java

示例9: removeQuestionReference

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Remove assessment 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
    */
   private ActionForward removeQuestionReference(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

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

int questionReferenceIdx = NumberUtils
	.toInt(request.getParameter(AssessmentConstants.PARAM_QUESTION_REFERENCE_INDEX), -1);
if (questionReferenceIdx != -1) {
    SortedSet<QuestionReference> questionReferences = getQuestionReferences(sessionMap);
    List<QuestionReference> rList = new ArrayList<QuestionReference>(questionReferences);
    QuestionReference questionReference = rList.remove(questionReferenceIdx);
    questionReferences.clear();
    questionReferences.addAll(rList);
    // add to delList
    List<QuestionReference> delList = getDeletedQuestionReferences(sessionMap);
    delList.add(questionReference);
}

reinitializeAvailableQuestions(sessionMap);

request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:38,代碼來源:AuthoringAction.java

示例10: switchQuestionReferences

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchQuestionReferences(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
updateQuestionReferencesGrades(request, sessionMap, false);

int questionReferenceIdx = NumberUtils
	.toInt(request.getParameter(AssessmentConstants.PARAM_QUESTION_REFERENCE_INDEX), -1);
if (questionReferenceIdx != -1) {
    SortedSet<QuestionReference> references = getQuestionReferences(sessionMap);
    List<QuestionReference> rList = new ArrayList<QuestionReference>(references);
    // get current and the target item, and switch their sequnece
    QuestionReference reference = rList.get(questionReferenceIdx);
    QuestionReference repReference;
    if (up) {
	repReference = rList.get(--questionReferenceIdx);
    } else {
	repReference = rList.get(++questionReferenceIdx);
    }
    int upSeqId = repReference.getSequenceId();
    repReference.setSequenceId(reference.getSequenceId());
    reference.setSequenceId(upSeqId);

    // put back list, it will be sorted again
    references.clear();
    references.addAll(rList);
}

request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:AuthoringAction.java

示例11: getTableInstance

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
public static MTable getTableInstance(Configuration conf, String[] cols) {
  aClient = getConnectionFromConf(conf);
  String tableName = conf.get(REGION);
  MTable table = aClient.getMTable(tableName);
  if (table == null) {
    boolean persist;
    String persistence = conf.get(MonarchUtils.PERSIST);
    persist = persistence != null;
    final String tableType = conf.get(MonarchUtils.MONARCH_TABLE_TYPE);
    final MTableType type = TABLE_TYPE_ORDERED.equalsIgnoreCase(tableType)
      ? MTableType.ORDERED_VERSIONED : MTableType.UNORDERED;

    MTableDescriptor tableDescriptor = new MTableDescriptor(type);
    int redundancy = NumberUtils.toInt(conf.get(MonarchUtils.REDUNDANCY),
      MonarchUtils.REDUNDANCY_DEFAULT);
    tableDescriptor.setRedundantCopies(redundancy);

    int buckets = NumberUtils.toInt(conf.get(MonarchUtils.BUCKETS),
      MonarchUtils.BUCKETS_DEFAULT);
    tableDescriptor.setTotalNumOfSplits(buckets);

    tableDescriptor.setSchema(new Schema(cols));

    if (persist) {
      if (persistence.compareToIgnoreCase("sync") == 0) {
        tableDescriptor.enableDiskPersistence(MDiskWritePolicy.SYNCHRONOUS);
      } else if (persistence.compareToIgnoreCase("async") == 0) {
        tableDescriptor.enableDiskPersistence(MDiskWritePolicy.ASYNCHRONOUS);
      }
    }
    Admin admin = aClient.getAdmin();
    table = admin.createMTable(tableName, tableDescriptor);
  }
  return table;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:36,代碼來源:MonarchUtils.java

示例12: switchAnswer

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
private ActionForward switchAnswer(ActionMapping mapping, HttpServletRequest request, boolean up) {
SortedSet<ScratchieAnswer> answerList = getAnswersFromRequest(request, false);

int answerIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1);
if (answerIndex != -1) {
    List<ScratchieAnswer> rList = new ArrayList<ScratchieAnswer>(answerList);

    // get current and the target item, and switch their sequnece
    ScratchieAnswer answer = rList.get(answerIndex);
    ScratchieAnswer repAnswer;
    if (up) {
	repAnswer = rList.get(--answerIndex);
    } else {
	repAnswer = rList.get(++answerIndex);
    }

    int upSeqId = repAnswer.getOrderId();
    repAnswer.setOrderId(answer.getOrderId());
    answer.setOrderId(upSeqId);

    // put back list, it will be sorted again
    answerList.clear();
    answerList.addAll(rList);
}

request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList);
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:AuthoringAction.java

示例13: getOverallFeedbacksFromRequest

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Get overall feedbacks from <code>HttpRequest</code>
    *
    * @param request
    */
   private TreeSet<AssessmentOverallFeedback> getOverallFeedbacksFromRequest(HttpServletRequest request,
    boolean skipBlankOverallFeedbacks) {
int count = NumberUtils.toInt(request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_COUNT));
TreeSet<AssessmentOverallFeedback> overallFeedbackList = new TreeSet<AssessmentOverallFeedback>(
	new SequencableComparator());
for (int i = 0; i < count; i++) {
    String gradeBoundaryStr = request
	    .getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i);
    String feedback = request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_FEEDBACK_PREFIX + i);
    String sequenceId = request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_SEQUENCE_ID_PREFIX + i);

    if ((StringUtils.isBlank(feedback) || StringUtils.isBlank(gradeBoundaryStr)) && skipBlankOverallFeedbacks) {
	continue;
    }
    AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
    overallFeedback.setSequenceId(NumberUtils.toInt(sequenceId));
    if (!StringUtils.isBlank(gradeBoundaryStr)) {
	int gradeBoundary = NumberUtils.toInt(
		request.getParameter(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i));
	overallFeedback.setGradeBoundary(gradeBoundary);
    }
    overallFeedback.setFeedback(feedback);
    overallFeedbackList.add(overallFeedback);
}
return overallFeedbackList;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:AuthoringAction.java

示例14: getOverallFeedbacksFromForm

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Get overall feedbacks from <code>HttpRequest</code>
    *
    * @param request
    */
   private TreeSet<AssessmentOverallFeedback> getOverallFeedbacksFromForm(HttpServletRequest request,
    boolean skipBlankOverallFeedbacks) {
Map<String, String> paramMap = splitRequestParameter(request, AssessmentConstants.ATTR_OVERALL_FEEDBACK_LIST);

int count = NumberUtils.toInt(paramMap.get(AssessmentConstants.ATTR_OVERALL_FEEDBACK_COUNT));
TreeSet<AssessmentOverallFeedback> overallFeedbackList = new TreeSet<AssessmentOverallFeedback>(
	new SequencableComparator());
for (int i = 0; i < count; i++) {
    String gradeBoundaryStr = paramMap.get(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i);
    String feedback = paramMap.get(AssessmentConstants.ATTR_OVERALL_FEEDBACK_FEEDBACK_PREFIX + i);
    String sequenceId = paramMap.get(AssessmentConstants.ATTR_OVERALL_FEEDBACK_SEQUENCE_ID_PREFIX + i);

    if ((StringUtils.isBlank(feedback) || StringUtils.isBlank(gradeBoundaryStr)) && skipBlankOverallFeedbacks) {
	continue;
    }
    AssessmentOverallFeedback overallFeedback = new AssessmentOverallFeedback();
    overallFeedback.setSequenceId(NumberUtils.toInt(sequenceId));
    if (!StringUtils.isBlank(gradeBoundaryStr)) {
	int gradeBoundary = NumberUtils
		.toInt(paramMap.get(AssessmentConstants.ATTR_OVERALL_FEEDBACK_GRADE_BOUNDARY_PREFIX + i));
	overallFeedback.setGradeBoundary(gradeBoundary);
    }
    overallFeedback.setFeedback(feedback);
    overallFeedbackList.add(overallFeedback);
}
return overallFeedbackList;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:AuthoringAction.java

示例15: editItem

import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
    * Display edit page for existed scratchie item.
    */
   private ActionForward editItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

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

int itemIdx = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ITEM_INDEX), -1);
ScratchieItem item = null;
if (itemIdx != -1) {
    SortedSet<ScratchieItem> itemList = getItemList(sessionMap);
    List<ScratchieItem> rList = new ArrayList<ScratchieItem>(itemList);
    item = rList.get(itemIdx);
    if (item != null) {
	ScratchieItemForm itemForm = (ScratchieItemForm) form;
	itemForm.setTitle(item.getTitle());
	itemForm.setDescription(item.getDescription());
	if (itemIdx >= 0) {
	    itemForm.setItemIndex(new Integer(itemIdx).toString());
	}

	Set<ScratchieAnswer> answerList = item.getAnswers();
	request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList);

	itemForm.setContentFolderID(contentFolderID);
    }
}
request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID);
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:AuthoringAction.java


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