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:MainClass.java

public void setFileStats(File dir) {
    String files[] = dir.list();// w  ww . j av  a 2 s  .c  om
    data = new Object[files.length][titles.length];

    for (int i = 0; i < files.length; i++) {
        File tmp = new File(files[i]);
        data[i][0] = new Boolean(tmp.isDirectory());
        data[i][1] = tmp.getName();
        data[i][2] = new Boolean(tmp.canRead());
        data[i][3] = new Boolean(tmp.canWrite());
        data[i][4] = new Long(tmp.length());
        data[i][5] = new Date(tmp.lastModified());
    }

    fireTableDataChanged();
}

From source file:com.nextdoor.bender.InternalEvent.java

/**
 * @param eventString the raw string data of the event.
 * @param context lambda context of the function.
 * @param arrivalTime epoch time in MS when the event arrived.
 *///w w  w . j av  a2 s. co m
public InternalEvent(String eventString, LambdaContext context, long arrivalTime) {
    this.eventString = eventString;
    this.context = context;
    this.eventSha1Hash = DigestUtils.sha1Hex(this.eventString);
    this.arrivalTime = arrivalTime;
    this.eventTime = arrivalTime;

    this.metadata.put("arrivalEpochMs", new Long(this.arrivalTime));
    this.metadata.put("eventSha1Hash", this.getEventSha1Hash());
}

From source file:com.kactech.otj.examples.App_otj.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    String command = null;//from   w  ww  .  ja v a 2s.  c  o m
    String hisacct = null;
    String hisacctName = null;
    String hisacctAsset = null;
    String asset = null;
    String assetName = null;
    List<String> argList = null;
    boolean newAccount = false;
    File dir = null;
    ConnectionInfo connection = null;
    List<ScriptFilter> filters = null;

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println("Command-line parsing error: " + e.getMessage());
        help();
        System.exit(-1);
    }
    if (cmd.hasOption('h')) {
        help();
        System.exit(0);
    }
    @SuppressWarnings("unchecked")
    List<String> list = cmd.getArgList();
    if (list.size() > 1) {
        System.err.println("only one command is supported, you've typed " + list);
        help();
        System.exit(-1);
    }
    if (list.size() > 0)
        command = list.get(0).trim();

    List<SampleAccount> accounts = ExamplesUtils.getSampleAccounts();

    if (cmd.hasOption('s')) {
        String v = cmd.getOptionValue('s').trim();
        connection = ExamplesUtils.findServer(v);
        if (connection == null) {
            System.err.println("unknown server: " + v);
            System.exit(-1);
        }
    } else {
        connection = ExamplesUtils.findServer(DEF_SERVER_NAME);
        if (connection == null) {
            System.err.println("default server not found server: " + DEF_SERVER_NAME);
            System.exit(-1);
        }
    }

    if (cmd.hasOption('t')) {
        String v = cmd.getOptionValue('t');
        for (SampleAccount ac : accounts)
            if (ac.accountName.startsWith(v)) {
                hisacct = ac.accountID;
                hisacctName = ac.accountName;
                hisacctAsset = ac.assetID;
                break;
            }
        if (hisacct == null)
            if (mayBeValid(v))
                hisacct = v;
            else {
                System.err.println("invalid hisacct: " + v);
                System.exit(-1);
            }
    }
    if (cmd.hasOption('p')) {
        String v = cmd.getOptionValue('p');
        for (SampleAccount ac : accounts)
            if (ac.assetName.startsWith(v)) {
                asset = ac.assetID;
                assetName = ac.assetName;
                break;
            }
        if (asset == null)
            if (mayBeValid(v))
                asset = v;
            else {
                System.err.println("invalid asset: " + v);
                System.exit(-1);
            }
    }

    if (cmd.hasOption('a')) {
        String v = cmd.getOptionValue('a');
        argList = new ArrayList<String>();
        boolean q = false;
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < v.length(); i++) {
            char c = v.charAt(i);
            if (c == '"') {
                if (q) {
                    argList.add(b.toString());
                    b = null;
                    q = false;
                    continue;
                }
                if (b != null)
                    argList.add(b.toString());
                b = new StringBuilder();
                q = true;
                continue;
            }
            if (c == ' ' || c == '\t') {
                if (q) {
                    b.append(c);
                    continue;
                }
                if (b != null)
                    argList.add(b.toString());
                b = null;
                continue;
            }
            if (b == null)
                b = new StringBuilder();
            b.append(c);
        }
        if (b != null)
            argList.add(b.toString());
        if (q) {
            System.err.println("unclosed quote in args: " + v);
            System.exit(-1);
        }
    }

    dir = new File(cmd.hasOption('d') ? cmd.getOptionValue('d') : DEF_CLIENT_DIR);

    if (cmd.hasOption('x'))
        del(dir);

    newAccount = cmd.hasOption('n');

    if (cmd.hasOption('f')) {
        filters = new ArrayList<ScriptFilter>();
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");
        Compilable compilingEngine = (Compilable) engine;
        for (String fn : cmd.getOptionValue('f').split(",")) {
            fn = fn.trim();
            if (fn.isEmpty())
                continue;
            fn += ".js";
            Reader r = null;
            try {
                r = new InputStreamReader(new FileInputStream(new File("filters", fn)), Utils.UTF8);
            } catch (Exception e) {
                try {
                    r = new InputStreamReader(
                            App_otj.class.getResourceAsStream("/com/kactech/otj/examples/filters/" + fn));
                } catch (Exception e2) {
                }
            }
            if (r == null) {
                System.err.println("filter not found: " + fn);
                System.exit(-1);
            } else
                try {
                    CompiledScript compiled = compilingEngine.compile(r);
                    ScriptFilter sf = new ScriptFilter(compiled);
                    filters.add(sf);
                } catch (Exception ex) {
                    System.err.println("error while loading " + fn + ": " + ex);
                    System.exit(-1);
                }
        }
    }

    System.out.println("server: " + connection.getEndpoint() + " " + connection.getID());
    System.out.println("command: '" + command + "'");
    System.out.println("args: " + argList);
    System.out.println("hisacct: " + hisacct);
    System.out.println("hisacctName: " + hisacctName);
    System.out.println("hisacctAsset: " + hisacctAsset);
    System.out.println("asset: " + asset);
    System.out.println("assetName: " + assetName);

    if (asset != null && hisacctAsset != null && !asset.equals(hisacctAsset)) {
        System.err.println("asset differs from hisacctAsset");
        System.exit(-1);
    }

    EClient client = new EClient(dir, connection);
    client.setAssetType(asset != null ? asset : hisacctAsset);
    client.setCreateNewAccount(newAccount);
    if (filters != null)
        client.setFilters(filters);

    try {
        Utils.init();
        Client.DEBUG_JSON = true;
        client.init();

        if ("balance".equals(command))
            System.out.println("Balance: " + client.getAccount().getBalance().getAmount());
        else if ("acceptall".equals(command))
            client.processInbox();
        else if ("transfer".equals(command)) {
            if (hisacct == null)
                System.err.println("please specify --hisacct");
            else {
                int idx = argList != null ? argList.indexOf("amount") : -1;
                if (idx < 0)
                    System.err.println("please specify amount");
                else if (idx == argList.size())
                    System.err.println("amount argument needs value");
                else {
                    Long amount = -1l;
                    try {
                        amount = new Long(argList.get(idx + 1));
                    } catch (Exception e) {

                    }
                    if (amount <= 0)
                        System.err.println("invalid amount");
                    else {
                        client.notarizeTransaction(hisacct, amount);
                    }
                }
            }
        } else if ("reload".equals(command))
            client.reloadState();
        else if ("procnym".equals(command))
            client.processNymbox();
    } finally {
        client.saveState();
        client.close();
    }
}

From source file:com.feilong.core.lang.ObjectUtilTest.java

/**
 * Assert equals./*from  w  ww  .ja va  2  s  . co m*/
 */
@Test
public void assertEquals2() {
    Long a = new Long(1L);
    Long b = new Long(1L);
    assertEquals(false, a == b);
    assertEquals(true, a.equals(b));

    User user = new User(1L);

    List<User> list = toList(//
            user, new User(1L), new User(new Long(1L)));

    for (User user2 : list) {
        LOGGER.debug((user2.getId() == user.getId()) + "");
    }
}

From source file:edu.mayo.qdm.executor.drools.DroolsUtil.java

public static Long toDays(Date date) {
    if (date == null) {
        return null;
    } else {//from www  . j  a  v  a 2 s . com
        return new Long(java.util.concurrent.TimeUnit.MILLISECONDS.toDays(date.getTime()));
    }
}

From source file:gov.nih.nci.ncicb.cadsr.bulkloader.util.excel.ExcelUtility.java

public static Long getLong(HSSFSheet sheet, int row, short col) {
    HSSFRow hssfRow = getRow(sheet, row);

    if (hssfRow == null) {
        return null;
    }// w w w  . j a  v a 2  s  . c  om

    HSSFCell cell = getRow(sheet, row).getCell(col);

    if (isNull(cell)) {
        return null;
    }
    long round = Math.round(cell.getNumericCellValue());
    return new Long(round);
}

From source file:net.gplatform.sudoor.server.tools.fileupload.controller.FileResource.java

@Cacheable(cc = "public, max-age=5184000")
@GET/*from   w  w w .  j a v  a  2s .co m*/
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("{fileId}")
public Response getFile(@PathParam("fileId") String fileId) {
    File f = fileRepository.findOne(new Long(fileId));
    if (f == null) {
        return Response.noContent().build();
    } else {
        return Response.ok(f.getData()).build();
    }
}

From source file:org.openmeetings.app.templates.RegisterUserTemplate.java

public String getRegisterUserWithVerificationTemplate(String username, String userpass, String email,
        Long default_lang_id, String verification_url) {
    try {/*from  w w  w . j  ava  2  s  .  c  om*/

        super.init();

        Fieldlanguagesvalues labelid507 = fieldmanagment.getFieldByIdAndLanguage(new Long(507),
                default_lang_id);
        Fieldlanguagesvalues labelid508 = fieldmanagment.getFieldByIdAndLanguage(new Long(508),
                default_lang_id);
        Fieldlanguagesvalues labelid509 = fieldmanagment.getFieldByIdAndLanguage(new Long(509),
                default_lang_id);
        Fieldlanguagesvalues labelid510 = fieldmanagment.getFieldByIdAndLanguage(new Long(510),
                default_lang_id);
        Fieldlanguagesvalues labelid667 = fieldmanagment.getFieldByIdAndLanguage(new Long(667),
                default_lang_id);
        Fieldlanguagesvalues labelid668 = fieldmanagment.getFieldByIdAndLanguage(new Long(668),
                default_lang_id);

        /* lets make a Context and put data into it */
        VelocityContext context = new VelocityContext();

        context.put("username", username);
        context.put("userpass", userpass);
        context.put("mail", email);
        context.put("verification_url", verification_url);
        context.put("labelid506", fieldmanagment.getString(506L, default_lang_id));
        context.put("labelid507", labelid507.getValue());
        context.put("labelid508", labelid508.getValue());
        context.put("labelid509", labelid509.getValue());
        context.put("labelid510", labelid510.getValue());
        context.put("labelid511", fieldmanagment.getString(511L, default_lang_id));
        context.put("labelid667", labelid667.getValue());
        context.put("labelid668", labelid668.getValue());

        /* lets render a template */

        StringWriter w = new StringWriter();
        Velocity.mergeTemplate(templateNameVerification, "UTF-8", context, w);

        // System.out.println(" template : " + w );

        return w.toString();

    } catch (Exception e) {
        log.error("Problem merging template : ", e);
        // System.out.println("Problem merging template : " + e );
    }
    return null;
}

From source file:caillou.company.clonemanager.gui.service.task.impl.ComputeStatisticTask.java

@Override
protected StatisticAnalyse call() throws Exception {
    workerMonitor.addWorker(WorkerMonitor.STATISTIC_WORKER, this);
    StatisticAnalyse statisticAnalyse = new StatisticAnalyse();

    if (getStatisticToCompute() == null) {
        throw new CloneManagerArgumentException("statisticAnalyse");
    }/* w  w  w.  j a v  a2s  . co  m*/

    statisticAnalyse.setNbFileScanned(new Long(getStatisticToCompute().getMyFilesToTreat().size()));

    if (getMainModel().getTaskModel().getCurrentTask().equals(TaskModel.TASK.DETECT_DOUBLONS)) {
        Map<String, List<GUIApplicationFile>> setPerHash = hashUtil.sortPerMD5(resultingList);

        Long wastedSpace = (long) 0;
        Long numberOfDuplicateFiles = (long) 0;

        for (Map.Entry<String, List<GUIApplicationFile>> entry : setPerHash.entrySet()) {
            Iterator<GUIApplicationFile> iterator = entry.getValue().iterator();
            int i = 0;
            while (iterator.hasNext()) {
                if (i++ == 0) {
                    iterator.next();
                    continue;
                }
                GUIApplicationFile myFile = iterator.next();
                wastedSpace += myFile.getSize();
                numberOfDuplicateFiles += 1;
            }
        }
        statisticAnalyse.setNumberOfDuplicateFiles(numberOfDuplicateFiles);
        statisticAnalyse.setWastedSpace(wastedSpace);
    } else if (getMainModel().getTaskModel().getCurrentTask().equals(TaskModel.TASK.DETECT_MISSING)) {

        Map<String, List<Long>> sizePerHash = new HashMap<>();
        for (GUIApplicationFile guiApplicationFile : resultingList) {
            String MD5Print = guiApplicationFile.getMD5Print() == null
                    ? HashProcessor.process(guiApplicationFile, null)
                    : guiApplicationFile.getMD5Print();
            if (!sizePerHash.containsKey(MD5Print)) {
                sizePerHash.put(MD5Print, new ArrayList<Long>());
            }
            sizePerHash.get(MD5Print).add(guiApplicationFile.getSize());
        }

        Long spaceToDuplicate = (long) 0;
        Long numberOfFileToDuplicate = (long) 0;
        for (Map.Entry<String, List<Long>> entry : sizePerHash.entrySet()) {
            Iterator<Long> iteSize = entry.getValue().iterator();
            numberOfFileToDuplicate += 1;
            spaceToDuplicate += iteSize.next();
        }
        statisticAnalyse.setNbFileToDuplicate(numberOfFileToDuplicate);
        statisticAnalyse.setSpaceToDuplicate(spaceToDuplicate);
    }
    workerMonitor.removeWorker(WorkerMonitor.STATISTIC_WORKER, this);
    return statisticAnalyse;
}

From source file:com.googlecode.psiprobe.controllers.threads.ListSunThreadsController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    List threads = null;/*  w w w. j av a  2s. c om*/
    int executionStackDepth = 1;

    MBeanServer mBeanServer = new Registry().getMBeanServer();
    ObjectName threadingOName = new ObjectName("java.lang:type=Threading");

    long[] deadlockedIds = (long[]) mBeanServer.invoke(threadingOName, "findMonitorDeadlockedThreads", null,
            null);
    long[] allIds = (long[]) mBeanServer.getAttribute(threadingOName, "AllThreadIds");

    if (allIds != null) {
        threads = new ArrayList(allIds.length);

        for (int i = 0; i < allIds.length; i++) {
            CompositeData cd = (CompositeData) mBeanServer.invoke(threadingOName, "getThreadInfo",
                    new Object[] { new Long(allIds[i]), new Integer(executionStackDepth) },
                    new String[] { "long", "int" });

            if (cd != null) {
                SunThread st = new SunThread();
                st.setId(JmxTools.getLongAttr(cd, "threadId"));
                st.setName(JmxTools.getStringAttr(cd, "threadName"));
                st.setState(JmxTools.getStringAttr(cd, "threadState"));
                st.setSuspended(JmxTools.getBooleanAttr(cd, "suspended"));
                st.setInNative(JmxTools.getBooleanAttr(cd, "inNative"));
                st.setLockName(JmxTools.getStringAttr(cd, "lockName"));
                st.setLockOwnerName(JmxTools.getStringAttr(cd, "lockOwnerName"));
                st.setWaitedCount(JmxTools.getLongAttr(cd, "waitedCount"));
                st.setBlockedCount(JmxTools.getLongAttr(cd, "blockedCount"));
                st.setDeadlocked(contains(deadlockedIds, st.getId()));

                CompositeData[] stack = (CompositeData[]) cd.get("stackTrace");
                if (stack.length > 0) {
                    CompositeData cd2 = stack[0];
                    ThreadStackElement tse = new ThreadStackElement();
                    tse.setClassName(JmxTools.getStringAttr(cd2, "className"));
                    tse.setFileName(JmxTools.getStringAttr(cd2, "fileName"));
                    tse.setMethodName(JmxTools.getStringAttr(cd2, "methodName"));
                    tse.setLineNumber(JmxTools.getIntAttr(cd2, "lineNumber", -1));
                    tse.setNativeMethod(JmxTools.getBooleanAttr(cd2, "nativeMethod"));
                    st.setExecutionPoint(tse);
                }

                threads.add(st);
            }
        }
    }
    return new ModelAndView(getViewName(), "threads", threads);
}