com.google.common.primitives.UnsignedInts Java Examples
The following examples show how to use
com.google.common.primitives.UnsignedInts.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobsScanner.java From quartz-glass with Apache License 2.0 | 6 votes |
private void createTriggerByGlassTrigger(Class<?> clazz, GlassTrigger glassTrigger) throws Exception { GlassTriggerFactoryBean factoryBean = new GlassTriggerFactoryBean(); if (StringUtils.isBlank(glassTrigger.name())) { factoryBean.setName("Auto@" + UnsignedInts.toString(UUID.randomUUID().hashCode())); } else { factoryBean.setName(glassTrigger.name()); } factoryBean.setGroup(glassTrigger.group()); factoryBean.setJobClass(clazz); factoryBean.setTriggerDataMap(glassTrigger.triggerDataMap()); factoryBean.setScheduler(glassTrigger.scheduler()); factoryBean.setStartDelay(glassTrigger.startDelay()); beanFactory.autowireBean(factoryBean); factoryBean.afterPropertiesSet(); }
Example #2
Source File: JoH.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static boolean checkChecksum(byte[] bytes) { if ((bytes == null) || (bytes.length < 4)) return false; final CRC32 crc = new CRC32(); crc.update(bytes, 0, bytes.length - 4); final long buffer_crc = UnsignedInts.toLong(ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(bytes.length - 4)); return buffer_crc == crc.getValue(); }
Example #3
Source File: CloudTraceFormat.java From opencensus-java with Apache License 2.0 | 5 votes |
@Override public <C /*>>> extends @NonNull Object*/> SpanContext extract(C carrier, Getter<C> getter) throws SpanContextParseException { checkNotNull(carrier, "carrier"); checkNotNull(getter, "getter"); try { String headerStr = getter.get(carrier, HEADER_NAME); if (headerStr == null || headerStr.length() < MIN_HEADER_SIZE) { throw new SpanContextParseException("Missing or too short header: " + HEADER_NAME); } checkArgument(headerStr.charAt(TRACE_ID_SIZE) == SPAN_ID_DELIMITER, "Invalid TRACE_ID size"); TraceId traceId = TraceId.fromLowerBase16(headerStr.subSequence(0, TRACE_ID_SIZE)); int traceOptionsPos = headerStr.indexOf(TRACE_OPTION_DELIMITER, TRACE_ID_SIZE); CharSequence spanIdStr = headerStr.subSequence( SPAN_ID_START_POS, traceOptionsPos < 0 ? headerStr.length() : traceOptionsPos); SpanId spanId = longToSpanId(UnsignedLongs.parseUnsignedLong(spanIdStr.toString(), 10)); TraceOptions traceOptions = OPTIONS_NOT_SAMPLED; if (traceOptionsPos > 0) { String traceOptionsStr = headerStr.substring(traceOptionsPos + TRACE_OPTION_DELIMITER_SIZE); if ((UnsignedInts.parseUnsignedInt(traceOptionsStr, 10) & CLOUD_TRACE_IS_SAMPLED) != 0) { traceOptions = OPTIONS_SAMPLED; } } return SpanContext.create(traceId, spanId, traceOptions, TRACESTATE_DEFAULT); } catch (IllegalArgumentException e) { throw new SpanContextParseException("Invalid input", e); } }
Example #4
Source File: Zip.java From turbine with Apache License 2.0 | 5 votes |
/** The entry data. */ public byte[] data() { // Read the offset and variable lengths from the central directory and then try to map in the // data section in one shot. long offset = UnsignedInts.toLong(cd.getInt(cdindex + CENOFF)); int nameLength = cd.getChar(cdindex + CENNAM); int extLength = cd.getChar(cdindex + CENEXT); int compression = cd.getChar(cdindex + CENHOW); switch (compression) { case 0x8: return getBytes( offset, nameLength, extLength, UnsignedInts.toLong(cd.getInt(cdindex + CENSIZ)), /*deflate=*/ true); case 0x0: return getBytes( offset, nameLength, extLength, UnsignedInts.toLong(cd.getInt(cdindex + CENLEN)), /*deflate=*/ false); default: throw new AssertionError( String.format("unsupported compression mode: 0x%x", compression)); } }
Example #5
Source File: JoH.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static boolean checkChecksum(byte[] bytes) { if ((bytes == null) || (bytes.length < 4)) return false; final CRC32 crc = new CRC32(); crc.update(bytes, 0, bytes.length - 4); final long buffer_crc = UnsignedInts.toLong(ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(bytes.length - 4)); return buffer_crc == crc.getValue(); }
Example #6
Source File: JoH.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static boolean checkChecksum(byte[] bytes) { if ((bytes == null) || (bytes.length < 4)) return false; final CRC32 crc = new CRC32(); crc.update(bytes, 0, bytes.length - 4); final long buffer_crc = UnsignedInts.toLong(ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(bytes.length - 4)); return buffer_crc == crc.getValue(); }
Example #7
Source File: JoH.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static boolean checkChecksum(byte[] bytes) { if ((bytes == null) || (bytes.length < 4)) return false; final CRC32 crc = new CRC32(); crc.update(bytes, 0, bytes.length - 4); final long buffer_crc = UnsignedInts.toLong(ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(bytes.length - 4)); return buffer_crc == crc.getValue(); }
Example #8
Source File: Zip.java From turbine with Apache License 2.0 | 4 votes |
public ZipIterable(Path path) throws IOException { this.path = path; this.chan = FileChannel.open(path, StandardOpenOption.READ); // Locate the EOCD long size = chan.size(); if (size < ENDHDR) { throw new ZipException("invalid zip archive"); } long eocdOffset = size - ENDHDR; MappedByteBuffer eocd = chan.map(MapMode.READ_ONLY, eocdOffset, ENDHDR); eocd.order(ByteOrder.LITTLE_ENDIAN); int index = 0; int commentSize = 0; if (!isSignature(eocd, 0, 5, 6)) { // The archive may contain a zip file comment; keep looking for the EOCD. long start = Math.max(0, size - ENDHDR - 0xFFFF); eocd = chan.map(MapMode.READ_ONLY, start, (size - start)); eocd.order(ByteOrder.LITTLE_ENDIAN); index = (int) ((size - start) - ENDHDR); while (index > 0) { index--; eocd.position(index); if (isSignature(eocd, index, 5, 6)) { commentSize = (int) ((size - start) - ENDHDR) - index; eocdOffset = start + index; break; } } } checkSignature(path, eocd, index, 5, 6, "ENDSIG"); int totalEntries = eocd.getChar(index + ENDTOT); long cdsize = UnsignedInts.toLong(eocd.getInt(index + ENDSIZ)); int actualCommentSize = eocd.getChar(index + ENDCOM); if (commentSize != actualCommentSize) { throw new ZipException( String.format( "zip file comment length was %d, expected %d", commentSize, actualCommentSize)); } // If the number of entries is 0xffff, check if the archive has a zip64 EOCD locator. if (totalEntries == ZIP64_MAGICCOUNT) { // Assume the zip64 EOCD has the usual size; we don't support zip64 extensible data sectors. long zip64eocdOffset = size - ENDHDR - ZIP64_LOCHDR - ZIP64_ENDHDR; MappedByteBuffer zip64eocd = chan.map(MapMode.READ_ONLY, zip64eocdOffset, ZIP64_ENDHDR); zip64eocd.order(ByteOrder.LITTLE_ENDIAN); // Note that zip reading is necessarily best-effort, since an archive could contain 0xFFFF // entries and the last entry's data could contain a ZIP64_ENDSIG. Some implementations // read the full EOCD records and compare them. if (zip64eocd.getInt(0) == ZIP64_ENDSIG) { cdsize = zip64eocd.getLong(ZIP64_ENDSIZ); eocdOffset = zip64eocdOffset; } } this.cd = chan.map(MapMode.READ_ONLY, eocdOffset - cdsize, cdsize); cd.order(ByteOrder.LITTLE_ENDIAN); }
Example #9
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public long padToLong() { return UnsignedInts.toLong(hash); }
Example #10
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public long padToLong() { return UnsignedInts.toLong(hash); }
Example #11
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public long padToLong() { return UnsignedInts.toLong(hash); }
Example #12
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public long padToLong() { return UnsignedInts.toLong(hash); }
Example #13
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public long padToLong() { return UnsignedInts.toLong(hash); }
Example #14
Source File: Stat.java From riiablo with Apache License 2.0 | 4 votes |
public long toLong() { return UnsignedInts.toLong(val); }
Example #15
Source File: HprofParser.java From haha with Apache License 2.0 | 4 votes |
private long readUnsignedInt() throws IOException { return UnsignedInts.toLong(mInput.readInt()); }
Example #16
Source File: AbstractBsonTimestamp.java From mongowp with Apache License 2.0 | 4 votes |
@Override public String toString() { return "{ \"$timestamp\": { \"t\": " + UnsignedInts.toString(getSecondsSinceEpoch()) + ", \"i\": " + UnsignedInts.toString(getOrdinal()) + "} }"; }
Example #17
Source File: StrictBGPPeerRegistry.java From bgpcep with Eclipse Public License 1.0 | 4 votes |
private static long toLong(final Ipv4Address from) { final int i = InetAddresses.coerceToInteger(InetAddresses.forString(from.getValue())); return UnsignedInts.toLong(i); }
Example #18
Source File: IntOption.java From dhcp4j with Apache License 2.0 | 4 votes |
@Nonnegative public long getIntValue() { return UnsignedInts.toLong(Ints.fromByteArray(getData())); }
Example #19
Source File: IntOption.java From dhcp4j with Apache License 2.0 | 4 votes |
@Nonnegative public long getIntValue() { return UnsignedInts.toLong(Ints.fromByteArray(getData())); }