List of usage examples for java.lang Long decode
public static Long decode(String nm) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { Long longObject = Long.decode("0Xff"); System.out.println(longObject); }
From source file:org.patientview.patientview.news.NewsDeleteAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = BeanUtils.getProperty(form, "id"); Long idLong = Long.decode(id); LegacySpringUtils.getNewsManager().delete(idLong); NewsUtils.putAppropriateNewsForEditInRequest(request); return mapping.findForward("success"); }
From source file:org.patientview.patientview.feedback.FeedbackEditDisplayAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Long feedbackId = Long.decode(BeanUtils.getProperty(form, "id")); Feedback feedback = LegacySpringUtils.getFeedbackManager().get(feedbackId); request.setAttribute("feedback", feedback); return mapping.findForward("success"); }
From source file:com.example.getstarted.basicactions.UpdateBookServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BookDao dao = (BookDao) this.getServletContext().getAttribute("dao"); try {/* w w w . ja v a 2s . com*/ Book book = dao.readBook(Long.decode(req.getParameter("id"))); req.setAttribute("book", book); req.setAttribute("action", "Edit"); req.setAttribute("destination", "update"); req.setAttribute("page", "form"); req.getRequestDispatcher("/base.jsp").forward(req, resp); } catch (Exception e) { throw new ServletException("Error loading book for editing", e); } }
From source file:org.patientview.patientview.news.NewsViewAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = BeanUtils.getProperty(form, "id"); Long idLong = Long.decode(id); News newsItem = LegacySpringUtils.getNewsManager().getSecure(idLong); request.setAttribute("news", newsItem); NewsUtils.putAppropriateNewsForViewingInRequest(request); return mapping.findForward("success"); }
From source file:NumberUtils.java
/** * Parse the given text into a number instance of the given target class, * using the corresponding default <code>decode</code> methods. Trims the * input <code>String</code> before attempting to parse the number. Supports * numbers in hex format (with leading 0x) and in octal format (with leading 0). * @param text the text to convert/*from ww w . j a v a 2s . co m*/ * @param targetClass the target class to parse into * @return the parsed number * @throws IllegalArgumentException if the target class is not supported * (i.e. not a standard Number subclass as included in the JDK) * @see java.lang.Byte#decode * @see java.lang.Short#decode * @see java.lang.Integer#decode * @see java.lang.Long#decode * @see #decodeBigInteger(String) * @see java.lang.Float#valueOf * @see java.lang.Double#valueOf * @see java.math.BigDecimal#BigDecimal(String) */ public static Number parseNumber(String text, Class<?> targetClass) { // Assert.notNull(text, "Text must not be null"); //Assert.notNull(targetClass, "Target class must not be null"); String trimmed = text.trim(); if (targetClass.equals(Byte.class)) { return Byte.decode(trimmed); } else if (targetClass.equals(Short.class)) { return Short.decode(trimmed); } else if (targetClass.equals(Integer.class)) { return Integer.decode(trimmed); } else if (targetClass.equals(Long.class)) { return Long.decode(trimmed); } else if (targetClass.equals(BigInteger.class)) { return decodeBigInteger(trimmed); } else if (targetClass.equals(Float.class)) { return Float.valueOf(trimmed); } else if (targetClass.equals(Double.class)) { return Double.valueOf(trimmed); } else if (targetClass.equals(BigDecimal.class) || targetClass.equals(Number.class)) { return new BigDecimal(trimmed); } else { throw new IllegalArgumentException( "Cannot convert String [" + text + "] to target class [" + targetClass.getName() + "]"); } }
From source file:controllers.Service.java
public static void toPreview(String surveyId, String resultIDs) { // Find the survey Survey survey = Survey.findById(Long.decode(surveyId)); // make an array of results Collection<NdgResult> results = new ArrayList<NdgResult>(); NdgResult result = null;//from w ww.j a va2 s .c om // Get the result result = NdgResult.find("byId", Long.parseLong(resultIDs)).first(); if (result != null) { results.add(result); } // loop the result for (NdgResult current : results) { List<Question> questions = new ArrayList<Question>(); questions = survey.getQuestions(); LinkedList preview = new LinkedList(); if (questions.isEmpty()) { preview.add("No question"); } // loop the questions in the result for (Question question : questions) { preview.add(question.label); // get answers which correspond with questions Collection<Answer> answers = CollectionUtils.intersection(question.answerCollection, current.answerCollection); if (answers.isEmpty()) { preview.add("No answer"); } else if (answers.size() == 1) { Answer answer = answers.iterator().next(); //System.out.println("Answer " + answer.textData); if (answer.question.questionType.typeName.equalsIgnoreCase(QuestionTypesConsts.IMAGE)) { preview.add(answer.binaryData); } else { preview.add(answer.textData); } } } JSONSerializer previewSerializer = new JSONSerializer(); previewSerializer.rootName("preview"); renderJSON(previewSerializer.serialize(preview)); } }
From source file:org.patientview.patientview.splashpage.SplashPageDeleteAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = BeanUtils.getProperty(form, "id"); Long idLong = Long.decode(id); LegacySpringUtils.getSplashPageManager().delete(idLong); LegacySpringUtils.getSplashPageManager().removeSeenSplashPage(idLong); List<SplashPage> splashpages = LegacySpringUtils.getSplashPageManager().getAll(); request.setAttribute("splashpages", splashpages); return mapping.findForward("success"); }
From source file:org.patientview.patientview.news.NewsEditAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = BeanUtils.getProperty(form, "id"); Long idLong = Long.decode(id); News newsItem = LegacySpringUtils.getNewsManager().get(idLong); request.setAttribute("news", newsItem); UnitUtils.putRelevantUnitsInRequest(request); return mapping.findForward("success"); }
From source file:org.patientview.patientview.feedback.FeedbackEditUpdateAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Long feedbackId = Long.decode(BeanUtils.getProperty(form, "id")); String commentedited = BeanUtils.getProperty(form, "commentedited"); String makepublic = BeanUtils.getProperty(form, "makepublic"); boolean makepublicBool = "true".equals(makepublic); Feedback feedback = LegacySpringUtils.getFeedbackManager().get(feedbackId); feedback.setCommentedited(commentedited); feedback.setMakepublic(makepublicBool); LegacySpringUtils.getFeedbackManager().save(feedback); List feedbacks = LegacySpringUtils.getFeedbackManager().get(feedback.getUnitcode()); request.setAttribute("feedbacks", feedbacks); return LogonUtils.logonChecks(mapping, request); }