Example usage for java.lang Integer Integer

List of usage examples for java.lang Integer Integer

Introduction

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

Prototype

@Deprecated(since = "9")
public Integer(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Usage

From source file:controllers.require.RequireApp.java

/**
 * //from  ww w  .java 2 s . com
 */
@Transactional(readOnly = true)
public static Result index() {
    DynamicForm requestData = Form.form().bindFromRequest();
    ListOrderedMap cts = SkillTag.getCacheCategory();
    Integer page = StringUtils.isBlank(requestData.get("page")) ? 1 : new Integer(requestData.get("page"));
    Integer pageSize = StringUtils.isBlank(requestData.get("pageSize")) ? 10
            : new Integer(requestData.get("pageSize"));
    Long categoryId = StringUtils.isBlank(requestData.get("categoryId")) ? (Long) cts.asList().get(0)
            : new Long(requestData.get("categoryId"));
    String type = requestData.get("type") == null ? "html" : requestData.get("type");
    Page<RequireListVO> returnPage = Require.queryRequireByPage(page, pageSize, categoryId);
    if (!type.equals("json")) {
        return ok(views.html.require.index.render(returnPage, cts, categoryId));
    }
    return ok(play.libs.Json.toJson(returnPage));
}

From source file:com.muni.fi.pa165.survive.rest.client.utils.DtoBuilder.java

public static WeaponDto getWeaponDto(CommandLine line) {
    WeaponDto dto = new WeaponDto();
    //name//from   w w  w.j a  v  a 2s .c  o m
    if (line.hasOption("n")) {
        dto.setName(line.getOptionValue("n"));
    }
    //caliber
    if (line.hasOption("m")) {
        dto.setCaliber(new Double(line.getOptionValue("m")));
    }
    //range
    if (line.hasOption("g")) {
        dto.setRange(new Integer(line.getOptionValue("g")));
    }
    //rounds
    if (line.hasOption("r")) {
        dto.setRounds(new Integer(line.getOptionValue("r")));
    }
    //index
    if (line.hasOption("i")) {
        dto.setId(new Long(line.getOptionValue("i")));
    }
    //type
    if (line.hasOption("t")) {
        dto.setWeaponType(WeaponType.valueOf(line.getOptionValue("t").toUpperCase()));
    }
    //class
    if (line.hasOption("c")) {
        dto.setWeaponClass(WeaponClass.valueOf(line.getOptionValue("c").toUpperCase()));
    }
    //desc
    if (line.hasOption("d")) {
        dto.setDescription(line.getOptionValue("d"));
    }
    return dto;

}

From source file:com.thinkbiganalytics.servicemonitor.rest.client.cdh.ClouderaRootResourceManager.java

/**
 * Will attempt to get configured api version. If that fails it will fall back to API v1.
 *///from w ww  .ja va  2 s  .c  om
static ClouderaRootResource getRootResource(ApiRootResource apiRootResource) {

    String version = apiRootResource.getCurrentVersion();
    Integer numericVersion = new Integer(StringUtils.substringAfter(version, "v"));
    RootResourceV1 rootResource = null;
    Integer maxVersion = 10;
    if (numericVersion > maxVersion) {
        numericVersion = maxVersion;
    }

    try {
        rootResource = (RootResourceV1) MethodUtils.invokeMethod(apiRootResource, "getRootV" + numericVersion);
    } catch (Exception ignored) {

    }
    if (rootResource == null) {
        LOG.info("Unable to get RootResource for version {}, returning version 1", numericVersion);
        rootResource = apiRootResource.getRootV1();
    }

    return new DefaultClouderaRootResource(rootResource);

}

From source file:org.restsql.core.impl.SqlUtils.java

public static Object getObjectByColumnNumber(final ColumnMetaData column, final SqlRowSet resultSet) {
    Object value = null;/*  ww w. j  a va  2s  .  c o m*/
    if (column.getColumnType() == Types.DATE && column.getColumnTypeName().equals("YEAR")) {
        value = new Integer(resultSet.getInt(column.getColumnNumber()));
        if (resultSet.wasNull()) {
            value = null;
        }
    } else {
        value = resultSet.getObject(column.getColumnNumber());
    }
    return value;
}

From source file:Main.java

public static void logMessage(int id, String message) {
    logMessage(new Integer(id).toString(), message);
}

From source file:edu.unc.lib.dl.ui.service.XMLRetrievalService.java

public static Document getXMLDocument(String url) throws HttpException, IOException, JDOMException {
    SAXBuilder builder = new SAXBuilder();

    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(url);
    method.getParams().setParameter("http.socket.timeout", new Integer(2000));
    method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(3, false));
    method.getParams().setParameter("http.useragent", "");

    InputStream responseStream = null;
    Document document = null;/*www  . j  a v a  2  s  .  c o m*/

    try {
        client.executeMethod(method);
        responseStream = method.getResponseBodyAsStream();
        document = builder.build(responseStream);
    } finally {
        if (responseStream != null)
            responseStream.close();
        method.releaseConnection();
    }

    return document;
}

From source file:Main.java

/**
 * Given an Object, and an index, returns the nth value in the
 * object./*from  w  ww.  java2 s .com*/
 * <ul>
 * <li>If obj is a Map, returns the nth value from the <b>keySet</b> iterator, unless
 *     the Map contains an Integer key with integer value = idx, in which case the
 *     corresponding map entry value is returned.  If idx exceeds the number of entries in
 *     the map, an empty Iterator is returned.
 * <li>If obj is a List or an array, returns the nth value, throwing IndexOutOfBoundsException,
 *     ArrayIndexOutOfBoundsException, resp. if the nth value does not exist.
 * <li>If obj is an iterator, enumeration or Collection, returns the nth value from the iterator,
 *     returning an empty Iterator (resp. Enumeration) if the nth value does not exist.
 * <li>Returns the original obj if it is null or not a Collection or Iterator.
 * </ul>
 *
 * @param obj  the object to get an index of, may be null
 * @param idx  the index to get
 * @throws IndexOutOfBoundsException
 * @throws ArrayIndexOutOfBoundsException
 *
 * @deprecated use {@link #get(Object, int)} instead. Will be removed in v4.0
 */
public static Object index(Object obj, int idx) {
    return index(obj, new Integer(idx));
}

From source file:Main.java

/**
 *
 * @param doc Document//from w  ww.j a  v  a  2  s .  co  m
 * @param parent Node
 * @param name String
 * @param value int
 * @return Element
 */
public static Element appendChildNode(Document doc, Node parent, String name, int value) {
    Element child = doc.createElement(name);
    child.appendChild(doc.createTextNode(new Integer(value).toString()));
    parent.appendChild(child);
    return child;
}

From source file:UsingContexts.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    HttpSession session = request.getSession(true);

    Integer counter2 = (Integer) getServletContext().getAttribute("counter2");

    if (counter2 == null) {
        counter2 = new Integer(1);
    } else {/*from   ww w .  ja v a 2 s.  c o  m*/
        counter2 = new Integer(counter2.intValue() + 1);
    }

    getServletContext().setAttribute("counter2", counter2);

    Integer counter = (Integer) session.getAttribute("counter");

    if (counter == null) {
        counter = new Integer(1);
    } else {
        counter = new Integer(counter.intValue() + 1);
    }

    session.setAttribute("counter", counter);

    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("Using Contexts");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>Using Contexts</H1>");

    out.println("Welcome! You have been here " + counter + " times.<BR>");

    out.println("Total page accesses: " + counter2 + "<BR>");

    if (session.isNew()) {
        out.println("This is a new session.<BR>");
    } else {
        out.println("This is not a new session.<BR>");
    }

    out.println("The session ID: " + session.getId() + "<BR>");
    out.println("Last time accessed: " + new Date(session.getLastAccessedTime()) + "<BR>");
    out.println("Creation time: " + new Date(session.getCreationTime()) + "<BR>");
    out.println("Timeout length: " + session.getMaxInactiveInterval() + " seconds<BR>");

    out.println("</BODY>");
    out.println("</HTML>");
}

From source file:Main.java

public Main() {
    setSize(200, 150);//from w w w . ja v  a 2 s . c  o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JLayeredPane lp = getLayeredPane();
    JButton top = new JButton();
    top.setBackground(Color.white);
    top.setBounds(20, 20, 50, 50);
    JButton middle = new JButton();
    middle.setBackground(Color.gray);
    middle.setBounds(40, 40, 50, 50);
    JButton bottom = new JButton();
    bottom.setBackground(Color.black);
    bottom.setBounds(60, 60, 50, 50);

    lp.add(middle, new Integer(2));
    lp.add(top, new Integer(3));
    lp.add(bottom, new Integer(1));

    setVisible(true);
}