Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

In this page you can find the example usage for java.lang Integer valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:com.archivas.logging.FileHandler.java

private static int getLimit() {
    LogManager manager = LogManager.getLogManager();
    String cname = FileHandler.class.getName();

    String limitStr = manager.getProperty(cname + ".limit");
    int limit = 10000000;
    if (limitStr != null) {
        limit = Integer.valueOf(limitStr);
    }/*from   www. ja v  a2s . co m*/

    return limit;
}

From source file:org.springframework.social.facebook.api.impl.PagedListUtils.java

public static PagingParameters getPagedListParameters(JsonNode pagingNode, String pageKey) {
    if (pagingNode == null || pagingNode.get(pageKey) == null) {
        return null;
    }/*from   w  w  w  .  j a  va  2  s  .  c om*/
    String pageNode = pagingNode.get(pageKey).textValue();
    String limitString = extractParameterValueFromUrl(pageNode, "limit");
    String sinceString = extractParameterValueFromUrl(pageNode, "since");
    String untilString = extractParameterValueFromUrl(pageNode, "until");
    String offsetString = extractParameterValueFromUrl(pageNode, "offset");
    String after = extractEncodedParameterValueFromUrl(pageNode, "after");
    String before = extractEncodedParameterValueFromUrl(pageNode, "before");

    return new PagingParameters(limitString != null ? Integer.valueOf(limitString) : null,
            offsetString != null ? Integer.valueOf(offsetString) : null,
            sinceString != null ? Long.valueOf(sinceString) : null,
            untilString != null ? Long.valueOf(untilString) : null, after, before);
}

From source file:ipLock.Signal.java

public static Signal valueOf(String data) {
    try {//from   w  ww. j  a  va  2  s . c o  m
        String[] fields = StringUtils.split(data, ':');

        Integer senderId = Integer.valueOf(fields[0]);
        SignalCode code = SignalCode.valueOf(fields[1]);
        String[] params = Arrays.copyOfRange(fields, 2, fields.length);

        return new Signal(senderId, code, params);
    } catch (RuntimeException e) {
        String msg = String.format("message '%s' can not be parsed into client signal", data);
        throw new IllegalArgumentException(msg, e);
    }
}

From source file:com.me.controller.AddBookDetails.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest hsr, HttpServletResponse hsr1)
        throws Exception {

    HttpSession session = hsr.getSession();
    ModelAndView mv = new ModelAndView();
    int val = (Integer.valueOf(hsr.getParameter("noOfBook")));

    session.setAttribute("val", val);

    if (val > 0) {

        mv.setViewName("GetBookDetails");

    }//from ww w  .j av a 2s .c  o m

    return mv;
}

From source file:org.zht.framework.util.ZBeanUtil.java

public static Integer parseInteger(Object value) {
    try {/*from  ww  w  .  j  av  a  2  s  . c  o  m*/
        return Integer.valueOf("" + value);
    } catch (Exception e) {
        return null;
    }
}

From source file:com.nabla.wapp.server.xml.Util.java

public static Integer extractLine(final Exception e) {
    final String message = e.getMessage();
    if (message != null && !message.isEmpty()) {
        // looking for [row,col]:[x,x]
        int from = message.indexOf(ROW_COL);
        if (from >= 0) {
            from += ROW_COL.length();//from   ww  w.  j  a v a  2  s  .c o  m
            int to = message.indexOf(',', from);
            if (to > from) {
                final String row = message.substring(from, to);
                try {
                    return Integer.valueOf(row);
                } catch (Throwable x) {
                    log.warn("fail to convert " + row + " to a row", x);
                }
            }
        }
    }
    return null;
}

From source file:com.github.bysrhq.belajar.domain.formatter.VarietyFormatter.java

public Variety parse(String text, Locale locale) throws ParseException {
    Integer id = Integer.valueOf(text);

    return varietyService.findById(id);
}

From source file:MagicSquare.MagicSquare.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    int n = Integer.valueOf(request.getParameter("num"));
    int[][] array = new int[n][n];
    if (n == 0 | n % 2 == 0) {
        array[0][0] = -1;/*  w w w .ja  v  a  2s  . com*/
    } else {

        int x = 0;
        int y = n / 2;

        int xa = x;
        int ya = y;

        for (int i = 0; i < n * n; i++) {
            if (array[x][y] == 0) {
                xa = x;
                ya = y;
                array[x][y] = i + 1;
                x--;
                y++;
            } else {
                y = ya;
                x = xa;
                x++;
                i--;
            }

            if (y == -1) {
                y = n - 1;
            }
            if (x == -1) {
                x = n - 1;
            }
            if (y == n) {
                y = 0;
            }
            if (x == n) {
                x = 0;
            }
        }
    }
    String resp = "";
    for (int no = 0; no < n; no++) {
        for (int ni = 0; ni < n; ni++) {
            if (ni + 1 == n) {
                resp += array[no][ni] + "";
            } else {
                resp += array[no][ni] + ",";
            }
        }
        if (no + 1 == n) {
            resp += "";
        } else {
            resp += ";";
        }

    }
    //        JSONObject json = new JSONObject();
    //        json.put("hola", array);

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(resp);
}

From source file:net.paulgray.mockrest.course.MockCourseService.java

public Course getCourseForId(String id) {
    Integer courseId = Integer.valueOf(id);
    Criteria crit = sessionFactory.getCurrentSession().createCriteria(MockCourse.class);
    crit.add(Restrictions.eq("id", id));
    return (MockCourse) crit.uniqueResult();
}

From source file:Main.java

/**
 * Convert a string value to a boxed primitive type.
 *
 * @param type the boxed primitive type//from  w  w w.j a v a 2  s.c o  m
 * @param value the string value
 * @return a boxed primitive type
 */
public static Object valueOf(final Class<?> type, final String value) {
    if (type == String.class) {
        return value;
    }
    if (type == boolean.class) {
        return Boolean.valueOf(value);
    }
    if (type == int.class) {
        return Integer.valueOf(value);
    }
    if (type == long.class) {
        return Long.valueOf(value);
    }
    if (type == float.class) {
        return Float.valueOf(value);
    }
    if (type == double.class) {
        return Double.valueOf(value);
    }
    throw new IllegalArgumentException("Unsupported type " + type.getName());
}