Store a <b>short</b> number into a byte array in a given byte order
764877
public static void setShort(int n, byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			b[off] = (byte) n;
			b[off + 1] = (byte) (n >>> 8);
		} else {
			b[off] = (byte) (n >>> 8);
			b[off + 1] = (byte) n;
		}
	}
911452
public static void writeShort(byte[] buf, int pos, short v) {
    checkBoundary(buf, pos, 2);
    buf[pos++] = (byte) (0xff & (v >> 8));
    buf[pos] = (byte) (0xff & v);
  }
441979
@Pure
	@Inline(value = "$2.valueOf($1.shortValue())", imported = Short.class)
	public static Short toShort(AtomicDouble number) {
		return Short.valueOf(number.shortValue());
	}
278102
public static byte[] writeShort(short v, byte[] b, int offset) {
        b[offset] = (byte) v;
        b[offset + 1] = (byte) (v >> 8);

        return b;
    }
1261977
public static void encode(short value, byte[] dst, int dstOffset) {
        value ^= 0x8000;
        dst[dstOffset    ] = (byte)(value >> 8);
        dst[dstOffset + 1] = (byte)value;
    }
454834
static public final short[] RLEStringToShortArray(String s) {
        int length = ((s.charAt(0)) << 16) | (s.charAt(1));
        short[] array = new short[length];
        int ai = 0;
        for (int i=2; i<s.length(); ++i) {
            char c = s.charAt(i);
            if (c == ESCAPE) {
                c = s.charAt(++i);
                if (c == ESCAPE) {
                    array[ai++] = (short) c;
                } else {
                    int runLength = c;
                    short runValue = (short) s.charAt(++i);
                    for (int j=0; j<runLength; ++j) array[ai++] = runValue;
                }
            }
            else {
                array[ai++] = (short) c;
            }
        }

        if (ai != length)
            throw new IllegalStateException("Bad run-length encoded short array");

        return array;
    }
757381
private void writeShort(int s, byte[] buf, int offset) throws IOException {
        buf[offset] = (byte)(s & 0xff);
        buf[offset + 1] = (byte)((s >> 8) & 0xff);
    }
857372
public static short decodeShort(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            return (short)(((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff)) ^ 0x8000);
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
841730
public Packer putShort(final short value) {
		ensureCapacity(bufPosition + 2);
		buf[bufPosition++] = (byte) (value >> 8);
		buf[bufPosition++] = (byte) (value);
		return this;
	}
381911
public void fromShort(short n) {
    Bits[] v = Bits.values();
    set(v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7]);
  }
739364
public void putBytes(int pos, byte... bs) {
		adaptSize(pos + bs.length);
		ByteBuffer bb = null;
		int i = _bufferSize;
		for (byte b : bs) {
			if (i == _bufferSize) {
				bb = getBuffer(pos);
				i = pos % _bufferSize;
			}
			bb.put(i, b);
			++i;
			++pos;
		}
	}
825226
public static void shortToBytes(short value, byte[] bytes, int offset) {
        for (int i = offset + 1; i >= offset; --i) {
            bytes[i] = (byte) value;
            value = (short) ((value) >> 8);
        }
    }
600132
public Short getAsShort(String key) {
        Object value = mValues.get(key);
        try {
            return value != null ? ((Number) value).shortValue() : null;
        } catch (ClassCastException e) {
            if (value instanceof CharSequence) {
                try {
                    return Short.valueOf(value.toString());
                } catch (NumberFormatException e2) {
                    logger.severe("Cannot parse Short value for " + value + " at key " + key);
                    return null;
                }
            } else {
                logger.log(Level.SEVERE,"Cannot cast value for " + key + " to a Short: " + value, e);
                return null;
            }
        }
    }
1049838
public int getShort(int offset)
  {
    int b0 = getCode()[offset + 0] & 0xff;
    int b1 = getCode()[offset + 1] & 0xff;
    
    return (short) ((b0 << 8) + b1);
  }
1332664
public static short byteArrayToShortLE( byte[] data ) {
        ByteBuffer buffer = ByteBuffer.wrap(data);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        return buffer.getShort();
    }
463792
public static Short decodeShortObjDesc(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            int b = src[srcOffset];
            if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) {
                return null;
            }
            return decodeShortDesc(src, srcOffset + 1);
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
676926
def write_short(self, n):
        """"""
        if n < 0 or n > 65535:
            raise FrameSyntaxError(
                'Octet {0!r} out of range 0..65535'.format(n))
        self._flushbits()
        self.out.write(pack('>H', int(n)))