当前位置: 首页>>代码示例>>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;未经允许,请勿转载。