List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.java
/** * @see RepositoryService#getEvents(SessionInfo, EventFilter, long) *//*from w w w. j av a2 s . c o m*/ public EventBundle getEvents(SessionInfo sessionInfo, EventFilter filter, long after) throws RepositoryException, UnsupportedRepositoryOperationException { // TODO: use filters remotely (JCR-3179) GetMethod method = null; String rootUri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName()); rootUri += "?type=journal"; // TODO should have a way to discover URI template try { method = new GetMethod(rootUri); method.addRequestHeader("If-None-Match", "\"" + Long.toHexString(after) + "\""); // TODO initMethod(method, sessionInfo); getClient(sessionInfo).executeMethod(method); assert method.getStatusCode() == 200; InputStream in = method.getResponseBodyAsStream(); Document doc = null; if (in != null) { // read response and try to build a xml document try { doc = DomUtil.parseDocument(in); } catch (ParserConfigurationException e) { IOException exception = new IOException("XML parser configuration error"); exception.initCause(e); throw exception; } catch (SAXException e) { IOException exception = new IOException("XML parsing error"); exception.initCause(e); throw exception; } finally { in.close(); } } List<Event> events = new ArrayList<Event>(); ElementIterator entries = DomUtil.getChildren(doc.getDocumentElement(), AtomFeedConstants.N_ENTRY); while (entries.hasNext()) { Element entryElem = entries.next(); Element contentElem = DomUtil.getChildElement(entryElem, AtomFeedConstants.N_CONTENT); if (contentElem != null && "application/vnd.apache.jackrabbit.event+xml".equals(contentElem.getAttribute("type"))) { List<Event> el = buildEventList(contentElem, (SessionInfoImpl) sessionInfo, rootUri); for (Event e : el) { if (e.getDate() > after && (filter == null || filter.accept(e, false))) { events.add(e); } } } } return new EventBundleImpl(events, false); } catch (Exception ex) { log.error("extracting events from journal feed", ex); throw new RepositoryException(ex); } }
From source file:org.apache.hadoop.hive.ql.io.orc.TestInputOutputFormat.java
@Test public void testVectorizationWithAcid() throws Exception { StructObjectInspector inspector = new BigRowInspector(); JobConf conf = createMockExecutionEnvironment(workDir, new Path("mock:///"), "vectorizationAcid", inspector, true, 1);/*from ww w .j av a2s. com*/ // write the orc file to the mock file system Path partDir = new Path(conf.get("mapred.input.dir")); OrcRecordUpdater writer = new OrcRecordUpdater(partDir, new AcidOutputFormat.Options(conf).maximumTransactionId(10).writingBase(true).bucket(0) .inspector(inspector).finalDestination(partDir)); for (int i = 0; i < 100; ++i) { BigRow row = new BigRow(i); writer.insert(10, row); } writer.close(false); Path path = new Path("mock:/vectorizationAcid/p=0/base_0000010/bucket_00000"); setBlocks(path, conf, new MockBlock("host0", "host1")); // call getsplits HiveInputFormat<?, ?> inputFormat = new HiveInputFormat<WritableComparable, Writable>(); InputSplit[] splits = inputFormat.getSplits(conf, 10); assertEquals(1, splits.length); conf.set(IOConstants.SCHEMA_EVOLUTION_COLUMNS, BigRow.getColumnNamesProperty()); conf.set(IOConstants.SCHEMA_EVOLUTION_COLUMNS_TYPES, BigRow.getColumnTypesProperty()); HiveConf.setBoolVar(conf, HiveConf.ConfVars.HIVE_TRANSACTIONAL_TABLE_SCAN, true); org.apache.hadoop.mapred.RecordReader<NullWritable, VectorizedRowBatch> reader = inputFormat .getRecordReader(splits[0], conf, Reporter.NULL); NullWritable key = reader.createKey(); VectorizedRowBatch value = reader.createValue(); assertEquals(true, reader.next(key, value)); assertEquals(100, value.count()); LongColumnVector booleanColumn = (LongColumnVector) value.cols[0]; LongColumnVector byteColumn = (LongColumnVector) value.cols[1]; LongColumnVector shortColumn = (LongColumnVector) value.cols[2]; LongColumnVector intColumn = (LongColumnVector) value.cols[3]; LongColumnVector longColumn = (LongColumnVector) value.cols[4]; DoubleColumnVector floatColumn = (DoubleColumnVector) value.cols[5]; DoubleColumnVector doubleCoulmn = (DoubleColumnVector) value.cols[6]; BytesColumnVector stringColumn = (BytesColumnVector) value.cols[7]; DecimalColumnVector decimalColumn = (DecimalColumnVector) value.cols[8]; LongColumnVector dateColumn = (LongColumnVector) value.cols[9]; TimestampColumnVector timestampColumn = (TimestampColumnVector) value.cols[10]; for (int i = 0; i < 100; i++) { assertEquals("checking boolean " + i, i % 2 == 0 ? 1 : 0, booleanColumn.vector[i]); assertEquals("checking byte " + i, (byte) i, byteColumn.vector[i]); assertEquals("checking short " + i, (short) i, shortColumn.vector[i]); assertEquals("checking int " + i, i, intColumn.vector[i]); assertEquals("checking long " + i, i, longColumn.vector[i]); assertEquals("checking float " + i, i, floatColumn.vector[i], 0.0001); assertEquals("checking double " + i, i, doubleCoulmn.vector[i], 0.0001); Text strValue = new Text(); strValue.set(stringColumn.vector[i], stringColumn.start[i], stringColumn.length[i]); assertEquals("checking string " + i, new Text(Long.toHexString(i)), strValue); assertEquals("checking decimal " + i, HiveDecimal.create(i), decimalColumn.vector[i].getHiveDecimal()); assertEquals("checking date " + i, i, dateColumn.vector[i]); long millis = (long) i * MILLIS_IN_DAY; millis -= LOCAL_TIMEZONE.getOffset(millis); assertEquals("checking timestamp " + i, millis, timestampColumn.getTime(i)); } assertEquals(false, reader.next(key, value)); }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.TestResourceLocalizationService.java
private static LocalResource getMockedResource(Random r, LocalResourceVisibility vis) { String name = Long.toHexString(r.nextLong()); URL url = getPath("/local/PRIVATE/" + name); LocalResource rsrc = BuilderUtils.newLocalResource(url, LocalResourceType.FILE, vis, r.nextInt(1024) + 1024L, r.nextInt(1024) + 2048L, false); return rsrc;/*from ww w .ja va 2 s. c o m*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
public void updatePageTable(BigInteger pageDirectoryBaseAddress) { Vector<IA32PageDirectory> ia32_pageDirectories = new Vector<IA32PageDirectory>(); try {/*from w ww .j a v a2 s . c o m*/ commandReceiver.clearBuffer(); commandReceiver.shouldShow = false; jStatusLabel.setText("Updating page table"); // commandReceiver.setCommandNoOfLine(512); sendCommand("xp /4096bx " + pageDirectoryBaseAddress); float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr; String realStartAddressStr; BigInteger realStartAddress = pageDirectoryBaseAddress; realStartAddressStr = realStartAddress.toString(16); BigInteger realEndAddress = realStartAddress.add(BigInteger.valueOf(totalByte3 * 8)); realEndAddressStr = String.format("%08x", realEndAddress); String result = commandReceiver.getCommandResult(realStartAddressStr, realEndAddressStr, null); if (result != null) { String[] lines = result.split("\n"); DefaultTableModel model = (DefaultTableModel) jPageDirectoryTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } jStatusProgressBar.setMaximum(lines.length - 1); for (int y = 0; y < lines.length; y++) { jStatusProgressBar.setValue(y); String[] b = lines[y].replaceFirst("^.*:", "").trim().split("\t"); for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for (int x = 0; x < 4; x++) { bytes[x] = CommonLib.string2BigInteger(b[x + z * 4].substring(2).trim()).intValue(); } long value = CommonLib.getInt(bytes, 0); // "No.", "PT base", "AVL", "G", // "D", "A", "PCD", "PWT", // "U/S", "W/R", "P" long baseL = value & 0xfffff000; // if (baseL != 0) { String base = "0x" + Long.toHexString(baseL); String avl = String.valueOf((value >> 9) & 3); String g = String.valueOf((value >> 8) & 1); String d = String.valueOf((value >> 6) & 1); String a = String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value >> 1) & 1); String p = String.valueOf((value >> 0) & 1); ia32_pageDirectories .add(new IA32PageDirectory(base, avl, g, d, a, pcd, pwt, us, wr, p)); model.addRow(new String[] { String.valueOf(y * 2 + z), base, avl, g, d, a, pcd, pwt, us, wr, p }); // } } catch (Exception ex) { } } jStatusLabel.setText("Updating page table " + (y + 1) + "/" + lines.length); } jPageDirectoryTable.setModel(model); } } catch (Exception ex) { ex.printStackTrace(); } /* * if (false && Global.debug && * jAutoRefreshPageTableGraphCheckBox.isSelected()) { * System.out.println("aa"); GraphModel model = new DefaultGraphModel(); * GraphLayoutCache view = new GraphLayoutCache(model, new * DefaultCellViewFactory() { public CellView createView(GraphModel * model, Object cell) { CellView view = null; if (model.isPort(cell)) { * view = new PortView(cell); } else if (model.isEdge(cell)) { view = * new EdgeView(cell); } else { if (cell instanceof IA32PageDirectory) { * view = new PageDirectoryView(cell); } else if (cell instanceof * IA32PageTable) { view = new JButtonView(cell, 1); } else { view = new * VertexView(cell); } } return view; } }); JGraph graph = new * JGraph(model, view); * * // add cells * * // DefaultGraphCell[] cells = new // * DefaultGraphCell[ia32_pageDirectories.size() + 1]; * Vector<DefaultGraphCell> cells = new Vector<DefaultGraphCell>(); * DefaultGraphCell root = new DefaultGraphCell("cr3 " + * jRegisterPanel1.jCR3TextField.getText()); * GraphConstants.setGradientColor(root.getAttributes(), Color.red); * GraphConstants.setOpaque(root.getAttributes(), true); * GraphConstants.setBounds(root.getAttributes(), new * Rectangle2D.Double(0, 0, 140, 20)); root.add(new DefaultPort()); * cells.add(root); * * Vector<IA32PageDirectory> pageDirectoryCells = new * Vector<IA32PageDirectory>(); for (int x = 0; x < * ia32_pageDirectories.size(); x++) { IA32PageDirectory cell = * ia32_pageDirectories.get(x); * GraphConstants.setGradientColor(cell.getAttributes(), Color.orange); * GraphConstants.setOpaque(cell.getAttributes(), true); * GraphConstants.setBounds(cell.getAttributes(), new * Rectangle2D.Double(0, x * 20, 140, 20)); cell.add(new DefaultPort()); * pageDirectoryCells.add(cell); * * // page table String pageTableAddress = * ia32_pageDirectories.get(x).base; sendCommand("xp /4096bx " + * pageTableAddress); * * float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int * totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr; * String realStartAddressStr; String baseAddress = pageTableAddress; * long realStartAddress = CommonLib.string2BigInteger(baseAddress); * * realStartAddressStr = String.format("%08x", realStartAddress); long * realEndAddress = realStartAddress + totalByte3 * 8; realEndAddressStr * = String.format("%08x", realEndAddress); * * String result = commandReceiver.getCommandResult(realStartAddressStr, * realEndAddressStr); String[] lines = result.split("\n"); * * Vector<DefaultGraphCell> pageTables = new Vector<DefaultGraphCell>(); * for (int y = 1; y < 4; y++) { String[] b = * lines[y].replaceFirst(" cell.add(new DefaultPort());^.*:", * "").trim().split("\t"); * * for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for * (int x2 = 0; x2 < 4; x2++) { bytes[x2] = * CommonLib.string2BigInteger(b[x2 + z * * 4].substring(2).trim()).intValue(); } long value = * CommonLib.getInt(bytes, 0); * * String base = Long.toHexString(value & 0xfffff000); String avl = * String.valueOf((value >> 9) & 3); String g = String.valueOf((value >> * 8) & 1); String d = String.valueOf((value >> 6) & 1); String a = * String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value * >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us * = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value * >> 1) & 1); String p = String.valueOf((value >> 0) & 1); * IA32PageTable pageTableCell = new IA32PageTable(base, avl, g, d, a, * pcd, pwt, us, wr, p); * GraphConstants.setGradientColor(pageTableCell.getAttributes(), * Color.orange); * GraphConstants.setOpaque(pageTableCell.getAttributes(), true); * GraphConstants.setBounds(pageTableCell.getAttributes(), new * Rectangle2D.Double(0, (z + y) * 20, 140, 20)); pageTableCell.add(new * DefaultPort()); pageTables.add(pageTableCell); } catch (Exception ex) * { } } } * * // group it and link it DefaultGraphCell pt[] = * pageTables.toArray(new DefaultGraphCell[] {}); DefaultGraphCell * vertex1 = new DefaultGraphCell(new String("page table" + x), null, * pt); vertex1.add(new DefaultPort()); cells.add(vertex1); * * DefaultEdge edge = new DefaultEdge(); * edge.setSource(cell.getChildAt(0)); * edge.setTarget(vertex1.getLastChild()); * * GraphConstants.setLineStyle(edge.getAttributes(), * GraphConstants.STYLE_ORTHOGONAL); * GraphConstants.setRouting(edge.getAttributes(), * GraphConstants.ROUTING_DEFAULT); int arrow = * GraphConstants.ARROW_CLASSIC; * GraphConstants.setLineEnd(edge.getAttributes(), arrow); * GraphConstants.setEndFill(edge.getAttributes(), true); * * cells.add(edge); } * * if (pageDirectoryCells.toArray().length > 0) { IA32PageDirectory pt[] * = pageDirectoryCells.toArray(new IA32PageDirectory[] {}); * DefaultGraphCell vertex1 = new DefaultGraphCell(new * String("Vertex1"), null, pt); vertex1.add(new DefaultPort()); * cells.add(vertex1); * * DefaultEdge edge = new DefaultEdge(); * edge.setSource(root.getChildAt(0)); * edge.setTarget(vertex1.getLastChild()); int arrow = * GraphConstants.ARROW_CLASSIC; * GraphConstants.setLineEnd(edge.getAttributes(), arrow); * GraphConstants.setEndFill(edge.getAttributes(), true); * * // lastObj = cells[index]; cells.add(edge); } * * graph.getGraphLayoutCache().insert(cells.toArray()); * graph.setDisconnectable(false); * * JGraphFacade facade = new JGraphFacade(graph); JGraphLayout layout = * new JGraphTreeLayout(); ((JGraphTreeLayout) * layout).setOrientation(SwingConstants.WEST); // * ((JGraphHierarchicalLayout) layout).setNodeDistance(100); * layout.run(facade); Map nested = facade.createNestedMap(true, true); * graph.getGraphLayoutCache().edit(nested); * * // JGraphFacade facade = new JGraphFacade(graph); // JGraphLayout * layout = new JGraphFastOrganicLayout(); // layout.run(facade); // Map * nested = facade.createNestedMap(true, true); // * graph.getGraphLayoutCache().edit(nested); * * jPageTableGraphPanel.removeAll(); jPageTableGraphPanel.add(new * JScrollPane(graph), BorderLayout.CENTER); } */ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void changeText(JTextField jTextField, String value) { Long l = CommonLib.string2long(value); String newValue = "0x" + Long.toHexString(l); if (jTextField.getText().equals(newValue)) { jTextField.setForeground(Color.black); } else {//from w w w .j av a 2 s . c o m jTextField.setForeground(Color.red); } jTextField.setText(newValue); }
From source file:android.provider.Settings.java
/** * Returns the device ID that we should use when connecting to the mobile gtalk server. * This is a string like "android-0x1242", where the hex string is the Android ID obtained * from the GoogleLoginService./* www. j a v a 2s . c o m*/ * * @param androidId The Android ID for this device. * @return The device ID that should be used when connecting to the mobile gtalk server. * @hide */ public static String getGTalkDeviceId(long androidId) { return "android-" + Long.toHexString(androidId); }
From source file:org.openymsg.network.Session.java
/** * Note: the term 'packet' here refers to a YMSG message, not a TCP packet (although in almost all cases the two * will be synonymous). This is to avoid confusion with a 'YMSG message' - the actual discussion packet. * /* ww w. ja v a2 s . co m*/ * service - the Yahoo service number status - the Yahoo status number (not sessionStatus above!) body - the payload * of the packet * * Note: it is assumed that the ConnectionHandler has been open()'d */ protected void sendPacket(final PacketBodyBuffer body, final ServiceType service, final Status status) throws IOException { log.debug("Sending packet on/to the network. SessionId[0x" + Long.toHexString(this.sessionId) + "] ServiceType[" + service + "] Status[" + status + "] Body[" + body + "]"); this.network.sendPacket(body, service, status.getValue(), this.sessionId); }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jPageDirectoryTableMouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { jStatusProgressBar.setValue(0);// w w w. j a v a 2 s .com String pageTableAddress = jPageDirectoryTable.getValueAt(jPageDirectoryTable.getSelectedRow(), 1) .toString(); if (!CommonLib.isNumber(pageTableAddress)) { return; } // commandReceiver.setCommandNoOfLine(512); sendCommand("xp /4096bx " + pageTableAddress); float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr; String realStartAddressStr; String baseAddress = pageTableAddress; BigInteger realStartAddress = CommonLib.string2BigInteger(baseAddress); realStartAddressStr = String.format("%08x", realStartAddress); BigInteger realEndAddress = realStartAddress.add(BigInteger.valueOf(totalByte3 * 8)); realEndAddressStr = String.format("%08x", realEndAddress); String result = commandReceiver.getCommandResult(realStartAddressStr, realEndAddressStr, null); String[] lines = result.split("\n"); PageTableTableModel model = (PageTableTableModel) jPageTableTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } jStatusProgressBar.setMaximum(lines.length - 1); for (int y = 0; y < lines.length; y++) { jStatusProgressBar.setValue(y); String[] b = lines[y].replaceFirst("^.*:", "").trim().split("\t"); for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for (int x = 0; x < 4; x++) { bytes[x] = CommonLib.string2BigInteger(b[x + z * 4].substring(2).trim()).intValue(); } long value = CommonLib.getInt(bytes, 0); // "No.", "PT base", "AVL", "G", // "D", "A", "PCD", "PWT", // "U/S", "W/R", "P" String base = "0x" + Long.toHexString(CommonLib.getValue(value, 12, 31) << 12); String avl = String.valueOf((value >> 9) & 3); String g = String.valueOf((value >> 8) & 1); String pat = String.valueOf((value >> 7) & 1); String d = String.valueOf((value >> 6) & 1); String a = String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value >> 1) & 1); String p = String.valueOf((value >> 0) & 1); boolean tempB = model.isShowZeroAddress(); model.setShowZeroAddress(true); model.addRow(new String[] { String.valueOf(y * 2 + z), base, avl, g, pat, d, a, pcd, pwt, us, wr, p }); model.setShowZeroAddress(tempB); } catch (Exception ex) { } } jPageTableTable.setModel(model); } } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jButton5ActionPerformed(ActionEvent evt) { SaveMemoryToXLSDialog d = new SaveMemoryToXLSDialog(this); long currentMemoryAddress = CommonLib.string2long(jMemoryAddressComboBox.getSelectedItem().toString()); d.jFromTextField.setText("0x" + Long.toHexString(currentMemoryAddress)); d.jToTextField.setText("0x" + Long.toHexString(currentMemoryAddress + 64 * 1024)); d.setVisible(true);/*from ww w. ja v a2 s .co m*/ if (d.ok) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (!file.getName().toLowerCase().endsWith(".xls")) { file = new File(file.getAbsolutePath() + ".xls"); } PeterBochsCommonLib.exportTableModelToExcel(file, jHexTable1.getModel(), jMemoryAddressComboBox.getSelectedItem().toString()); } } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jSearchMemoryButtonActionPerformed(ActionEvent evt) { try {/*from w w w . ja v a2 s . co m*/ if (this.jSearchMemoryToComboBox.getSelectedItem().toString().trim().startsWith("+")) { this.jSearchMemoryToComboBox.setSelectedItem("0x" + Long.toHexString( CommonLib.string2long(this.jSearchMemoryFromComboBox.getSelectedItem().toString()) + CommonLib.string2long( this.jSearchMemoryToComboBox.getSelectedItem().toString().substring(1)))); } new SearchMemoryDialog(this, this.jSearchMemoryTable, this.jSearchMemoryTextField.getText(), CommonLib.string2long(this.jSearchMemoryFromComboBox.getSelectedItem().toString()), CommonLib.string2long(this.jSearchMemoryToComboBox.getSelectedItem().toString())) .setVisible(true); } catch (Exception ex) { } }