List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:MainClass.java
public static void main(String[] args) { long l = 10000000l; Long l2 = new Long(l); System.out.println(l2.longValue()); }
From source file:Main.java
public static void main(String[] args) { Long longObject = new Long("1234567"); long l = longObject.longValue(); System.out.println("long:" + l); }
From source file:Main.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); }
From source file:Main.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); System.out.println(Float.MIN_VALUE); System.out.println(Double.MAX_VALUE); }
From source file:WrappedClassApp.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); System.out.println();/*from w ww.j a v a2 s. c o m*/ Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); System.out.println(Float.MIN_VALUE); System.out.println(Double.MAX_VALUE); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Boolean refBoolean = new Boolean(true); boolean bool = refBoolean.booleanValue(); Byte refByte = new Byte((byte) 123); byte b = refByte.byteValue(); Character refChar = new Character('x'); char c = refChar.charValue(); Short refShort = new Short((short) 123); short s = refShort.shortValue(); Integer refInt = new Integer(123); int i = refInt.intValue(); Long refLong = new Long(123L); long l = refLong.longValue(); Float refFloat = new Float(12.3F); float f = refFloat.floatValue(); Double refDouble = new Double(12.3D); double d = refDouble.doubleValue(); }
From source file:com.linkedin.databus2.client.util.DbusClientClusterUtil.java
/** * @param args//from w ww. ja v a2 s. c o m * DbusClientClusterUtil -s <serverList> -n <namespace> -g <group> -d <dir> members * leader * keys * readSCN <key> * writeSCN <key> SCN [OFFSET] * remove <key> * readLastTS * writeLastTS TIMESTAMP */ public static void main(String[] args) { try { GnuParser cmdLineParser = new GnuParser(); Options options = new Options(); options.addOption("n", true, "Zookeeper namespace [/DatabusClient") .addOption("g", true, "Groupname [default-group-name] ") .addOption("d", true, "Shared directory name [shareddata] ") .addOption("s", true, "Zookeeper server list [localhost:2181] ").addOption("h", false, "help"); CommandLine cmdLineArgs = cmdLineParser.parse(options, args, false); if (cmdLineArgs.hasOption('h')) { usage(); System.exit(0); } String namespace = cmdLineArgs.getOptionValue('n'); if (namespace == null || namespace.isEmpty()) { namespace = "/DatabusClient"; } String groupname = cmdLineArgs.getOptionValue('g'); if (groupname == null || groupname.isEmpty()) { groupname = "default-group-name"; } String sharedDir = cmdLineArgs.getOptionValue('d'); if (sharedDir == null || sharedDir.isEmpty()) { sharedDir = "shareddata"; } String serverList = cmdLineArgs.getOptionValue('s'); if (serverList == null || serverList.isEmpty()) { serverList = "localhost:2181"; } String[] fns = cmdLineArgs.getArgs(); if (fns.length < 1) { usage(); System.exit(1); } String function = fns[0]; String arg1 = (fns.length > 1) ? fns[1] : null; String arg2 = (fns.length > 2) ? fns[2] : null; try { String memberName = "cmd-line-tool"; DatabusClientNode clusterNode = new DatabusClientNode(new DatabusClientNode.StaticConfig(true, serverList, 2000, 5000, namespace, groupname, memberName, false, sharedDir)); DatabusClientGroupMember member = clusterNode.getMember(namespace, groupname, memberName); if (member == null || !member.joinWithoutLeadershipDuties()) { System.err.println("Initialization failed for: " + member); System.exit(1); } if (function.equals("members")) { List<String> mlist = member.getMembers(); for (String m : mlist) { System.out.println(m); } } else if (function.equals("leader")) { String leader = member.getLeader(); System.out.println(leader); } else if (function.equals("keys")) { List<String> keyList = member.getSharedKeys(); if (keyList != null) { for (String m : keyList) { System.out.println(m); } } } else if (function.equals("readSCN")) { List<String> keyList; if (arg1 == null) { keyList = member.getSharedKeys(); } else { keyList = new ArrayList<String>(); keyList.add(arg1); } if (keyList != null) { for (String k : keyList) { if (!k.equals(DatabusClientDSCUpdater.DSCKEY)) { Checkpoint cp = (Checkpoint) member.readSharedData(k); if (cp != null) { System.out.println(k + " " + cp.getWindowScn() + " " + cp.getWindowOffset()); } else { System.err.println(k + " null null"); } } } } } else if (function.equals("writeSCN")) { if (arg1 != null && arg2 != null) { Checkpoint cp = new Checkpoint(); cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION); cp.setWindowScn(Long.parseLong(arg2)); if (fns.length > 3) { cp.setWindowOffset(Integer.parseInt(fns[3])); } else { cp.setWindowOffset(-1); } if (member.writeSharedData(arg1, cp)) { System.out.println(arg1 + " " + cp.getWindowScn() + " " + cp.getWindowOffset()); } else { System.err.println("Write failed! " + member + " couldn't write key=" + arg1); System.exit(1); } } else { usage(); System.exit(1); } } else if (function.equals("readLastTs")) { Long timeInMs = (Long) member.readSharedData(DatabusClientDSCUpdater.DSCKEY); if (timeInMs != null) { System.out.println(DatabusClientDSCUpdater.DSCKEY + " " + timeInMs.longValue()); } else { System.err.println(DatabusClientDSCUpdater.DSCKEY + " null"); } } else if (function.equals("writeLastTs")) { if (arg1 != null) { Long ts = Long.parseLong(arg1); if (member.writeSharedData(DatabusClientDSCUpdater.DSCKEY, ts)) { System.out.println(DatabusClientDSCUpdater.DSCKEY + " " + ts); } else { System.err.println("Write failed! " + member + " couldn't write key=" + DatabusClientDSCUpdater.DSCKEY); System.exit(1); } } else { usage(); System.exit(1); } } else if (function.equals("remove")) { if (!member.removeSharedData(arg1)) { System.err.println("Remove failed! " + arg1); System.exit(1); } } else if (function.equals("create")) { if (!member.createPaths()) { System.err.println("Create path failed!"); System.exit(1); } } else { usage(); System.exit(1); } } catch (InvalidConfigException e) { e.printStackTrace(); usage(); System.exit(1); } } catch (ParseException e) { usage(); System.exit(1); } }
From source file:de.unisb.cs.st.javaslicer.traceResult.TraceResult.java
public static void main(final String[] args) { Options options = createOptions();//www . j a va2s.c o m CommandLineParser parser = new GnuParser(); CommandLine cmdLine; try { cmdLine = parser.parse(options, args, true); } catch (ParseException e) { System.err.println("Error parsing the command line arguments: " + e.getMessage()); return; } if (cmdLine.hasOption('h')) { printHelp(options, System.out); System.exit(0); } InstanceFilter<InstructionInstance> filter; if (cmdLine.hasOption("filter")) { if ("labels".equals(cmdLine.getOptionValue("filter"))) { filter = InstanceFilter.LabelFilter.instance; } else if ("additionals".equals(cmdLine.getOptionValue("filter"))) { filter = InstanceFilter.AdditionalLabelFilter.instance; } else if ("none".equals(cmdLine.getOptionValue("filter"))) { filter = null; } else { System.err.println("Illegal argument for filter: " + cmdLine.getOptionValue("filter")); return; } } else { // default: filter = InstanceFilter.AdditionalLabelFilter.instance; } String[] additionalArgs = cmdLine.getArgs(); if (additionalArgs.length != 1) { System.err.println("Error: No input file given."); printHelp(options, System.err); System.exit(-1); } final File traceFile = new File(additionalArgs[0]); Long threadToTrace = null; if (cmdLine.hasOption('t')) { try { threadToTrace = Long.parseLong(cmdLine.getOptionValue('t')); } catch (final NumberFormatException e) { System.err.println("Illegal thread id: " + cmdLine.getOptionValue('t')); System.exit(-1); } } System.out.println("Opening and reading trace file..."); TraceResult tr = null; try { tr = readFrom(traceFile); } catch (final IOException e) { System.err.println("Error opening trace file: " + e); System.exit(-1); return; } final List<ThreadId> threads = tr.getThreads(); if (threads.size() == 0) { System.err.println("The trace file contains no tracing information."); System.exit(-1); } System.out.println("The trace file contains traces for these threads:"); ThreadId tracing = null; for (final ThreadId t : threads) { if (threadToTrace == null) { if ("main".equals(t.getThreadName()) && (tracing == null || t.getJavaThreadId() < tracing.getJavaThreadId())) tracing = t; } else if (t.getJavaThreadId() == threadToTrace.longValue()) { tracing = t; } System.out.format("%15d: %s%n", t.getJavaThreadId(), t.getThreadName()); } System.out.println(); if (tracing == null) { System.out.println(threadToTrace == null ? "Couldn't find a main thread." : "The thread you selected was not found."); System.exit(-1); return; } System.out.println(threadToTrace == null ? "Selected:" : "You selected:"); System.out.format("%15d: %s%n", tracing.getJavaThreadId(), tracing.getThreadName()); try { if (cmdLine.hasOption("length")) { final BackwardTraceIterator<AbstractInstructionInstance> it = tr.getBackwardIterator(tracing, filter, new AbstractInstructionInstanceFactory()); ProgressMonitor monitor = null; if (cmdLine.hasOption("--progress")) { monitor = new ConsoleProgressMonitor(System.out, "Computing trace length", true, 100, true, true); monitor.start(it); } try { while (it.hasNext()) it.next(); } finally { if (monitor != null) monitor.end(); } System.out.format( "%nNumber of instructions: %d (+ %d additional = %d total instructions)%nReady%n", it.getNumInstructions(), it.getNumFilteredInstructions(), it.getNumInstructions() + it.getNumFilteredInstructions()); } else { System.out.println(); System.out.println("The backward trace:"); BackwardTraceIterator<AbstractInstructionInstance> it = tr.getBackwardIterator(tracing, filter, new AbstractInstructionInstanceFactory()); long nr = 0; String format = "%8d (%8d) %-100s -> %3d %7d %s%n"; System.out.format("%19s %-100s %3s %7s %s%n", "Nr ( intern)", "Location", "Dep", "OccNr", "Instruction"); while (it.hasNext()) { InstructionInstance inst = it.next(); ReadMethod method = inst.getInstruction().getMethod(); ReadClass class0 = method.getReadClass(); System.out.format(format, nr++, inst.getInstanceNr(), class0.getName() + "." + method.getName() + ":" + inst.getInstruction().getLineNumber(), inst.getStackDepth(), inst.getOccurrenceNumber(), inst.toString()); } System.out.format( "%nNumber of instructions: %d (+ %d additional = %d total instructions)%nReady%n", it.getNumInstructions(), it.getNumFilteredInstructions(), it.getNumInstructions() + it.getNumFilteredInstructions()); } } catch (final TracerException e) { System.err.print("Error while tracing: "); e.printStackTrace(System.err); System.exit(-1); } }
From source file:de.unisb.cs.st.javaslicer.slicing.DirectSlicer.java
public static void main(String[] args) { Options options = createOptions();// w w w .j ava 2 s.co m CommandLineParser parser = new GnuParser(); CommandLine cmdLine; try { cmdLine = parser.parse(options, args, true); } catch (ParseException e) { System.err.println("Error parsing the command line arguments: " + e.getMessage()); return; } if (cmdLine.hasOption('h')) { printHelp(options, System.out); System.exit(0); } String[] additionalArgs = cmdLine.getArgs(); if (additionalArgs.length != 2) { printHelp(options, System.err); System.exit(-1); } File traceFile = new File(additionalArgs[0]); String slicingCriterionString = additionalArgs[1]; Long threadId = null; if (cmdLine.hasOption('t')) { try { threadId = Long.parseLong(cmdLine.getOptionValue('t')); } catch (NumberFormatException e) { System.err.println("Illegal thread id: " + cmdLine.getOptionValue('t')); System.exit(-1); } } TraceResult trace; try { trace = TraceResult.readFrom(traceFile); } catch (IOException e) { System.err.format("Could not read the trace file \"%s\": %s%n", traceFile, e); System.exit(-1); return; } List<SlicingCriterion> sc = null; try { sc = StaticSlicingCriterion.parseAll(slicingCriterionString, trace.getReadClasses()); } catch (IllegalArgumentException e) { System.err.println("Error parsing slicing criterion: " + e.getMessage()); System.exit(-1); return; } List<ThreadId> threads = trace.getThreads(); if (threads.size() == 0) { System.err.println("The trace file contains no tracing information."); System.exit(-1); } ThreadId tracing = null; for (ThreadId t : threads) { if (threadId == null) { if ("main".equals(t.getThreadName()) && (tracing == null || t.getJavaThreadId() < tracing.getJavaThreadId())) tracing = t; } else if (t.getJavaThreadId() == threadId.longValue()) { tracing = t; } } if (tracing == null) { System.err.println(threadId == null ? "Couldn't find the main thread." : "The thread you specified was not found."); System.exit(-1); return; } long startTime = System.nanoTime(); DirectSlicer slicer = new DirectSlicer(trace); if (cmdLine.hasOption("--progress")) slicer.addProgressMonitor(new ConsoleProgressMonitor()); Set<Instruction> slice = slicer.getDynamicSlice(tracing, sc); long endTime = System.nanoTime(); List<Instruction> sliceList = new ArrayList<Instruction>(slice); Collections.sort(sliceList); System.out.println("The dynamic slice for criterion " + sc + ":"); for (Instruction insn : sliceList) { System.out.format((Locale) null, "%s.%s:%d %s%n", insn.getMethod().getReadClass().getName(), insn.getMethod().getName(), insn.getLineNumber(), insn.toString()); } System.out.format((Locale) null, "%nSlice consists of %d bytecode instructions.%n", sliceList.size()); System.out.format((Locale) null, "Computation took %.2f seconds.%n", 1e-9 * (endTime - startTime)); }
From source file:de.unisb.cs.st.javaslicer.jung.ShowJungGraph.java
public static void main(String[] args) throws InterruptedException { Options options = createOptions();//from w w w. j a v a 2 s . c o m CommandLineParser parser = new GnuParser(); CommandLine cmdLine; try { cmdLine = parser.parse(options, args, true); } catch (ParseException e) { System.err.println("Error parsing the command line arguments: " + e.getMessage()); return; } if (cmdLine.hasOption('h')) { printHelp(options, System.out); System.exit(0); } String[] additionalArgs = cmdLine.getArgs(); if (additionalArgs.length != 2) { printHelp(options, System.err); System.exit(-1); } File traceFile = new File(additionalArgs[0]); String slicingCriterionString = additionalArgs[1]; Long threadId = null; if (cmdLine.hasOption('t')) { try { threadId = Long.parseLong(cmdLine.getOptionValue('t')); } catch (NumberFormatException e) { System.err.println("Illegal thread id: " + cmdLine.getOptionValue('t')); System.exit(-1); } } TraceResult trace; try { trace = TraceResult.readFrom(traceFile); } catch (IOException e) { System.err.format("Could not read the trace file \"%s\": %s%n", traceFile, e); System.exit(-1); return; } List<SlicingCriterion> sc = null; try { sc = StaticSlicingCriterion.parseAll(slicingCriterionString, trace.getReadClasses()); } catch (IllegalArgumentException e) { System.err.println("Error parsing slicing criterion: " + e.getMessage()); System.exit(-1); return; } List<ThreadId> threads = trace.getThreads(); if (threads.size() == 0) { System.err.println("The trace file contains no tracing information."); System.exit(-1); } ThreadId tracing = null; for (ThreadId t : threads) { if (threadId == null) { if ("main".equals(t.getThreadName()) && (tracing == null || t.getJavaThreadId() < tracing.getJavaThreadId())) tracing = t; } else if (t.getJavaThreadId() == threadId.longValue()) { tracing = t; } } if (tracing == null) { System.err.println(threadId == null ? "Couldn't find the main thread." : "The thread you specified was not found."); System.exit(-1); return; } Transformer<InstructionInstance, Object> transformer; Transformer<Object, String> vertexLabelTransformer; Transformer<Object, String> vertexTooltipTransformer; String granularity = cmdLine.getOptionValue("granularity"); if (granularity == null || "instance".equals(granularity)) { transformer = new Transformer<InstructionInstance, Object>() { @Override public InstructionInstance transform(InstructionInstance inst) { return inst; } }; vertexLabelTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { return getShortInstructionText(((InstructionInstance) inst).getInstruction()); } }; vertexTooltipTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { return getInstructionTooltip(((InstructionInstance) inst).getInstruction()); } }; } else if ("instruction".equals(granularity)) { transformer = new Transformer<InstructionInstance, Object>() { @Override public Instruction transform(InstructionInstance inst) { return inst.getInstruction(); } }; vertexLabelTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { return getShortInstructionText(((Instruction) inst)); } }; vertexTooltipTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { return getInstructionTooltip(((Instruction) inst)); } }; } else if ("line".equals(granularity)) { transformer = new Transformer<InstructionInstance, Object>() { @Override public Line transform(InstructionInstance inst) { return new Line(inst.getInstruction().getMethod(), inst.getInstruction().getLineNumber()); } }; vertexLabelTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { Line line = (Line) inst; return line.getMethod().getName() + ":" + line.getLineNr(); } }; vertexTooltipTransformer = new Transformer<Object, String>() { @Override public String transform(Object inst) { Line line = (Line) inst; return "Line " + line.getLineNr() + " in method " + line.getMethod().getReadClass().getName() + "." + line.getMethod(); } }; } else { System.err.println("Illegal granularity specification: " + granularity); System.exit(-1); return; } int maxLevel = Integer.MAX_VALUE; if (cmdLine.hasOption("maxlevel")) { try { maxLevel = Integer.parseInt(cmdLine.getOptionValue("maxlevel")); } catch (NumberFormatException e) { System.err.println("Argument to \"maxlevel\" must be an integer."); System.exit(-1); return; } } long startTime = System.nanoTime(); ShowJungGraph<Object> showGraph = new ShowJungGraph<Object>(trace, transformer); showGraph.setMaxLevel(maxLevel); showGraph.setVertexLabelTransformer(vertexLabelTransformer); showGraph.setVertexTooltipTransformer(vertexTooltipTransformer); if (cmdLine.hasOption("progress")) showGraph.addProgressMonitor(new ConsoleProgressMonitor()); boolean multithreaded; if (cmdLine.hasOption("multithreaded")) { String multithreadedStr = cmdLine.getOptionValue("multithreaded"); multithreaded = ("1".equals(multithreadedStr) || "true".equals(multithreadedStr)); } else { multithreaded = Runtime.getRuntime().availableProcessors() > 1; } DirectedGraph<Object, SliceEdge<Object>> graph = showGraph.getGraph(tracing, sc, multithreaded); long endTime = System.nanoTime(); System.out.format((Locale) null, "%nSlice graph consists of %d nodes.%n", graph.getVertexCount()); System.out.format((Locale) null, "Computation took %.2f seconds.%n", 1e-9 * (endTime - startTime)); showGraph.displayGraph(graph); }