Retrieve a <b>short</b> from a byte array in a given byte order
966467
public static int toShort(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
		}
		return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
	}
679193
public short getShort(String key) {
		addToDefaults(key, null);
		String value = getRequired(key);
		return Short.valueOf(value);
	}
413668
@Override
    public byte[] getBytes(int position, int length) {
        byte[] result = new byte[length];
        for (int i = 0; i < length; i++) {
            result[i]=getByte(position);
            position += BYTE_LEN;
        }
        return result;
    }
854355
function getByte(array, position, length) {
  const d = position % 8;
  const a = Math.floor(position / 8);
  const de = 8 - d;
  const ef = (position + length) - ((a + 1) * 8);
  let fg = (8 * (a + 2)) - (position + length);
  const dg = ((a + 2) * 8) - position;
  fg = Math.max(0, fg);
  if (a >= array.length) {
    console.warn('ran off the end of the buffer before finding EOI_CODE (end on input code)');
    return EOI_CODE;
  }
  let chunk1 = array[a] & ((2 ** (8 - d)) - 1);
  chunk1 <<= (length - de);
  let chunks = chunk1;
  if (a + 1 < array.length) {
    let chunk2 = array[a + 1] >>> fg;
    chunk2 <<= Math.max(0, (length - dg));
    chunks += chunk2;
  }
  if (ef > 8 && a + 2 < array.length) {
    const hi = ((a + 3) * 8) - (position + length);
    const chunk3 = array[a + 2] >>> hi;
    chunks += chunk3;
  }
  return chunks;
}
529942
public short[] loadShortArray() throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return null;
    }
    
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
    
    try {
      r.open();
      r.position(DATA_START_POSITION);
        
      short[] array = new short[_arrayLength];
      for (int i = 0; i < _arrayLength; i++) {
        array[i] = r.readShort();
      }
      
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
      return array;
    } finally {
      r.close();
    }
  }
598895
public static final short parseShort(CharSequence cs)
    {
        if (CharSequences.startsWith(cs, "0b"))
        {
            return parseShort(cs, 2, 2, cs.length());
        }
        if (CharSequences.startsWith(cs, "0x"))
        {
            return parseShort(cs, 16, 2, cs.length());
        }
        return parseShort(cs, 10);
    }
510469
public static short readShortLittleEndian(InputStream io) throws IOException {
		int value = io.read();
		if (value < 0) throw new EOFException();
		int i = io.read();
		if (i < 0) throw new EOFException();
		return (short)(value | (i << 8));
	}
1165591
public static int writeShort(byte[] target, int offset, short value) {
        target[offset] = (byte) (value >>> 8 & 255);
        target[offset + 1] = (byte) (value & 255);
        return Short.BYTES;
    }
550504
def read_short(self, unpacker=Struct('>H').unpack_from,
                   size=Struct('>H').size):
        
        self._check_underflow(size)
        rval = unpacker(self._input, self._pos)[0]
        self._pos += size
        return rval
1141520
public short[] getShortArray(final String key) {
		final String[] value = getArray(key);
		if (value != null) {
			final short[] result = new short[value.length];
			for (int i = 0; i < value.length; i++) {
				result[i] = Short.parseShort(value[i]);
			}
			return result;
		}
		return null;
	}
734945
public static void setShort(final byte[] b, final short n, final int offset) {
        b[offset + 0] = (byte) (n >>> 8);
        b[offset + 1] = (byte) (n >>> 0);
    }
37199
@Override
    public short[] read(ScanBuffer buffer) {
        int length = getLength(buffer);
        if (length<0) return null;
        return buffer.getShorts(length);
    }
1234077
private static Short[] castToShort( short[] d )
    {
        Short[] dest = new Short[d.length];
        for ( int i = 0; i < d.length; i++ )
        {
            dest[i] = (Short)d[i];
        }
        return dest;
    }
358042
public short[] getShortArray(final String key, final short[] def) {
		try {
			final short[] result = getShortArray(key);
			return result != null ? result : def;
		} catch (final NumberFormatException nfe) {
			return def;
		}
	}
1329694
public static short readShort(byte[] buf, int pos) {
    checkBoundary(buf, pos, 2);
    return (short) (((short) (buf[pos] & 0xff) << 8) | ((short) (buf[pos + 1] & 0xff)));
  }
278102
public static byte[] writeShort(short v, byte[] b, int offset) {
        b[offset] = (byte) v;
        b[offset + 1] = (byte) (v >> 8);

        return b;
    }
1049838
public int getShort(int offset)
  {
    int b0 = getCode()[offset + 0] & 0xff;
    int b1 = getCode()[offset + 1] & 0xff;
    
    return (short) ((b0 << 8) + b1);
  }