Example usage for java.lang Long parseLong

List of usage examples for java.lang Long parseLong

Introduction

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

Prototype

public static long parseLong(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal long .

Usage

From source file:controllers.skilltag.SkillTagApp.java

@Transactional(readOnly = true)
public static Result list() {
    DynamicForm requestData = Form.form().bindFromRequest();
    String p = requestData.get("p") == null ? "1" : requestData.get("p");
    Long i = StringUtils.isBlank(requestData.get("i")) ? 2L : Long.parseLong(requestData.get("i"));
    String s = StringUtils.isBlank(requestData.get("s")) ? null : requestData.get("s");

    String cf = requestData.get("cf");
    String ssf = requestData.get("ssf");
    String ef = requestData.get("ef");
    String gf = requestData.get("gf");
    String o = requestData.get("o");
    String ot = requestData.get("ot");

    List<SkillTag> skillTags = SkillTag.getAll(i, 1, "all");

    List<TagListVo> ivs = new ArrayList<TagListVo>();
    List<TagListVo> svs = new ArrayList<TagListVo>();
    ScriptEngine engine = SemUtils.getEngine();
    try {//from ww  w  .  j a  v  a2 s . co m
        for (SkillTag st : skillTags) {
            TagListVo tv = new TagListVo();
            tv.setTagName(st.tagName);
            tv.setTagId(st.id);
            if (st.tagType != null && st.tagType.ordinal() == SkillTag.TagType.CATEGORY.ordinal()) {
                if (st.id.equals(i))
                    tv.setIsCurr(true);
                tv.setHref(controllers.skilltag.routes.SkillTagApp.list().url() + "?p=1&i=" + tv.getTagId());
                ivs.add(tv);
            } else {
                tv.setHref(controllers.skilltag.routes.SkillTagApp.list().url() + "?p=1&i=" + i + "&s="
                        + engine.eval("encodeURIComponent('" + tv.getTagName() + "')").toString());
                svs.add(tv);
            }
        }
        if (StringUtils.isNotBlank(s)) {
            TagListVo tv = new TagListVo();
            tv.setTagName(s);
            tv.setIsCurr(true);
            tv.setHref(controllers.skilltag.routes.SkillTagApp.list().url() + "?p=1&i=" + i + "&s="
                    + engine.eval("encodeURIComponent('" + tv.getTagName() + "')").toString());
            svs.add(0, tv);
        }
    } catch (ScriptException e) {
        e.printStackTrace();
    }
    List<ExpertListVO> elv = getTagExperts(p, i, s, cf, ssf, ef, gf, o, ot);
    SPage spage = new SPage(Integer.parseInt(p), i, s, cf, ssf, ef, gf, o, ot, ivs, svs, elv);
    List<String> countryList = SkillTag.getCountryNameWithCache();
    spage.setCountryList(countryList);

    return ok(views.html.skilltag.skilltagall.render(spage));
}

From source file:com.dub.skoolie.web.forms.conversion.IdToSchoolYearConverter.java

@Override
public SchoolYearBean convert(String s) {
    return schoolYearServiceImpl.getByID(Long.parseLong(s));
}

From source file:ch.newscron.encryption.ReferralManagerJUnitTest.java

@AfterClass
public static void tearDownClass() throws SQLException {
    // Delete inserted query
    con = ReferralManager.connect();/*ww  w  . j  av a  2  s. com*/
    PreparedStatement query = null;
    query = con.prepareStatement("DELETE FROM ShortURL WHERE custId= ? AND shortUrl = ?");
    query.setLong(1, Long.parseLong((String) inviteData.get("custID")));
    query.setString(2, shortURL);
    query.execute();
    ReferralManager.disconnect(con, null);
}

From source file:com.docd.purefm.commandline.CommandDu.java

public static long du_s(@NonNull final GenericFile file) {
    final List<String> result = CommandLine.executeForResult(new CommandDu(file));
    if (result == null || result.isEmpty()) {
        return 0L;
    }//from ww  w .  j ava 2s.  c  om
    final String res = result.get(0);
    final int resLength = res.length();
    final StringBuilder lengthString = new StringBuilder(resLength);
    for (int i = 0; i < resLength; i++) {
        final char character = res.charAt(i);
        if (Character.isDigit(character)) {
            lengthString.append(character);
        } else {
            break;
        }
    }
    try {
        return Long.parseLong(lengthString.toString()) * FileUtils.ONE_KB;
    } catch (NumberFormatException e) {
        return 0L;
    }
}

From source file:com.dub.skoolie.web.forms.conversion.IdToGradingPeriodConverter.java

@Override
public GradingPeriodBean convert(String s) {
    return gradingPeriodServiceImpl.getByID(Long.parseLong(s));
}

From source file:Main.java

/**
 * Find an element, return as a long.//from w ww. java  2 s  .c  o m
 * @param e The element that searches.
 * @param find What we are searching for.
 * @param def The default value, if we fail to find it.
 * @return The value found, default value otherwise.
 */
public static long findElementAsLong(final Element e, final String find, final long def) {
    final String str = findElementAsString(e, find);
    if (str == null) {
        return def;
    }
    try {
        return Long.parseLong(str);
    } catch (final NumberFormatException ex) {
        return def;
    }
}

From source file:com.intuit.tank.service.impl.v1.report.FileReader.java

/**
 * Gets a StreamingOutput from the passedin file from start to end or from beginning to end if start is greater than
 * end. if a negative number is passed, it will get the last n lines of the file. If 0 is passed it will return the
 * entire file.//  w  ww.ja  v  a  2 s. c  o  m
 * 
 * @param total
 * 
 * @return a StreamingOutput
 */
public static StreamingOutput getFileStreamingOutput(final File f, long total, String start) {

    long l = 0;
    if (start != null) {
        try {
            l = Long.parseLong(start);
            // num lines to get from end
            if (l < 0) {
                l = getStartChar(f, Math.abs(l), total);
            }
        } catch (Exception e) {
            LOG.error("Error parsing start " + start + ": " + e);
        }
    }
    final long to = l > total ? 0 : total;
    final long from = l;

    StreamingOutput streamer = new StreamingOutput() {
        @SuppressWarnings("resource")
        @Override
        public void write(final OutputStream output) throws IOException, WebApplicationException {

            final FileChannel inputChannel = new FileInputStream(f).getChannel();
            final WritableByteChannel outputChannel = Channels.newChannel(output);
            try {
                inputChannel.transferTo(from, to, outputChannel);
            } finally {
                // closing the channels
                inputChannel.close();
                outputChannel.close();
            }
        }
    };
    LOG.debug("returning data from " + from + " - " + to + " of total " + total);
    return streamer;
}

From source file:com.oakesville.mythling.media.Cut.java

/**
 * Uses MythTV format./*from  ww w.j  av a2  s . c  om*/
 */
public static ArrayList<Cut> parseCutList(JSONObject jsonObj) throws JSONException {
    ArrayList<Cut> cuts = new ArrayList<Cut>();
    JSONObject cutList = jsonObj.getJSONObject("CutList");
    JSONArray cuttings = cutList.getJSONArray("Cuttings");
    int curCutStart = -1;
    for (int i = 0; i < cuttings.length(); i++) {
        JSONObject cutting = cuttings.getJSONObject(i);
        int mark = Integer.parseInt(cutting.getString("Mark"));
        long offset = Long.parseLong(cutting.getString("Offset"));
        if (mark == 4)
            curCutStart = (int) (offset / 1000);
        else if (mark == 5)
            cuts.add(new Cut(curCutStart, (int) (offset / 1000)));
    }
    return cuts;
}

From source file:com.exalttech.trex.stateful.models.trexglobal.FilterTrexGlobalResponseUtil.java

/**
 * Filter Response to create PortProperty
 *
 * @return/*from  ww w  .ja v  a 2  s  .  c  o m*/
 */
public static List<PortProperties> createPortPropertiesArray(String response) {
    JSONObject jObject = new JSONObject(response);
    JSONObject data = jObject.getJSONObject("data");
    int numOfPorts = countNumberOfPorts(response);

    List<PortProperties> portProperties = new ArrayList<PortProperties>();
    for (int i = 0; i < numOfPorts; i++) {
        portProperties.add(
                new PortProperties(Long.parseLong(data.get(Constants.PORT_OPACKETS_KEY + "-" + i).toString()),
                        Long.parseLong(data.get(Constants.PORT_OBYTES_KEY + "-" + i).toString()),
                        Long.parseLong(data.get(Constants.PORT_IPACKETS_KEY + "-" + i).toString()),
                        Long.parseLong(data.get(Constants.PORT_IBYTES_KEY + "-" + i).toString()),
                        Long.parseLong(data.get(Constants.PORT_IERROR_KEY + "-" + i).toString()),
                        Long.parseLong(data.get(Constants.PORT_OERROR_KEY + "-" + i).toString()),
                        Double.parseDouble(data.get(Constants.PORT_M_TOTAL_TX_BPS_KEY + "-" + i).toString()),
                        Double.parseDouble(data.get(Constants.PORT_M_TOTAL_TX_PPS_KEY + "-" + i).toString()),
                        Double.parseDouble(data.get(Constants.PORT_M_TOTAL_RX_BPS_KEY + "-" + i).toString()),
                        Double.parseDouble(data.get(Constants.PORT_M_TOTAL_RX_PPS_KEY + "-" + i).toString())));
    }
    return portProperties;
}

From source file:com.itn.configuration.RoleToUserProfileConverter.java

@Override
public UserProfile convert(Object s) {
    //Converting object s to string and then converting it to long
    Long id = Long.parseLong((String) s);
    return userProfileService.findById(id);
}