Returns a signed integer value using the bits from character position
start to position stop in the decoded message.

@param from
@param to
@return
493330
public synchronized int getSignedValue(int from, int to) {
        try {
            // is synchronized so that values of bitSet and calculated can be
            // lazily
            // calculated and safely published (thread safe).
            SixBit.convertSixBitToBits(message, padBits, bitSet, calculated, from, to);
            return (int) SixBit.getSignedValue(from, to, bitSet);
        } catch (SixBitException e) {
            throw new AisParseException(e);
        }
    }
357814
@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;
  }
1041552
public static int readUnsignedInt(byte[] bytes, int offset) {
      byte b = bytes[offset++];
      int i = b & 0x7F;
      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
         b = bytes[offset++];
         i |= (b & 0x7FL) << shift;
      }
      return i;
   }
517319
public static Identifier fromInt(int intValue) {
        if (intValue < 0 || intValue > MAX_INTEGER) {
            throw new IllegalArgumentException("Identifiers can only be constructed from integers between 0 and " + MAX_INTEGER + " (inclusive).");
        }

        byte[] newValue = new byte[2];

        newValue[0] = (byte) (intValue >> 8);
        newValue[1] = (byte) (intValue);

        return new Identifier(newValue);
    }
1139422
public static int indexOf(String source, String target, int fromIndex, int toIndex) {
		if(fromIndex>toIndex) throw new IllegalArgumentException("fromIndex>toIndex: fromIndex="+fromIndex+", toIndex="+toIndex);

		int sourceCount = source.length();

		// This line makes it different than regular String indexOf method.
		if(toIndex<sourceCount) sourceCount = toIndex;

		int targetCount = target.length();

		if (fromIndex >= sourceCount) {
			return (targetCount == 0 ? sourceCount : -1);
	}
		if (fromIndex < 0) {
			fromIndex = 0;
		}
	if (targetCount == 0) {
		return fromIndex;
	}

		char first  = target.charAt(0);
		int max = sourceCount - targetCount;

		for (int i = fromIndex; i <= max; i++) {
			/* Look for first character. */
			if (source.charAt(i) != first) {
				while (++i <= max && source.charAt(i) != first) {
					// Intentionally empty
				}
			}

			/* Found first character, now look at the rest of v2 */
			if (i <= max) {
				int j = i + 1;
				int end = j + targetCount - 1;
				for (int k = 1; j < end && source.charAt(j) == target.charAt(k); j++, k++) {
					// Intentionally empty
				}

				if (j == end) {
					/* Found whole string. */
					return i;
				}
			}
		}
		return -1;
	}
9215
int firstOneInRange(int from, int to) {
		if (from < 0) throw new IllegalArgumentException();
		if (to < from) throw new IllegalArgumentException();
		from += start;
		to += start;
		if (to > finish) throw new IllegalArgumentException();
		return firstOneInRangeAdj(from, to) - start;
	}
901779
int firstZeroInRange(int from, int to) {
		if (from < 0) throw new IllegalArgumentException();
		if (to < from) throw new IllegalArgumentException();
		from += start;
		to += start;
		if (to > finish) throw new IllegalArgumentException();
		return firstZeroInRangeAdj(from, to) - start;
	}
1093821
private boolean areTypesSame(String from, String to)
   {
      String fromCompare = from.endsWith(".java") ? from.substring(0, from.length() - 5) : from;
      String toCompare = to.endsWith(".java") ? to.substring(0, to.length() - 5) : to;
      return fromCompare.equals(toCompare);
   }
346525
public static long readUnsignedInt(byte[] bytes, int offset) {
        return (((bytes[offset + 0] & 0xffL) << 24) | ((bytes[offset + 1] & 0xffL) << 16)
                | ((bytes[offset + 2] & 0xffL) << 8) | (bytes[offset + 3] & 0xffL));
    }
915331
static public int unpackInt(InputStream in) throws IOException {
        int ret = 0;
        int v;
        do{
            v = in.read();
            if(v==-1)
                throw new EOFException();
            ret = (ret<<7 ) | (v & 0x7F);
        }while((v&0x80)==0);

        return ret;
    }
989857
public int prevSetBit(final int i) {
    int x = i >> 6; // signed i / 64
    long w = bitmap.get(x);
    w <<= 64 - i - 1;
    if (w != 0) {
      return i - Long.numberOfLeadingZeros(w);
    }
    for (--x; x >= 0; --x) {
      long X = bitmap.get(x);
      if (X != 0) {
        return x * 64 + 63 - Long.numberOfLeadingZeros(X);
      }
    }
    return -1;
  }
383619
static int getUnsignedInt(ByteBuf buf, int offset) {
        return (buf.getByte(offset)     & 0x7F) << 24 |
               (buf.getByte(offset + 1) & 0xFF) << 16 |
               (buf.getByte(offset + 2) & 0xFF) <<  8 |
                buf.getByte(offset + 3) & 0xFF;
    }
1352937
private int readInteger() {
        int b = buf.get();
        if (buf.hasRemaining()) {
            int n = 0;
            int result = 0;
            while ((b & 0x80) != 0 && n < 3) {
                result <<= 7;
                result |= (b & 0x7f);
                b = buf.get();
                n++;
            }
            if (n < 3) {
                result <<= 7;
                result |= b;
            } else {
                // use all 8 bits from the 4th byte
                result <<= 8;
                result |= b & 0x0ff;
                // check if the integer should be negative
                if ((result & 0x10000000) != 0) {
                    // extend the sign bit
                    result |= 0xe0000000;
                }
            }
            return result;
        }
        return b;
    }
844602
public int readUnsignedShortAsInt(int off) {
    	this.buffer.position(off);
        int b1 = (0x000000FF & (this.buffer.get()));
        int b2 = (0x000000FF & (this.buffer.get()));
        int val = b1 << 8 | b2;
        return val;
    }
205674
public BEValue bdecodeBytes() throws IOException {
    int c = this.getNextIndicator();
    int num = c - '0';
    if (num < 0 || num > 9)
      throw new InvalidBEncodingException("Number expected, not '"
              + (char) c + "'");
    this.indicator = 0;

    c = this.read();
    int i = c - '0';
    while (i >= 0 && i <= 9) {
      // This can overflow!
      num = num * 10 + i;
      c = this.read();
      i = c - '0';
    }

    if (c != ':') {
      throw new InvalidBEncodingException("Colon expected, not '" +
              (char) c + "'");
    }

    return new BEValue(read(num));
  }
765320
public String numerify(String numberString, int from, int to) {
		return replaceSymbolWithCharsFromTo(numberString, '#', Character.forDigit(from, 10), Character.forDigit(to, 10));
	}
1257903
private int nextSetBit(int fromIndex) {
      if (fromIndex < 0)
         throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);

      int u = intIndex(fromIndex);
      int arrayLength = array.length();
      if (u >= arrayLength)
         return -1;

      int possible = array.get(u) & (INT_MASK << fromIndex);

      while (true) {
         if (possible != 0) {
            return (u << ADDRESS_BITS_PER_INT) + Integer.numberOfTrailingZeros(possible);
         }
         if (++u == arrayLength) {
            return -1;
         }
         possible = array.get(u);
      }
   }