Example usage for java.lang Long Long

List of usage examples for java.lang Long Long

Introduction

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

Prototype

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

Source Link

Document

Constructs a newly allocated Long object that represents the long value indicated by the String parameter.

Usage

From source file:Main.java

/**
 * Given an array of objects, traverses the array and determines the most
 * suitable data type to perform the calculation in. An empty object of
 * the correct class is returned;/* ww  w . j  av a  2 s  .  co m*/
 *
 * @param objects
 *
 */
static Object getObject(Object[] objects) {
    Class bestClass = bestClass(objects);

    if (bestClass == String.class) {
        return new String(""); //$NON-NLS-1$
    } else if (bestClass == Double.class) {
        return new Double(0);
    } else if (bestClass == Float.class) {
        return new Float(0);
    } else if (bestClass == Long.class) {
        return new Long(0);
    } else if (bestClass == Integer.class) {
        return new Integer(0);
    } else { //it's a type we don't have here yet
        return null;
    }
}

From source file:controllers.user.UserAvatarApp.java

/**
 * flash ?//w  w  w. j a v a 2s  . c om
 * 
 * @return
 */
@Transactional
public static Result upload() {
    User current = null;
    String userId = request().getQueryString("userId");
    if (StringUtils.isNotBlank(userId)) {
        current = User.findById(new Long(userId));
    } else {
        current = User.getFromSession(session());
    }
    ObjectNodeResult result = new ObjectNodeResult();
    File avatarFile = request().body().asRaw().asFile();
    try {
        save(avatarFile, result, current);
    } catch (AvatarException e) {
        e.printStackTrace();
        result.errorkey("useravatar.error.upload");
        return ok(result.getObjectNode());
    }
    return ok(result.getObjectNode());
}

From source file:Main.java

public static ContentValues listToContentValues(List<String> values, String type) {
    ContentValues contentvalues = new ContentValues();

    //Place values into contentvalue structure
    for (int i = 0; i < values.size(); i++) {
        String current = values.get(i);

        try {//from  ww  w .  ja v  a 2 s .  com
            //Separate the value by = in order to get key:value
            Integer indexOfEquals = current.indexOf("=");
            String key = current.substring(0, indexOfEquals);
            String value = current.substring(indexOfEquals + 1);

            if (type.toUpperCase().equals("STRING"))
                contentvalues.put(key, value);

            if (type.toUpperCase().equals("BOOLEAN"))
                contentvalues.put(key, Boolean.valueOf(value));

            if (type.toUpperCase().equals("INTEGER"))
                contentvalues.put(key, new Integer(value));

            if (type.toUpperCase().equals("DOUBLE"))
                contentvalues.put(key, new Double(value));

            if (type.toUpperCase().equals("FLOAT"))
                contentvalues.put(key, new Float(value));

            if (type.toUpperCase().equals("LONG"))
                contentvalues.put(key, new Long(value));

            if (type.toUpperCase().equals("SHORT"))
                contentvalues.put(key, new Short(value));
        } catch (Exception e) {
            Log.e("mercury", "Error with argument " + current);
        }

    }

    return contentvalues;
}

From source file:controllers.user.UserResumeApp.java

/**
 * Tab??//from w ww. j av a  2s  .  co  m
 * 
 * @return
 */
@Transactional(readOnly = true)
public static Result baseview() {
    DynamicForm requestData = Form.form().bindFromRequest();
    String userId = requestData.get("userId");
    ExpertDetailInfo expert = Expert.viewBaseByUserId(new Long(userId));
    List<SkillTag> sts = SkillTag.getCategoryTag(false);
    List<STagVo> ss = new ArrayList<STagVo>();
    for (SkillTag st : sts) {
        STagVo stv = new STagVo();
        stv.setSid(st.id);
        stv.setTag(st.tagName);
        if (expert.getInId().contains(stv.getSid()))
            stv.setIsMarked(true);
        ss.add(stv);
    }
    return ok(views.html.usercenter.detailUS.base.render(expert, ss));
}

From source file:controllers.group.GroupMsgApp.java

/**
 * ???/* w  ww .j  a va2s  . c  o  m*/
 * @return
 * @throws IOException 
 */
@Transactional
public static Result agreeInvit() throws IOException {
    User currentUser = User.getFromSession(session());
    ObjectNodeResult result = new ObjectNodeResult();
    Long groupId = new Long(request().getQueryString("groupId"));
    Long messageId = new Long(request().getQueryString("messageId"));
    Group group = Group.queryGroupById(groupId);
    if (group == null)
        return ok(result.errorkey("group.error.nofound").getObjectNode());
    if (group.getType() != null && group.getType() == Group.Type.NORMAL) { // ??
        User recevierUser = User.findById(group.owner.userId);
        List<User> userList = Group.queryUserListOfGroup(groupId); // ?
        if (!userList.contains(currentUser)) { // ?
            ChatService.appendMemberToGroup(groupId, currentUser.id);
            MessageService.pushMsgInvitAgree(currentUser, recevierUser, group);
            MessageService.handlerMessage(messageId);
        } else {
            MessageService.handlerMessage(messageId);
            return ok(result.error("?.").getObjectNode());
        }

    }
    return ok(result.getObjectNode());
}

From source file:Main.java

/**
 * Loads an index (Hashtable) from a file.
 * /*from   w  w  w  .j  a v  a 2 s  .  c o m*/
 * @param root_
 *            The file where the index is stored in.
 * @return The indextable.
 * @exception IOException
 *                If an internal error prevents the file from being read.
 */
public static Hashtable loadIndex(File root_, String name) throws IOException {
    File indexfile = new File(root_, name);
    Hashtable index = new Hashtable();
    if (indexfile.exists()) {
        LineNumberReader in = new LineNumberReader(new FileReader(indexfile));
        while (in.ready())
            index.put(in.readLine(), new Long(in.readLine()));
        in.close();
    }
    return index;
}

From source file:edu.umm.radonc.ca_dash.model.DoctorStats.java

public DoctorStats() {
    this.averageDailyPatients = new SynchronizedDescriptiveStatistics();
    this.totalPatients = new Long(0);
}

From source file:MainClass.java

@Test
public void testCopy() {
    assertEquals(12, 12);
    assertEquals(12L, 12L);
    assertEquals(new Long(12), new Long(12));

}

From source file:AutoServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    //client browser will request the page every 60 seconds
    HttpSession session = request.getSession();
    Long times = (Long) session.getAttribute("times");
    if (times == null)
        session.setAttribute("times", new Long(0));
    long temp = 1;
    if (times != null)
        temp = (times.longValue()) + 1;//from  w w w  . java 2 s. c o m

    if (temp < 5)
        response.addHeader("Refresh", "15");

    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println("<html><head><title>Client Refresh</title></head><body>");

    //More HTML or dynamic content
    out.println("You've viewed this page " + temp + " times.");
    session.setAttribute("times", new Long(temp));
    out.println("</body></html>");

}

From source file:Main.java

public static Set<Long> toSet(long... array) {
    if (isEmpty(array)) {
        return new HashSet<>(0);
    }/*from  w  w  w.ja v a  2s  . com*/
    Set<Long> set = new HashSet<>(array.length);
    for (long l : array) {
        set.add(new Long(l));
    }
    return set;
}