Example usage for java.lang Long valueOf

List of usage examples for java.lang Long valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Long valueOf(long l) 

Source Link

Document

Returns a Long instance representing the specified long value.

Usage

From source file:data.services.FreeValueRangeService.java

public FreeValueRange getParam(Object uid, Object valMin, Object valMax, Object amin, Object amax) {
    FreeValueRange fvr = new FreeValueRange();
    fvr.setUid(StringAdapter.getString(uid));
    fvr.setAmax(Long.valueOf(getZeroInNullAndTrim(amax)));
    fvr.setAmin(Long.valueOf(getZeroInNullAndTrim(amin)));
    fvr.setValueMax(Long.valueOf(getZeroInNullAndTrim(valMax)));
    fvr.setValueMin(Long.valueOf(getZeroInNullAndTrim(valMin)));
    //validate(vr);
    return fvr;/*from  w w w  . j av  a  2 s .  c  o  m*/
}

From source file:com.todo.backend.security.JWTUtils.java

public static Authentication getAuthentication(String token, String secretKey) {

    final Claims claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token).getBody();
    final Long userId = Long.valueOf(claims.getSubject());
    final String userRole = claims.get(AUTHORITIES_KEY).toString();

    return new PreAuthenticatedAuthenticationToken(userId, null,
            Collections.singletonList(new SimpleGrantedAuthority(userRole)));
}

From source file:com.milos.neo4j.controller.ScoreboardController.java

@RequestMapping(value = "/scoreboard", method = RequestMethod.GET)
public String getFullScoreboard(HttpServletRequest request, Model model) {
    String type = request.getParameter("type") != null ? request.getParameter("type") : "";
    Long score = request.getParameter("score") != null ? Long.valueOf(request.getParameter("score")) : 1000l;
    Iterable<Scoreboard> scoreboards = new LinkedList<>();
    switch (type) {
    case "montly":
        scoreboards = scoreboardService.getMontlyScoreboard(score);
        break;//from  ww  w.  j  a  v a 2 s.  c  o m
    case "weekly":
        scoreboards = scoreboardService.getWeeklyScoreboard(score);
        break;
    case "daily":
        scoreboards = scoreboardService.getDailyScoreboard(score);
        break;
    case "winnings":
        List<Scoreboard> winnings = scoreboardService.getWinningsScoreboard(score);
        scoreboards = new LinkedList<>(winnings);
        break;
    default:
        type = "montly";
        scoreboards = scoreboardService.getMontlyScoreboard(score);
        break;
    }
    model.addAttribute("scoreboards", scoreboards);
    model.addAttribute("type", type);
    return "scoreboard";
}

From source file:com.devnexus.ting.web.converter.StringToPurchaseGroup.java

@Override
public TicketGroup convert(String source) {
    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {/*from  w ww . j  ava 2 s .co  m*/
        return TicketGroup.fromId(Long.valueOf(source));
    }
}

From source file:com.devnexus.ting.web.converter.StringToPresentationType.java

@Override
public PresentationType convert(String source) {
    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {//  ww  w. j av  a 2 s  . c o m
        return PresentationType.fromId(Long.valueOf(source));
    }
}

From source file:no.smint.anthropos.ldap.PersonAttributesMapper.java

public Person mapFromAttributes(Attributes attributes) throws NamingException {
    Person person = new Person();
    person.setUidNumber(Long.valueOf((String) attributes.get("uidNumber").get()));
    person.setGivenName(attributes.get("givenName") != null ? (String) attributes.get("givenName").get() : "");
    person.setSn(attributes.get("sn") != null ? (String) attributes.get("sn").get() : "");
    person.setCn(attributes.get("cn") != null ? (String) attributes.get("cn").get() : "");
    person.setUid(attributes.get("uid") != null ? (String) attributes.get("uid").get() : "");
    person.setMail(attributes.get("mail") != null ? (String) attributes.get("mail").get() : "");
    person.setTelephoneNumber(/*from ww w  .j ava 2s  .c o m*/
            attributes.get("telephoneNumber") != null ? (String) attributes.get("telephoneNumber").get() : "");

    Attribute memberOfAtt = attributes.get("memberOf");
    if (memberOfAtt != null) {
        ArrayList<String> memberOf = new ArrayList<String>();
        for (int i = 0; i < memberOfAtt.size(); i++) {
            memberOf.add((String) memberOfAtt.get(i));
        }
        person.setMemberOf(memberOf);
    }
    return person;
}

From source file:net.ceos.project.poi.annotated.bean.MultiTypeObjectBuilder.java

/**
 * Create a MultiTypeObject for tests./* w  w  w . ja  va  2  s  .  co m*/
 * 
 * @return the {@link MultiTypeObject}
 */
public static MultiTypeObject buildMultiTypeObject(int multiplier) {
    MultiTypeObject toValidate = new MultiTypeObject();

    toValidate.setDateAttribute(new Date());
    toValidate.setLocalDateAttribute(LocalDate.now());
    toValidate.setLocalDateTimeAttribute(LocalDateTime.now());
    toValidate.setStringAttribute("some string");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name");
    job.setJobName("Job Name");
    toValidate.setJob(job);
    toValidate.setIntegerPrimitiveAttribute(121 * multiplier);
    toValidate.setDoublePrimitiveAttribute(44.6 * multiplier);
    toValidate.setLongPrimitiveAttribute(987654321L * multiplier);
    toValidate.setBooleanPrimitiveAttribute(true);
    /* create sub object AddressInfo */
    AddressInfo ai = new AddressInfo();
    ai.setAddress("this is the street");
    ai.setNumber(99);
    ai.setCity("this is the city");
    ai.setCityCode(70065);
    ai.setCountry("This is a Country");
    toValidate.setAddressInfo(ai);
    toValidate.setFloatAttribute(14.765f * multiplier);
    toValidate.setFloatPrimitiveAttribute(11.1125f * multiplier);
    toValidate.setUnitFamily(UnitFamily.COMPONENTS);
    toValidate.setBigDecimalAttribute(BigDecimal.valueOf(24.777).multiply(BigDecimal.valueOf(multiplier)));
    toValidate.setShortAttribute((short) 17);
    toValidate.setShortPrimitiveAttribute((short) 4);
    // TODO add new fields below

    return toValidate;
}

From source file:com.egt.core.db.ddl.Writer.java

private static void execute(String vm, String clase) {
    if (VelocityEngineer.init()) {
        String c = clase == null ? "*" : clase;
        //          Utils.println("*** combinar(" + vm + ", clase=" + c + ") ***");
        MapaClases mapaClases = new MapaClases();
        try {//w  ww.j  a va2s. com
            if (mapaClases.connected()) {
                if (StringUtils.isNumeric(clase)) {
                    execute(vm, mapaClases.getMap(Long.valueOf(clase)));
                } else if (StringUtils.isNotBlank(clase)) {
                    execute(vm, mapaClases.getMap(clase));
                } else {
                    execute(vm, mapaClases.getMap());
                }
            } else {
                Utils.println("*** error de conexion ***");
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally {
            if (mapaClases != null) {
                mapaClases.close();
                mapaClases = null;
            }
        }
    }
}

From source file:WarUtil.java

private static long readLastModifiled(File file) {
    if (file.exists()) {
        BufferedReader reader = null;
        try {//w  w  w.j  a va 2s .c o  m
            reader = new BufferedReader(new FileReader(file));
            return Long.valueOf(reader.readLine());
        } catch (Exception e) {
            //   log.debug(e.getMessage(), e);
        }
    }
    return 0;
}

From source file:imperial.modaclouds.monitoring.sda.weka.CreateArff.java

/**
 * Create arff file given the data//from  w ww . j  a  v a 2 s  . co m
 * 
 * @param timestamps_str   the timestamps data
 * @param data   the values of the metrics
 * @param metricName   the metric name
 * @param fileName   the file name to keep the arff file
 */
public static void create(ArrayList<ArrayList<String>> timestamps_str, ArrayList<ArrayList<String>> data,
        ArrayList<String> metricName, String fileName) {

    System.out.println("data: " + data.get(0));

    long min_timestamp = Long.valueOf(Collections.min(timestamps_str.get(0)));
    long max_timestamp = Long.valueOf(Collections.max(timestamps_str.get(0)));

    for (int i = 1; i < timestamps_str.size(); i++) {
        long min_temp = Long.valueOf(Collections.min(timestamps_str.get(i)));
        long max_temp = Long.valueOf(Collections.max(timestamps_str.get(i)));

        if (max_temp < max_timestamp) {
            max_timestamp = max_temp;
        }

        if (min_temp > min_timestamp) {
            min_timestamp = min_temp;
        }
    }

    for (int i = 0; i < timestamps_str.size(); i++) {
        Iterator<String> iter_time = timestamps_str.get(i).iterator();
        Iterator<String> iter_data = data.get(i).iterator();

        while (iter_time.hasNext()) {
            long temp_timestamps = Long.valueOf(iter_time.next());
            if (temp_timestamps < min_timestamp || temp_timestamps > max_timestamp) {
                iter_time.remove();

                iter_data.next();
                iter_data.remove();
            }
        }
    }

    double[] timestamps = convertDoubles(timestamps_str.get(0));
    double[] targetData = convertDoubles(data.get(0));

    double[][] otherData = new double[data.size() - 1][timestamps.length];
    for (int i = 0; i < data.size() - 1; i++) {
        double[] timestamps_temp = convertDoubles(timestamps_str.get(i));
        double[] targetData_temp = convertDoubles(data.get(i));

        SplineInterpolator spline = new SplineInterpolator();

        Map<Double, Integer> map = new TreeMap<Double, Integer>();
        for (int j = 0; j < timestamps_temp.length; j++) {
            map.put(timestamps_temp[j], j);
        }
        Collection<Integer> indices = map.values();

        int[] indices_int = ArrayUtils.toPrimitive(indices.toArray(new Integer[indices.size()]));
        double[] timestamps_temp_new = new double[indices_int.length];
        double[] targetData_temp_new = new double[indices_int.length];

        for (int j = 0; j < indices_int.length; j++) {
            timestamps_temp_new[j] = timestamps_temp[indices_int[j]];
            targetData_temp_new[j] = targetData_temp[indices_int[j]];
        }

        PolynomialSplineFunction polynomical = spline.interpolate(timestamps_temp_new, targetData_temp_new);

        for (int j = 0; j < timestamps.length; j++) {
            try {
                otherData[i][j] = polynomical.value(timestamps[j]);
            } catch (Exception ex) {
                otherData[i][j] = targetData_temp_new[j];
            }
        }
    }

    ArrayList<Attribute> attributes;
    Instances dataSet;

    attributes = new ArrayList<Attribute>();

    for (String metric : metricName) {
        attributes.add(new Attribute(metric));
    }

    dataSet = new Instances("data", attributes, 0);

    for (int i = 0; i < timestamps.length; i++) {
        double[] instanceValue1 = new double[dataSet.numAttributes()];
        instanceValue1[0] = timestamps[i];
        instanceValue1[1] = targetData[i];

        for (int j = 0; j < data.size() - 1; j++) {
            instanceValue1[2 + j] = otherData[j][i];
        }

        DenseInstance denseInstance1 = new DenseInstance(1.0, instanceValue1);

        dataSet.add(denseInstance1);
    }

    ArffSaver saver = new ArffSaver();
    saver.setInstances(dataSet);
    try {
        String workingDir = System.getProperty("user.dir");
        System.out.println("workingDir: " + workingDir);
        saver.setFile(new File(workingDir + "/" + fileName));
        saver.writeBatch();
    } catch (IOException e) {
        e.printStackTrace();
    }

}