List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.exoplatform.shareextension.service.ShareService.java
/** * Create the resources needed to create the upload destination folder and * upload the file/*from w w w .j ava2 s .c om*/ */ private UploadInfo initUpload() { postInfo.activityType = SocialPostInfo.TYPE_DOC; UploadInfo uploadInfo = new UploadInfo(); uploadInfo.uploadId = Long.toHexString(System.currentTimeMillis()); uploadInfo.repository = DocumentHelper.getInstance().repository; uploadInfo.workspace = DocumentHelper.getInstance().workspace; if (postInfo.isPublic()) { // File will be uploaded in the Public folder of the user's drive // e.g. /Users/u___/us___/use___/user/Public/Mobile uploadInfo.drive = ExoConstants.DOCUMENT_PERSONAL_DRIVE_NAME; uploadInfo.folder = "Public/Mobile"; uploadInfo.jcrUrl = DocumentHelper.getInstance().getRepositoryHomeUrl(); } else { // File will be uploaded in the Documents folder of the space's drive // e.g. /Groups/spaces/the_space/Documents/Mobile uploadInfo.drive = ".spaces." + postInfo.destinationSpace.getOriginalName(); uploadInfo.folder = "Mobile"; StringBuffer url = new StringBuffer(postInfo.ownerAccount.serverUrl) .append(ExoConstants.DOCUMENT_JCR_PATH).append("/").append(uploadInfo.repository).append("/") .append(uploadInfo.workspace).append("/Groups/spaces/") .append(postInfo.destinationSpace.getOriginalName()).append("/Documents"); uploadInfo.jcrUrl = url.toString(); } return uploadInfo; }
From source file:edu.cornell.mannlib.vedit.controller.BaseEditController.java
private String createEpoKey() { return Long.toHexString(cal.getTimeInMillis()); }
From source file:org.energy_home.jemma.javagal.layers.data.implementations.Utils.DataManipulation.java
/** * Converts a {@code long} to a {@code List<Byte>}. A long is composed of * eight bytes. Numbering them from 1 (the most important) to 8 (the least * important), the resulting list will have all them placed in the same * order. The pad parameter indicate the minimum size of the resulting list. * In case its size is less then the one indicated in the pad parameter, a * number of leading zeros will be inserted. * /* w w w .j a v a2s . c om*/ * @param toConvert * the long to convert. * @param pad * the minimum size of the returned {@code Byte}'s list. * @return the converted list. */ public static List<Byte> toByteList(Long toConvert, int pad) { List<Byte> toReturn = new ArrayList<Byte>(); String inString = Long.toHexString(toConvert); int length = inString.length(); // Characters must be even in number if (length % 2 != 0) { // System.out // .print("Odd number of chars in conversion from Long to byte[] "); inString = "0" + inString; length = inString.length(); } for (int start = 0; start < length; start += 2) { toReturn.add((byte) Short.parseShort(inString.substring(start, Math.min(length, start + 2)), 16)); } if (toReturn.size() < pad) { int diff = pad - toReturn.size(); for (int i = 0; i < diff; i++) { toReturn.add(0, (byte) 0); } } return toReturn; }
From source file:org.apache.accumulo.master.tableOps.Utils.java
public static long reserveNamespace(String namespaceId, long id, boolean writeLock, boolean mustExist, TableOperation op) throws Exception { if (getLock(namespaceId, id, writeLock).tryLock()) { if (mustExist) { Instance instance = HdfsZooInstance.getInstance(); IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance(); if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + namespaceId)) throw new ThriftTableOperationException(namespaceId, "", op, TableOperationExceptionType.NAMESPACE_NOTFOUND, "Namespace does not exist"); }//from w w w. ja v a2 s . c o m log.info("namespace " + namespaceId + " (" + Long.toHexString(id) + ") locked for " + (writeLock ? "write" : "read") + " operation: " + op); return 0; } else return 100; }
From source file:com.luorrak.ouroboros.catalog.CatalogActivity.java
private void initPostPassword() { if (SettingsHelper.getPostPassword(getApplicationContext()).equals("")) { Random random = new Random(); SettingsHelper.setPostPassword(getApplicationContext(), Long.toHexString(random.nextLong())); }/*ww w .j a v a 2 s . co m*/ }
From source file:com.cloud.agent.api.SecurityGroupRulesCmd.java
private String compressCidr(String cidr) { String[] toks = cidr.split("/"); long ipnum = NetUtils.ip2Long(toks[0]); return Long.toHexString(ipnum) + "/" + toks[1]; }
From source file:net.wastl.webmail.xml.XMLGenericModel.java
/** * Create a unique ID.//from w w w .j a va 2s . c o m * Important: This returns a new Unique ID within this session. * It should be used to generate IDs for Folders and messages so that they can be easily referenced */ public String getNextID() { return Long.toHexString(++current_id).toUpperCase(); }
From source file:UUID.java
private static String digits(long l, int i) { long l1 = 1L << (i * 4); return Long.toHexString(l1 | (l & (l1 - 1L))).substring(1); }
From source file:com.alibaba.wasp.zookeeper.RecoverableZooKeeper.java
public void reconnectAfterExpiration() throws IOException, InterruptedException { LOG.info("Closing dead ZooKeeper connection, session" + " was: 0x" + Long.toHexString(zk.getSessionId())); zk.close();/*from w ww . j ava 2 s . co m*/ this.zk = new ZooKeeper(this.quorumServers, this.sessionTimeout, this.watcher); LOG.info("Recreated a ZooKeeper, session" + " is: 0x" + Long.toHexString(zk.getSessionId())); }
From source file:pcap.application.PcapApplicationTest.java
/** * Test PcapApplication with big endian on entrency. * @throws Exception /*from w w w . j av a2s. c o m*/ */ @Test public void testPcapApplicationBigEndian() throws Exception { System.out.println("Test resulting pcap file with big endian"); String pcapName = "testPcap" + PCAP_EX; String resultingPcapName = "test" + PCAP_EX; File pcap = createTempPCapBigEndian(pcapName); final File resultingPcap = tempFolder.newFile(resultingPcapName); String[] myArgs = { OPTION_F, pcap.getAbsolutePath(), resultingPcap.getAbsolutePath() }; PcapCommandLineParser parser = new PcapCommandLineParser(myArgs); ApplicationHandler handler = new ApplicationHandler(parser.getOutFile()); PCapImportTask importTask = PCapHelper.createImportTask(parser.getInFile(), handler); importTask.init(); while (!importTask.isFinished()) { importTask.processNext(); } long[] expBin = { 0xa1b2c3d400020004L, 0x0000000000000000L, 0x0000ffff00000001L, 0x42c23479000871cdL, 0x000000080000004bL, 0x1234ffff0000121aL }; DataInputStream inputStream = new DataInputStream(new FileInputStream(resultingPcap)); int count = inputStream.available() / 8; long[] b = new long[count]; for (int i = 0; i < count; i++) { b[i] = inputStream.readLong(); System.out.println(Long.toHexString(b[i])); } assertTrue(Arrays.equals(b, expBin)); }