Example usage for java.lang Long toString

List of usage examples for java.lang Long toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Long 's value.

Usage

From source file:com.facebook.ads.sdk.AdAsyncRequestSet.java

public static AdAsyncRequestSet fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:nz.net.catalyst.MaharaDroid.upload.http.RestClient.java

public static JSONObject AuthSync(String url, String token, String username, Long lastsync,
        String notifications, Context context) {
    Vector<String> pNames = new Vector<String>();
    Vector<String> pVals = new Vector<String>();

    if (token != null) {
        pNames.add("token");
        pVals.add(token);//from  w ww.  java  2s.  c  o m
    }
    if (username != null) {
        pNames.add("username");
        pVals.add(username);
    }
    if (lastsync != null) {
        pNames.add("lastsync");
        pVals.add(lastsync.toString());
    }
    if (lastsync != null) {
        pNames.add("lastsync");
        pVals.add(lastsync.toString());
    }
    if (notifications != null) {
        pNames.add("notifications");
        pVals.add(notifications);
    }

    String[] paramNames, paramVals;
    paramNames = paramVals = new String[] {};
    paramNames = pNames.toArray(paramNames);
    paramVals = pVals.toArray(paramVals);

    return CallFunction(url, paramNames, paramVals, context);
}

From source file:ext.usercenter.UCClient.java

/**
 *  ????<br>//from  w  w w  .  j  a  va2  s  . c o  m
 * ??????????
 * 
 * @param userpassword ?
 * @param username ?null????
 * @param realname ?null????
 * @param email ?null??
 * @param phoneNumber ?null?????
 * @param device android/iphone/ipad/web
 * @param ip ???ip?
 * @param privateId Id
 * @return UCResult.data?email?isable?phoneNumber?realname?token?uid?username?userpassword<br>
 *         ?????????
 */
public static UCResult<UCUser> register(String userpassword, String username, String realname, String email,
        String phoneNumber, String device, String ip, Long privateId) {

    long beginMillis = System.currentTimeMillis();
    String post = postNullIgnore("/remote/security/register", "userpassword", userpassword, "username",
            username, "realname", realname, "email", email, "phoneNumber", phoneNumber, "product", product,
            "device", device, "ip", ip, "privateId", privateId.toString());
    long endMillis = System.currentTimeMillis();
    long callTime = endMillis - beginMillis;
    callTimeLog(callTime, "register", "/remote/security/register");

    UCResult<UCUser> result = UCResult.fromJsonString(post, UCUser.class, true);
    if (result.data == null || StringUtils.isBlank(result.data.userpassword)) {
        LOGGER.error("response error : null param or response. path = /remote/security/register, response = "
                + post);
    }
    return result;
}

From source file:com.nridge.core.base.std.StrUtl.java

/**
 * Convenience method that converts a generic ArrayList of
 * Objects into an array of string values.
 *
 * @param anArrayList Array of value object instances.
 *
 * @return An array of values extracted from the array list.
 *//*from   ww  w . j av a 2 s . c o m*/
public static String[] convertToMulti(ArrayList<?> anArrayList) {
    if ((anArrayList == null) || (anArrayList.size() == 0)) {
        String[] emptyList = new String[1];
        emptyList[0] = StringUtils.EMPTY;
        return emptyList;
    }

    int offset = 0;
    String[] multiValues = new String[anArrayList.size()];

    for (Object arrayObject : anArrayList) {
        if (arrayObject instanceof Integer) {
            Integer integerValue = (Integer) arrayObject;
            multiValues[offset++] = integerValue.toString();
        } else if (arrayObject instanceof Long) {
            Long longValue = (Long) arrayObject;
            multiValues[offset++] = longValue.toString();
        } else if (arrayObject instanceof Float) {
            Float floatValue = (Float) arrayObject;
            multiValues[offset++] = floatValue.toString();
        } else if (arrayObject instanceof Double) {
            Double doubleValue = (Double) arrayObject;
            multiValues[offset++] = doubleValue.toString();
        } else if (arrayObject instanceof Date) {
            Date dateValue = (Date) arrayObject;
            multiValues[offset++] = Field.dateValueFormatted(dateValue, Field.FORMAT_DATETIME_DEFAULT);
        } else
            multiValues[offset++] = arrayObject.toString();
    }

    return multiValues;
}

From source file:net.java.sip.communicator.impl.history.HistoryReaderImpl.java

/**
 * Used to limit the files if any starting or ending date exist
 * So only few files to be searched.//from w  w  w  .  j a  v a 2  s .  c o  m
 *
 * @param filelist Iterator
 * @param startDate Date
 * @param endDate Date
 * @param reverseOrder reverse order of files
 * @return Vector
 */
static Vector<String> filterFilesByDate(Iterator<String> filelist, Date startDate, Date endDate,
        final boolean reverseOrder) {
    if (startDate == null && endDate == null) {
        // no filtering needed then just return the same list
        Vector<String> result = new Vector<String>();
        while (filelist.hasNext()) {
            result.add(filelist.next());
        }

        Collections.sort(result, new Comparator<String>() {

            public int compare(String o1, String o2) {
                if (reverseOrder)
                    return o2.compareTo(o1);
                else
                    return o1.compareTo(o2);
            }
        });

        return result;
    }
    // first convert all files to long
    TreeSet<Long> files = new TreeSet<Long>();
    while (filelist.hasNext()) {
        String filename = filelist.next();

        files.add(Long.parseLong(filename.substring(0, filename.length() - 4)));
    }

    TreeSet<Long> resultAsLong = new TreeSet<Long>();

    // Temporary fix of a NoSuchElementException
    if (files.size() == 0) {
        return new Vector<String>();
    }

    Long startLong;
    Long endLong;

    if (startDate == null)
        startLong = Long.MIN_VALUE;
    else
        startLong = startDate.getTime();

    if (endDate == null)
        endLong = Long.MAX_VALUE;
    else
        endLong = endDate.getTime();

    // get all records inclusive the one before the startdate
    for (Long f : files) {
        if (startLong <= f && f <= endLong) {
            resultAsLong.add(f);
        }
    }

    // get the subset before the start date, to get its last element
    // if exists
    if (!files.isEmpty() && files.first() <= startLong) {
        SortedSet<Long> setBeforeTheInterval = files.subSet(files.first(), true, startLong, true);
        if (!setBeforeTheInterval.isEmpty())
            resultAsLong.add(setBeforeTheInterval.last());
    }

    Vector<String> result = new Vector<String>();

    Iterator<Long> iter = resultAsLong.iterator();
    while (iter.hasNext()) {
        Long item = iter.next();
        result.add(item.toString() + ".xml");
    }

    Collections.sort(result, new Comparator<String>() {

        public int compare(String o1, String o2) {
            if (reverseOrder)
                return o2.compareTo(o1);
            else
                return o1.compareTo(o2);
        }
    });

    return result;
}

From source file:controllers.OldSensorReadingController.java

public static Result add(Boolean publish) throws Exception {
    JsonNode json = request().body().asJson();
    if (json == null) {
        return badRequest("Expecting Json data");
    }/*w w  w.ja va2 s.c  om*/
    if (!checkDao()) {
        return internalServerError("database conf file not found");
    }

    // Parse JSON FIle
    String deviceId = json.findPath("id").getTextValue();
    Long timeStamp = json.findPath("timestamp").getLongValue();
    Iterator<String> it = json.getFieldNames();
    ArrayList<String> error = new ArrayList<String>();
    while (it.hasNext()) {
        String sensorType = it.next();
        if (sensorType == "id" || sensorType == "timestamp")
            continue;
        double value = json.findPath(sensorType).getDoubleValue();
        if (!sensorReadingDao.addReading(deviceId, timeStamp, sensorType, value)) {
            error.add(sensorType + ", " + deviceId + ", " + timeStamp.toString() + ", " + value + "\n");
        }

        if (publish) {
            MessageBusHandler mb = new MessageBusHandler();
            if (!mb.publish(new models.OldSensorReading(deviceId, timeStamp, sensorType, value))) {
                error.add("publish failed");
            }
        }
    }
    if (error.size() == 0) {
        System.out.println("saved");
        return ok("saved");
    } else {
        System.out.println("some not saved: " + error.toString());
        return ok("some not saved: " + error.toString());
    }
}

From source file:ext.msg.model.Message.java

public static boolean deleteMessageBySenderRevicer(Long senderId, Long consumeId, Collection<?> msgTypes) {
    List<Message> resultList = JPA.em().createQuery(
            "from Message m where m.senderOnly = :senderId and m.consumeOnly = :consumeId and m.msgType in (:msgTypes)",
            Message.class).setParameter("senderId", senderId.toString())
            .setParameter("consumeId", consumeId.toString()).setParameter("msgTypes", msgTypes)
            .setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
    if (CollectionUtils.isEmpty(resultList)) {
        return false;
    }//from w ww  .  j ava  2 s.c  om
    for (Message message : resultList)
        JPA.em().remove(message);
    return true;
}

From source file:com.cyphermessenger.client.SyncRequest.java

private static JsonNode pullUpdate(CypherSession session, CypherUser contact, String action, Boolean since,
        Long time) throws IOException, APIErrorException {
    String timeBoundary = "since";
    if (since != null && since == UNTIL) {
        timeBoundary = "until";
    }/* w w  w  . j a v a 2s .  c o  m*/
    HashMap<String, String> pairs = new HashMap<>(3);
    pairs.put("action", action);
    if (contact != null) {
        pairs.put("contactID", contact.getUserID().toString());
    }
    if (time != null) {
        pairs.put(timeBoundary, time.toString());
    }
    HttpURLConnection conn = doRequest("pull", session, pairs);
    if (conn.getResponseCode() != 200) {
        throw new IOException("Server error");
    }

    InputStream in = conn.getInputStream();
    JsonNode node = MAPPER.readTree(in);
    conn.disconnect();
    int statusCode = node.get("status").asInt();
    if (statusCode == StatusCode.OK) {
        return node;
    } else {
        throw new APIErrorException(statusCode);
    }
}

From source file:ips1ap101.lib.base.util.ObjUtils.java

public static String toString(Object o) {
    if (o == null) {
        return null;
    } else if (invalidUIInput(o)) {
        return null;
    } else if (o instanceof Checkbox) {
        return trimToNull(((Checkbox) o).getSelected());
    } else if (o instanceof DropDown) {
        return trimToNull(((DropDown) o).getSelected());
    } else if (o instanceof TextField) {
        return trimToNull(((TextField) o).getText());
    } else if (o instanceof PasswordField) {
        return trimToNull(((PasswordField) o).getPassword());
    } else if (o instanceof CampoArchivo) {
        return StringUtils.trimToNull(((CampoArchivo) o).getServerFileName());
    } else if (o instanceof CampoArchivoMultiPart) {
        return StringUtils.trimToNull(((CampoArchivoMultiPart) o).getServerFileName());
    } else if (o instanceof RecursoCodificable) {
        return StringUtils.trimToNull(((RecursoCodificable) o).getCodigoRecurso());
    } else if (o instanceof RecursoNombrable) {
        return StringUtils.trimToNull(((RecursoNombrable) o).getNombreRecurso());
    } else if (o instanceof RecursoIdentificable) {
        Long id = ((RecursoIdentificable) o).getIdentificacionRecurso();
        return id == null ? null : id.toString();
    } else if (o instanceof RecursoEnumerable) {
        Integer numero = ((RecursoEnumerable) o).getNumeroRecurso();
        return numero == null ? null : numero.toString();
    }/*from w w w .  j  a  v  a  2s.c o m*/
    return o.toString();
}

From source file:ext.msg.model.Message.java

/**
 * ?//www.  j  a va 2s. c o  m
 * @param id
 *            ?Id
 * @param userId
 *            ?Id
 * @return true - ?false - ??
 */
public static boolean deleteMessageById(Long id, Long userId) {
    Cache.remove(Constants.CACHE_MSG_NEWCOUNT + userId);
    List<Message> resultList = JPA.em()
            .createQuery("from Message m " + "where m.id = :id and m.consumeOnly = :userIdStr", Message.class)
            .setParameter("id", id).setParameter("userIdStr", userId.toString()).getResultList();

    if (CollectionUtils.isEmpty(resultList)) {
        return false;
    }

    JPA.em().remove(resultList.get(0));
    return true;
}