Reads a single {@link Geometry} in WKB format from a byte array.

@param bytes the byte array to read from
@return the geometry read
@throws ParseException if the WKB is ill-formed
169622
public Geometry read( byte[] bytes ) throws ParseException {
        // possibly reuse the ByteArrayInStream?
        // don't throw IOExceptions, since we are not doing any I/O
        try {
            return read(new ByteArrayInStream(bytes));
        } catch (IOException ex) {
            throw new RuntimeException("Unexpected IOException caught: " + ex.getMessage());
        }
    }
649370
public <T> T parse(byte[] in, JsonReaderI<T> mapper) throws ParseException {
		return getPBytes().parse(in, mapper);
	}
221564
public Map<String, String> decode(byte[] bytes) throws DeserializationException {
        Map<String, String> map = new HashMap<String, String>();
        if (bytes == null || bytes.length == 0) {
            return map;
        }

        UnsafeByteArrayInputStream in = new UnsafeByteArrayInputStream(bytes);
        try {
            while (in.available() > 0) {
                String key = readString(in);
                String value = readString(in);
                map.put(key, value);
            }
            return map;
        } catch (IOException ex) {
            throw new DeserializationException(ex.getMessage(), ex);
        }
    }
390860
public static long parseLong(byte[] bytes, int from, int to) {
        long result = 0;
        for (int i = from; i < to && i < bytes.length; i++) {
            result *= 10;
            result += (bytes[i] - (byte) '0');
        }
        return result;
    }
390451
public static float bytes_to_float(byte[] bytes, int offset) {
		try {
			int result = bytes[0+offset] & 0xff;
			result <<= 8;
			result |= bytes[1+offset] & 0xff;
			result <<= 8;
			result |= bytes[2+offset] & 0xff;
			result <<= 8;
			result |= bytes[3+offset] & 0xff;
			return Float.intBitsToFloat(result);
		} catch (IndexOutOfBoundsException x) {
			throw new PickleException("decoding float: too few bytes");
		}
	}
980646
public static InputStream bytes2InputStream(final byte[] bytes) {
        if (bytes == null || bytes.length <= 0) return null;
        return new ByteArrayInputStream(bytes);
    }
46312
public static Optional<Byte> readMaybeByte(ByteBuf bf) {
      if (bf.readableBytes() >= 1) {
         return Optional.of(bf.readByte());
      } else {
         bf.resetReaderIndex();
         return Optional.empty();
      }
   }
801110
public static String toHex( byte[] bytes ) {
        StringBuffer buf = new StringBuffer();
        for( int i = 0; i < bytes.length; i++ ) {
            byte b = bytes[i];
            buf.append(toHexDigit((b >> 4) & 0x0F));
            buf.append(toHexDigit(b & 0x0F));
        }
        return buf.toString();
    }
97929
protected <T> T decode(byte[] bytes) {
    return bytes != null ? userSerializer.decode(bytes) : null;
  }
1139521
public static Stream<Byte> box(final byte[] bytes) {
        return new FixedSizeStream<>(bytes.length, new Func1<Integer, Byte>() {
            @Override
            public Byte call(Integer index) {
                return bytes[index];
            }
        });
    }
424140
public static byte[] readBytes(byte b[], int offset, int length) {
    byte[] retValue = new byte[length];
    System.arraycopy(b, offset, retValue, 0, length);
    return retValue;
  }
635872
public Object parse(byte [] bytes, String charset) {
        if (bytes == null) {
            throw new IllegalArgumentException("bytes must not be null");
        }

        if (charset == null) {
            throw new IllegalArgumentException("charset must not be null");
        }

        Object content;
        content = createParser().parse(bytes, charset);
        return content;
    }
1244177
public static final Object deserialize(byte[] bytes) throws Exception {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, "deserialize");

        Object o;
        try {
            ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
            ObjectInputStream oin = new ObjectInputStream(bis);
            o = oin.readObject();
            oin.close();
        } catch (IOException e) {
            FFDCFilter.processException(e, ConnectorService.class.getName(), "151");
            if (trace && tc.isEntryEnabled())
                Tr.exit(tc, "deserialize", new Object[] { toString(bytes), e });
            throw e;
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, "deserialize", o == null ? null : o.getClass());
        return o;
    }
849675
public static Geometry toGeometry(byte[] bytes, int srid) throws SQLException{
        if(bytes==null) {
            return null;
        }
        WKBReader wkbReader = new WKBReader();
        try {
            Geometry geometry = wkbReader.read(bytes);
            geometry.setSRID(srid);
            return geometry;
        } catch (ParseException ex) {
            throw new SQLException("Cannot parse the input bytes",ex);
        }
    }
238184
public static int[] convertBytesToInts(byte[] bytes)
    {
        if (bytes.length % 4 != 0)
        {
            throw new IllegalArgumentException("Number of input bytes must be a multiple of 4.");
        }
        int[] ints = new int[bytes.length / 4];
        for (int i = 0; i < ints.length; i++)
        {
            ints[i] = convertBytesToInt(bytes, i * 4);
        }
        return ints;
    }
730118
public static FixedBucketsHistogram fromBytes(byte[] bytes)
  {
    ByteBuffer buf = ByteBuffer.wrap(bytes);
    return fromByteBuffer(buf);
  }
603321
private static Geometry parseWkt(String wkt) throws WktException {
		if (wkt != null) {
			int i1 = wkt.indexOf('(');
			int i2 = wkt.indexOf(' ');
			// allow both '(' and ' ('
			int i = Math.min(i1, i2);
			if (i < 0) {
				i = (i1 > 0 ? i1 : i2);
			}
			String type = null;
			if (i >= 0) {
				type = typeWktToGeom(wkt.substring(0, i).trim());
			}
			if (type == null) {
				throw new WktException(ERR_MSG + "type of geometry not supported");
			}
			if (wkt.indexOf("EMPTY") >= 0) {
				return new Geometry(type, 0, 0);
			}
			Geometry geometry = new Geometry(type, 0, 0);
			String result = parse(wkt.substring(wkt.indexOf('(')), geometry);
			if (result.length() != 0) {
				throw new WktException(ERR_MSG + "unexpected ending \"" + result + "\"");
			}
			return geometry;
		}
		throw new WktException(ERR_MSG + "illegal argument; no WKT");
	}