Java 类javax.annotation.CheckForSigned 实例源码

项目:ph-commons    文件:IntDoubleMap.java   
/**
 * Find key position in the map.
 *
 * @param key
 *        Key to look for
 * @return Key position or -1 if not found
 */
@CheckForSigned
private int _getReadIndex (final int key)
{
  int idx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[idx] == key)
  {
    // we check FREE prior to this call
    return idx;
  }
  if (m_aKeys[idx] == FREE_KEY)
  {
    // end of chain already
    return -1;
  }
  final int startIdx = idx;
  while ((idx = _getNextIndex (idx)) != startIdx)
  {
    if (m_aKeys[idx] == FREE_KEY)
      return -1;
    if (m_aKeys[idx] == key)
      return idx;
  }
  return -1;
}
项目:ph-commons    文件:IntDoubleMap.java   
/**
 * Find an index of a cell which should be updated by 'put' operation. It can
 * be: 1) a cell with a given key 2) first free cell in the chain
 *
 * @param key
 *        Key to look for
 * @return Index of a cell to be updated by a 'put' operation
 */
@CheckForSigned
private int _getPutIndex (final int key)
{
  final int readIdx = _getReadIndex (key);
  if (readIdx >= 0)
    return readIdx;
  // key not found, find insertion point
  final int startIdx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[startIdx] == FREE_KEY)
    return startIdx;
  int idx = startIdx;
  while (m_aKeys[idx] != FREE_KEY)
  {
    idx = _getNextIndex (idx);
    if (idx == startIdx)
      return -1;
  }
  return idx;
}
项目:ph-commons    文件:IntObjectMap.java   
/**
 * Find key position in the map.
 *
 * @param key
 *        Key to look for
 * @return Key position or -1 if not found
 */
@CheckForSigned
private int _getReadIndex (final int key)
{
  int idx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[idx] == key)
  {
    // we check FREE prior to this call
    return idx;
  }
  if (m_aKeys[idx] == FREE_KEY)
  {
    // end of chain already
    return -1;
  }
  final int startIdx = idx;
  while ((idx = _getNextIndex (idx)) != startIdx)
  {
    if (m_aKeys[idx] == FREE_KEY)
      return -1;
    if (m_aKeys[idx] == key)
      return idx;
  }
  return -1;
}
项目:ph-commons    文件:IntObjectMap.java   
/**
 * Find an index of a cell which should be updated by 'put' operation. It can
 * be: 1) a cell with a given key 2) first free cell in the chain
 *
 * @param key
 *        Key to look for
 * @return Index of a cell to be updated by a 'put' operation
 */
@CheckForSigned
private int _getPutIndex (final int key)
{
  final int readIdx = _getReadIndex (key);
  if (readIdx >= 0)
    return readIdx;
  // key not found, find insertion point
  final int startIdx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[startIdx] == FREE_KEY)
    return startIdx;
  int idx = startIdx;
  while (m_aKeys[idx] != FREE_KEY)
  {
    idx = _getNextIndex (idx);
    if (idx == startIdx)
      return -1;
  }
  return idx;
}
项目:ph-commons    文件:IntFloatMap.java   
/**
 * Find key position in the map.
 *
 * @param key
 *        Key to look for
 * @return Key position or -1 if not found
 */
@CheckForSigned
private int _getReadIndex (final int key)
{
  int idx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[idx] == key)
  {
    // we check FREE prior to this call
    return idx;
  }
  if (m_aKeys[idx] == FREE_KEY)
  {
    // end of chain already
    return -1;
  }
  final int startIdx = idx;
  while ((idx = _getNextIndex (idx)) != startIdx)
  {
    if (m_aKeys[idx] == FREE_KEY)
      return -1;
    if (m_aKeys[idx] == key)
      return idx;
  }
  return -1;
}
项目:ph-commons    文件:IntFloatMap.java   
/**
 * Find an index of a cell which should be updated by 'put' operation. It can
 * be: 1) a cell with a given key 2) first free cell in the chain
 *
 * @param key
 *        Key to look for
 * @return Index of a cell to be updated by a 'put' operation
 */
@CheckForSigned
private int _getPutIndex (final int key)
{
  final int readIdx = _getReadIndex (key);
  if (readIdx >= 0)
    return readIdx;
  // key not found, find insertion point
  final int startIdx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[startIdx] == FREE_KEY)
    return startIdx;
  int idx = startIdx;
  while (m_aKeys[idx] != FREE_KEY)
  {
    idx = _getNextIndex (idx);
    if (idx == startIdx)
      return -1;
  }
  return idx;
}
项目:ph-commons    文件:IntIntMap.java   
/**
 * Find key position in the map.
 *
 * @param key
 *        Key to look for
 * @return Key position or -1 if not found
 */
@CheckForSigned
private int _getReadIndex (final int key)
{
  int idx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[idx] == key)
  {
    // we check FREE prior to this call
    return idx;
  }
  if (m_aKeys[idx] == FREE_KEY)
  {
    // end of chain already
    return -1;
  }
  final int startIdx = idx;
  while ((idx = _getNextIndex (idx)) != startIdx)
  {
    if (m_aKeys[idx] == FREE_KEY)
      return -1;
    if (m_aKeys[idx] == key)
      return idx;
  }
  return -1;
}
项目:ph-commons    文件:IntIntMap.java   
/**
 * Find an index of a cell which should be updated by 'put' operation. It can
 * be: 1) a cell with a given key 2) first free cell in the chain
 *
 * @param key
 *        Key to look for
 * @return Index of a cell to be updated by a 'put' operation
 */
@CheckForSigned
private int _getPutIndex (final int key)
{
  final int readIdx = _getReadIndex (key);
  if (readIdx >= 0)
    return readIdx;
  // key not found, find insertion point
  final int startIdx = MapHelper.phiMix (key) & m_nMask;
  if (m_aKeys[startIdx] == FREE_KEY)
    return startIdx;
  int idx = startIdx;
  while (m_aKeys[idx] != FREE_KEY)
  {
    idx = _getNextIndex (idx);
    if (idx == startIdx)
      return -1;
  }
  return idx;
}
项目:ph-commons    文件:CodepointHelper.java   
@CheckForSigned
public static int getIndex (@Nonnull final int [] aCodepointSet, final int nValue)
{
  int nStart = 0;
  int nEnd = aCodepointSet.length;
  while (nEnd - nStart > 8)
  {
    final int i = (nEnd + nStart) >>> 1;
    nStart = aCodepointSet[i] <= nValue ? i : nStart;
    nEnd = aCodepointSet[i] > nValue ? i : nEnd;
  }
  while (nStart < nEnd)
  {
    if (nValue < aCodepointSet[nStart])
      break;
    nStart++;
  }
  return nStart == nEnd ? -1 : nStart - 1;
}
项目:ph-commons    文件:NonBlockingStringReader.java   
/**
 * Reads characters into a portion of an array.
 *
 * @param aBuf
 *        Destination buffer
 * @param nOfs
 *        Offset at which to start writing characters
 * @param nLen
 *        Maximum number of characters to read
 * @return The number of characters read, or -1 if the end of the stream has
 *         been reached
 * @exception IOException
 *            If an I/O error occurs
 */
@Override
@CheckForSigned
public int read (@Nonnull final char [] aBuf,
                 @Nonnegative final int nOfs,
                 @Nonnegative final int nLen) throws IOException
{
  _ensureOpen ();
  ValueEnforcer.isArrayOfsLen (aBuf, nOfs, nLen);

  if (nLen == 0)
    return 0;
  if (m_nNext >= m_nLength)
    return -1;
  final int nChars = Math.min (m_nLength - m_nNext, nLen);
  System.arraycopy (m_aChars, m_nNext, aBuf, nOfs, nChars);
  m_nNext += nChars;
  return nChars;
}
项目:ph-stx    文件:MutableAttributesImpl.java   
@CheckForSigned
public int getIndex (final String uri, final String localName)
{
  for (int n = m_nLength; n-- > 0;)
    if (localName.equals (m_aLocalNames[n]) && uri.equals (m_aUris[n]))
      return n;
  return -1;
}
项目:ph-stx    文件:MutableAttributesImpl.java   
@CheckForSigned
public int getIndex (final String qName)
{
  for (int n = m_nLength; n-- > 0;)
  {
    if (qName.equals (m_aQNames[n]))
      return n;
  }
  return -1;
}
项目:TtorrentAndroid    文件:UDPTrackerMessage.java   
@Override
protected void _fromWire(@Nonnull ByteBuf in, @CheckForSigned int length)
        throws MessageValidationException {
    super._fromWire(in, length);
    setConnectionId(in.readLong());
    int actionId = in.readInt();
    if (actionId != getActionId())
        throw new MessageValidationException("Packet contained bad ActionId: " + this);
    setTransactionId(in.readInt());
}
项目:TtorrentAndroid    文件:UDPTrackerMessage.java   
@Override
protected void _fromWire(@Nonnull ByteBuf in, @CheckForSigned int length)
        throws MessageValidationException {
    super._fromWire(in, length);
    int actionId = in.readInt();
    if (actionId != getActionId())
        throw new MessageValidationException("Packet contained bad ActionId: " + this);
    setTransactionId(in.readInt());
}
项目:TtorrentAndroid    文件:Peer.java   
@CheckForSigned
public int getPort() {
    SocketAddress sa = getAddress();
    if (!(sa instanceof InetSocketAddress))
        return -1;
    InetSocketAddress isa = (InetSocketAddress) sa;
    return isa.getPort();
}
项目:lisp    文件:LispParser.java   
@CheckForSigned
private int readCharStart() throws IOException {
    for (;;) {
        int c = reader.read();
        if (Character.isWhitespace(c))
            continue;
        return c;
    }
}
项目:lisp    文件:LispParser.java   
@CheckForSigned
private int readCharNext() throws IOException {
    for (;;) {
        int c = reader.read();
        if (Character.isWhitespace(c))
            return -1;
        if (c == '(' || c == ')' || c == '.') {
            reader.unread(c);
            return -1;
        }
        return c;
    }
}
项目:ph-commons    文件:AbstractStatisticsHandlerNumeric.java   
@CheckForSigned
public final long getAverage ()
{
  return m_aRWLock.readLocked ( () -> {
    if (m_nInvocationCount == 0)
      return CGlobal.ILLEGAL_ULONG;
    return m_aSum.divide (BigInteger.valueOf (m_nInvocationCount)).longValue ();
  });
}
项目:ph-commons    文件:AbstractStatisticsHandlerKeyedNumeric.java   
@CheckForSigned
public final int getInvocationCount (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aValue = m_aMap.get (sKey);
    return aValue == null ? CGlobal.ILLEGAL_UINT : aValue.getInvocationCount ();
  });
}
项目:ph-commons    文件:AbstractStatisticsHandlerKeyedNumeric.java   
@CheckForSigned
public final long getMin (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aValue = m_aMap.get (sKey);
    return aValue == null ? CGlobal.ILLEGAL_ULONG : aValue.getMin ();
  });
}
项目:ph-commons    文件:AbstractStatisticsHandlerKeyedNumeric.java   
@CheckForSigned
public final long getAverage (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aValue = m_aMap.get (sKey);
    return aValue == null ? CGlobal.ILLEGAL_ULONG : aValue.getAverage ();
  });
}
项目:ph-commons    文件:AbstractStatisticsHandlerKeyedNumeric.java   
@CheckForSigned
public long getMax (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aValue = m_aMap.get (sKey);
    return aValue == null ? CGlobal.ILLEGAL_ULONG : aValue.getMax ();
  });
}
项目:ph-commons    文件:StatisticsHandlerKeyedCounter.java   
@CheckForSigned
public long getCount (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aCount = m_aMap.get (sKey);
    return aCount == null ? CGlobal.ILLEGAL_ULONG : aCount.getCount ();
  });
}
项目:ph-commons    文件:StatisticsHandlerKeyedCounter.java   
@CheckForSigned
public int getInvocationCount (@Nullable final String sKey)
{
  return m_aRWLock.readLocked ( () -> {
    final Value aCount = m_aMap.get (sKey);
    return aCount == null ? CGlobal.ILLEGAL_UINT : aCount.getInvocationCount ();
  });
}
项目:ph-commons    文件:NonBlockingStringReader.java   
/**
 * Reads a single character.
 *
 * @return The character read, or -1 if the end of the stream has been reached
 * @exception IOException
 *            If an I/O error occurs
 */
@Override
@CheckForSigned
public int read () throws IOException
{
  _ensureOpen ();
  if (m_nNext >= m_nLength)
    return -1;
  return m_aChars[m_nNext++];
}
项目:ph-commons    文件:URLResource.java   
@Nullable
public InputStream getInputStream (@CheckForSigned final int nConnectTimeoutMS,
                                   @CheckForSigned final int nReadTimeoutMS)
{
  return getInputStream (nConnectTimeoutMS,
                         nReadTimeoutMS,
                         (Consumer <? super URLConnection>) null,
                         (IMutableWrapper <IOException>) null);
}
项目:ph-commons    文件:URLResource.java   
@Nullable
public InputStream getInputStream (@CheckForSigned final int nConnectTimeoutMS,
                                   @CheckForSigned final int nReadTimeoutMS,
                                   @Nullable final IMutableWrapper <IOException> aExceptionHolder)
{
  return getInputStream (nConnectTimeoutMS,
                         nReadTimeoutMS,
                         (Consumer <? super URLConnection>) null,
                         aExceptionHolder);
}
项目:ph-commons    文件:URLResource.java   
@Nullable
public InputStream getInputStream (@CheckForSigned final int nConnectTimeoutMS,
                                   @CheckForSigned final int nReadTimeoutMS,
                                   @Nullable final Consumer <? super URLConnection> aConnectionModifier,
                                   @Nullable final IMutableWrapper <IOException> aExceptionHolder)
{
  return URLHelper.getInputStream (m_aURL, nConnectTimeoutMS, nReadTimeoutMS, aConnectionModifier, aExceptionHolder);
}
项目:ph-commons    文件:FileChannelHelper.java   
@CheckForSigned
public static long getFileSize (@Nullable final FileChannel aChannel)
{
  if (aChannel != null)
    try
    {
      return aChannel.size ();
    }
    catch (final IOException ex)
    {
      // fall-through
    }
  return -1;
}
项目:ph-masterdata    文件:VATINSyntaxChecker.java   
@CheckForSigned
private static int _fr_check (final char c)
{
  if (_isNum (c))
    return _toInt (c);
  final int idx = "ABCDEFGHJKLMNPQRSTUVWXYZ".indexOf (c);
  if (idx < 0)
    return -1;
  return 10 + idx;
}
项目:dhcp4j    文件:AbstractDhcpReplyFactory.java   
@Nonnegative
protected static long getLeaseTime(@Nonnull LeaseTimeRange leaseTimeSecs, @CheckForSigned long requestedLeaseTimeSecs) {
    if (requestedLeaseTimeSecs < 0)
        return leaseTimeSecs.defaultLeaseTime;
    if (requestedLeaseTimeSecs <= leaseTimeSecs.minLeaseTime)
        return leaseTimeSecs.minLeaseTime;
    if (requestedLeaseTimeSecs >= leaseTimeSecs.maxLeaseTime)
        return leaseTimeSecs.maxLeaseTime;
    return requestedLeaseTimeSecs;
}
项目:dhcp4j    文件:AbstractDhcpReplyFactory.java   
/** Utility: Constructs a new ACK reply. */
@Nonnull
protected static DhcpMessage newReplyAck(
        @Nonnull DhcpMessage request,
        @Nonnull MessageType type,
        @CheckForNull InetAddress assignedClientAddress,
        @CheckForSigned long leaseTimeSecs) {
    DhcpMessage reply = newReply(request, type);
    if (leaseTimeSecs > 0)
        reply.getOptions().setIntOption(IpAddressLeaseTime.class, leaseTimeSecs);
    if (assignedClientAddress != null)
        reply.setAssignedClientAddress(assignedClientAddress);
    return reply;
}
项目:ph-pdf-layout    文件:AbstractPLHBox.java   
private void _addAndReturnColumn (@CheckForSigned final int nIndex, @Nonnull final PLHBoxColumn aColumn)
{
  internalCheckNotPrepared ();
  if (nIndex < 0 || nIndex >= m_aColumns.size ())
    m_aColumns.add (aColumn);
  else
    m_aColumns.add (nIndex, aColumn);
}
项目:ph-pdf-layout    文件:AbstractPLHBox.java   
@Nonnull
public PLHBoxColumn addAndReturnColumn (@CheckForSigned final int nIndex,
                                        @Nonnull final IPLRenderableObject <?> aElement,
                                        @Nonnull final WidthSpec aWidth)
{
  final PLHBoxColumn aColumn = new PLHBoxColumn (aElement, aWidth);
  _addAndReturnColumn (nIndex, aColumn);
  return aColumn;
}
项目:ph-pdf-layout    文件:AbstractPLHBox.java   
@Nonnull
public IMPLTYPE addColumn (@CheckForSigned final int nIndex,
                           @Nonnull final IPLRenderableObject <?> aElement,
                           @Nonnull final WidthSpec aWidth)
{
  addAndReturnColumn (nIndex, aElement, aWidth);
  return thisAsT ();
}
项目:ph-pdf-layout    文件:AbstractPLVBox.java   
@Nonnull
private PLVBoxRow _addAndReturnRow (@CheckForSigned final int nIndex,
                                    @Nonnull final IPLRenderableObject <?> aElement,
                                    @Nonnull final HeightSpec aHeight)
{
  final PLVBoxRow aItem = new PLVBoxRow (aElement, aHeight);
  if (nIndex < 0 || nIndex >= m_aRows.size ())
    m_aRows.add (aItem);
  else
    m_aRows.add (nIndex, aItem);
  return aItem;
}
项目:dhcp4j    文件:AbstractDhcpReplyFactory.java   
@Nonnegative
protected static long getLeaseTime(@Nonnull LeaseTimeRange leaseTimeSecs, @CheckForSigned long requestedLeaseTimeSecs) {
    if (requestedLeaseTimeSecs < 0)
        return leaseTimeSecs.defaultLeaseTime;
    if (requestedLeaseTimeSecs <= leaseTimeSecs.minLeaseTime)
        return leaseTimeSecs.minLeaseTime;
    if (requestedLeaseTimeSecs >= leaseTimeSecs.maxLeaseTime)
        return leaseTimeSecs.maxLeaseTime;
    return requestedLeaseTimeSecs;
}
项目:dhcp4j    文件:AbstractDhcpReplyFactory.java   
/** Utility: Constructs a new ACK reply. */
@Nonnull
protected static DhcpMessage newReplyAck(
        @Nonnull DhcpMessage request,
        @Nonnull MessageType type,
        @CheckForNull InetAddress assignedClientAddress,
        @CheckForSigned long leaseTimeSecs) {
    DhcpMessage reply = newReply(request, type);
    if (leaseTimeSecs > 0)
        reply.getOptions().setIntOption(IpAddressLeaseTime.class, leaseTimeSecs);
    if (assignedClientAddress != null)
        reply.setAssignedClientAddress(assignedClientAddress);
    return reply;
}
项目:ph-as4    文件:AS4MessageState.java   
@CheckForSigned
public int getEffectivePModeLegNumber ()
{
  return getAsInt (KEY_EFFECTIVE_PMODE_LEG_NUMBER, -1);
}
项目:ph-stx    文件:STXSourceArea.java   
/**
 * @return The line number where the token begins (incl.). May be -1 if not
 *         such token is available.
 */
@CheckForSigned
public int getTokenBeginLineNumber ()
{
  return m_nBeginLineNumber;
}