當前位置: 首頁>>代碼示例>>Java>>正文


Java UnsignedInteger類代碼示例

本文整理匯總了Java中com.google.common.primitives.UnsignedInteger的典型用法代碼示例。如果您正苦於以下問題:Java UnsignedInteger類的具體用法?Java UnsignedInteger怎麽用?Java UnsignedInteger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UnsignedInteger類屬於com.google.common.primitives包,在下文中一共展示了UnsignedInteger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readFromBuffer

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Override
public void readFromBuffer(ByteBuffer buffer) {
    byte[] buf = new byte[8];
    buffer.get(buf);
    buf = Bytes.toArray(Lists.reverse(Bytes.asList(buf)));
    creationDate = decodeDateTime(buf);
    buffer.get(buf);
    buf = Bytes.toArray(Lists.reverse(Bytes.asList(buf)));
    modifyDate = decodeDateTime(buf);
    reserved = UnsignedInteger.fromIntBits(buffer.getInt()).longValue();
    name = "";
    boolean skip = false;
    while (buffer.hasRemaining()) {
        char ch = (char) buffer.get();
        if (!skip) {
            name += ch;
        }
        skip = !skip;
    }
    name = name.replaceAll("[\\x00-\\x1F]", "");
}
 
開發者ID:psyriccio,項目名稱:v8fs,代碼行數:22,代碼來源:Attributes.java

示例2: testSplittingWithDescendingWrites

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Test
public void testSplittingWithDescendingWrites() {
    // Reduce the splitting thresholds so that splitting occurs.
    InMemoryQueueDAO dao = new InMemoryQueueDAO();
    SortedQueue q = new PersistentSortedQueue("queue", false, 10000, 1000, dao, new MetricRegistry());
    TreeSet<ByteBuffer> expected = Sets.newTreeSet(ORDERING);

    int n = 100000;
    addBuffers(q, expected, n, 100, sequentialBufferIter(UnsignedInteger.MAX_VALUE.intValue(), -1));

    // Verify splitting successfully kept the row sizes manageable.
    assertSmallRows(dao, 2000);

    // Verify splitting cost was reasonable.  Max #writes should be 3*n, but for sequential writes it's ~2*n in practice.
    assertTrue(dao.getNumRecordWrites() <= 3 * n, "Splitting caused too many writes: " + dao.getNumRecordWrites());
    assertTrue(dao.getNumRecordDeletes() <= 2 * n, "Splitting caused too many deletes: " + dao.getNumRecordDeletes());

    // Verify that drainTo returns the expected items in the same order.
    assertDrain(q, expected, Long.MAX_VALUE);
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:21,代碼來源:PersistentSortedQueueTest.java

示例3: parseFloatingPoint

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
private Number parseFloatingPoint(String lTermRepresentation) {

    // the term is of the format "<VALUE>_<EXPWIDTH>_<MANTWIDTH>"
    Matcher matcher = FLOATING_POINT_PATTERN.matcher(lTermRepresentation);
    if (!matcher.matches()) {
      throw new NumberFormatException("Unknown floating-point format: " + lTermRepresentation);
    }

    int expWidth = Integer.parseInt(matcher.group(2));
    int mantWidth = Integer.parseInt(matcher.group(3));

    if (expWidth == 11 && mantWidth == 52) {
      return Double.longBitsToDouble(UnsignedLong.valueOf(matcher.group(1)).longValue());
    } else if (expWidth == 8 && mantWidth == 23) {
      return Float.intBitsToFloat(UnsignedInteger.valueOf(matcher.group(1)).intValue());
    }

    // TODO to be fully correct, we would need to interpret this string
    return new BigInteger(matcher.group(1));
  }
 
開發者ID:sosy-lab,項目名稱:java-smt,代碼行數:21,代碼來源:Mathsat5FormulaCreator.java

示例4: build

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
public CrtAuthServer build() {
  checkNotNull(serverName);
  checkNotNull(keyProviders);
  checkNotNull(secret);

  if (keyProviders.isEmpty()) {
    throw new IllegalArgumentException("At least one key provider must be specified.");
  }

  final UnsignedInteger lifetime = tokenLifetimeSeconds.or(DEFAULT_TOKEN_LIFETIME_SECONDS);
  if (lifetime.intValue() > MAX_VALIDITY) {
    throw new IllegalArgumentException(String.format(
        "Overly long token lifetime. Max lifetime is %d.", MAX_VALIDITY));
  }

  return new CrtAuthServer(lifetime,
                           serverName,
                           keyProviders,
                           timeSupplier.or(DEFAULT_TIME_SUPPLIER),
                           random.or(new Random()),
                           secret
  );
}
 
開發者ID:spotify,項目名稱:crtauth-java,代碼行數:24,代碼來源:CrtAuthServer.java

示例5: foo

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
void foo(
String s,
Runnable r,
Number n,
Iterable<?> it,
boolean b,
Equivalence<String> eq,
Exception e,
InputStream in,
Comparable<?> c,
Ordering<Integer> ord,
Charset charset,
TimeUnit unit,
Class<?> cls,
Joiner joiner,
Pattern pattern,
UnsignedInteger ui,
UnsignedLong ul,
StringBuilder sb,
Predicate<?> pred,
Function<?, ?> func,
Object obj);
 
開發者ID:google,項目名稱:guava,代碼行數:23,代碼來源:ForwardingWrapperTesterTest.java

示例6: visit

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Override
public Void visit(BsonBinary value, ByteBuf arg) {
  NonIoByteSource byteSource = value.getByteSource();

  UnsignedInteger unsignedSize;
  unsignedSize = UnsignedInteger.valueOf(byteSource.size());

  arg.writeInt(unsignedSize.intValue()).writeByte(value.getNumericSubType());

  try (OutputStream os = new ByteBufOutputStream(arg)) {
    value.getByteSource().copyTo(os);
  } catch (IOException ex) {
    throw new AssertionError("Unexpected IOException", ex);
  }
  return null;
}
 
開發者ID:torodb,項目名稱:mongowp,代碼行數:17,代碼來源:NettyBsonDocumentWriter.java

示例7: addRoute

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Override
public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
        final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
    LOG.trace("Find {} in {}", attributesIdentifier, data);
    final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes
            .findNode(data, attributesIdentifier).orElse(null);
    int offset = this.offsets.offsetOf(routerId);
    if (offset < 0) {
        final OffsetMap newOffsets = this.offsets.with(routerId);
        offset = newOffsets.offsetOf(routerId);

        this.values = newOffsets.expand(this.offsets, this.values, offset);
        this.offsets = newOffsets;
    }

    this.offsets.setValue(this.values, offset, advertisedAttrs);
    LOG.trace("Added route from {} attributes {}", routerId, advertisedAttrs);
    return offset;
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:20,代碼來源:BaseAbstractRouteEntry.java

示例8: processPath

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
void processPath(final UnsignedInteger routerId, final ContainerNode attrs) {
    requireNonNull(routerId, "Router ID may not be null");

    // Consider only non-null attributes
    if (attrs != null) {
        final UnsignedInteger originatorId = replaceOriginator(routerId, attrs);
        /*
         * Store the new details if we have nothing stored or when the selection algorithm indicates new details
         * are better.
         */
        final BestPathState state = new BestPathStateImpl(attrs);
        if (this.bestOriginatorId == null || !isExistingPathBetter(state)) {
            LOG.trace("Selecting path from router {}", routerId);
            this.bestOriginatorId = originatorId;
            this.bestRouterId = routerId;
            this.bestState = state;
        }
    }
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:20,代碼來源:BasePathSelector.java

示例9: processPath

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
void processPath(final ContainerNode attrs, final RouteKey key, final int offsetPosition, final Long pathId) {
    requireNonNull(key.getRouteId(), "Router ID may not be null");

    // Consider only non-null attributes
    if (attrs != null) {
        final UnsignedInteger originatorId = replaceOriginator(key.getRouteId(), attrs);

        /*
         * Store the new details if we have nothing stored or when the selection algorithm indicates new details
         * are better.
         */
        final BestPathState state = new BestPathStateImpl(attrs);
        if (this.bestOriginatorId == null || !isExistingPathBetter(state)) {
            LOG.trace("Selecting path from router {}", key);
            this.bestOriginatorId = originatorId;
            this.bestState = state;
            this.bestRouteKey = key;
            this.bestOffsetPosition = offsetPosition;
            this.bestPathId = pathId;
        }
    }
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:23,代碼來源:AddPathSelector.java

示例10: testFreshInstance

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@AndroidIncompatible // problem with equality of Type objects?
public void testFreshInstance() {
  assertFreshInstances(
      String.class, CharSequence.class,
      Appendable.class, StringBuffer.class, StringBuilder.class,
      Pattern.class, MatchResult.class,
      Number.class, int.class, Integer.class,
      long.class, Long.class,
      short.class, Short.class,
      byte.class, Byte.class,
      boolean.class, Boolean.class,
      char.class, Character.class,
      int[].class, Object[].class,
      UnsignedInteger.class, UnsignedLong.class,
      BigInteger.class, BigDecimal.class,
      Throwable.class, Error.class, Exception.class, RuntimeException.class,
      Charset.class, Locale.class, Currency.class,
      List.class, Map.Entry.class,
      Object.class,
      Equivalence.class, Predicate.class, Function.class,
      Comparable.class, Comparator.class, Ordering.class,
      Class.class, Type.class, TypeToken.class,
      TimeUnit.class, Ticker.class,
      Joiner.class, Splitter.class, CharMatcher.class,
      InputStream.class, ByteArrayInputStream.class,
      Reader.class, Readable.class, StringReader.class,
      OutputStream.class, ByteArrayOutputStream.class,
      Writer.class, StringWriter.class, File.class,
      Buffer.class, ByteBuffer.class, CharBuffer.class,
      ShortBuffer.class, IntBuffer.class, LongBuffer.class,
      FloatBuffer.class, DoubleBuffer.class,
      String[].class, Object[].class, int[].class);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:34,代碼來源:FreshValueGeneratorTest.java

示例11: testGet_primitives

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
public void testGet_primitives() {
  assertNull(ArbitraryInstances.get(void.class));
  assertNull(ArbitraryInstances.get(Void.class));
  assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
  assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
  assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
  assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
  assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));
  assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(Byte.class));
  assertEquals(Short.valueOf((short) 0), ArbitraryInstances.get(short.class));
  assertEquals(Short.valueOf((short) 0), ArbitraryInstances.get(Short.class));
  assertEquals(Integer.valueOf(0), ArbitraryInstances.get(int.class));
  assertEquals(Integer.valueOf(0), ArbitraryInstances.get(Integer.class));
  assertEquals(Long.valueOf(0), ArbitraryInstances.get(long.class));
  assertEquals(Long.valueOf(0), ArbitraryInstances.get(Long.class));
  assertEquals(Float.valueOf(0), ArbitraryInstances.get(float.class));
  assertEquals(Float.valueOf(0), ArbitraryInstances.get(Float.class));
  assertEquals(Double.valueOf(0), ArbitraryInstances.get(double.class));
  assertEquals(Double.valueOf(0), ArbitraryInstances.get(Double.class));
  assertEquals(UnsignedInteger.ZERO, ArbitraryInstances.get(UnsignedInteger.class));
  assertEquals(UnsignedLong.ZERO, ArbitraryInstances.get(UnsignedLong.class));
  assertEquals(0, ArbitraryInstances.get(BigDecimal.class).intValue());
  assertEquals(0, ArbitraryInstances.get(BigInteger.class).intValue());
  assertEquals("", ArbitraryInstances.get(String.class));
  assertEquals("", ArbitraryInstances.get(CharSequence.class));
  assertEquals(TimeUnit.SECONDS, ArbitraryInstances.get(TimeUnit.class));
  assertNotNull(ArbitraryInstances.get(Object.class));
  assertEquals(0, ArbitraryInstances.get(Number.class));
  assertEquals(Charsets.UTF_8, ArbitraryInstances.get(Charset.class));
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:31,代碼來源:ArbitraryInstancesTest.java

示例12: foo

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Override public void foo(
    String s, Runnable r, Number n, Iterable<?> it, boolean b, Equivalence<String> eq,
    Exception e, InputStream in, Comparable<?> c, Ordering<Integer> ord,
    Charset charset, TimeUnit unit, Class<?> cls, Joiner joiner,
    Pattern pattern, UnsignedInteger ui, UnsignedLong ul, StringBuilder sb,
    Predicate<?> pred, Function<?, ?> func, Object obj) {
  delegate.foo(s,
      r, n, it, b, eq, e, in, c, ord, charset, unit, cls, joiner, pattern,
      ui, ul, sb, pred, func, obj);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:11,代碼來源:ForwardingWrapperTesterTest.java

示例13: QueueInfo

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
public QueueInfo(UnsignedInteger queueId, Type type, long minRate,
                 long maxRate, long burst, long priority) {
    this.queueId = queueId;
    this.type = type;
    this.minRate = minRate;
    this.maxRate = maxRate;
    this.burst = burst;
    this.priority = priority;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:QueueInfo.java

示例14: sizeOf

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
/**
 * Gets the minimum encoded size of the given value.
 */
public static int sizeOf(long value) {
    if (isLessThanUnsigned(value, 253))
        return 1;
    else if (isLessThanUnsigned(value, 65536))
        return 3;  // 1 marker + 2 data bytes
    else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue()))
        return 5;  // 1 marker + 4 data bytes
    else
        return 9;  // 1 marker + 8 data bytes
}
 
開發者ID:appteam-nith,項目名稱:NithPointsj,代碼行數:14,代碼來源:VarInt.java

示例15: writeToBuffer

import com.google.common.primitives.UnsignedInteger; //導入依賴的package包/類
@Override
public void writeToBuffer(ByteBuffer buffer) {
    buffer.put(codeDateTime(creationDate)).put(codeDateTime(modifyDate)).putInt(UnsignedInteger.valueOf(reserved).intValue());
    try {
        buffer.put(name.getBytes("UTF-16"));
    } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:psyriccio,項目名稱:v8fs,代碼行數:10,代碼來源:Attributes.java


注:本文中的com.google.common.primitives.UnsignedInteger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。