class ByteArray implements Serializable, Cloneable {

    public ByteArray writeAsPs(String s, int displacement, int length) {
        s = s.trim();
        // we will also allow that the value has a sign ("-" or "+") at the end,
        // e.g. "1234-"
        Matcher matcher = psRegexPattern.matcher(s);
        if (!matcher.matches()) {
            throw new IllegalArgumentException("Value:" + s
                    + " has illegal character values for a packed field.");
        }
        char sign = 'F';
        // look for the sign in the value
        // check if length of string is zero
        if (s.length() > 0) {
            if (s.charAt(s.length() - 1) == '+'
                    || s.charAt(0) == '+') {
                sign = 'C';
                s = s.replaceAll("\\+", "");
            } else if (s.charAt(s.length() - 1) == '-'
                    || s.charAt(0) == '-') {
                sign = 'D';
                s = s.replaceAll("-", "");
            }
        }
        s += sign;
        writeAsPns(s, displacement, length, '0');
        return this;
    }

    public  ByteArray(int size);
    public  ByteArray(int size, String encoding);
    public  ByteArray(int size, ByteOrder order);
    public  ByteArray(int size, String encoding, ByteOrder order);
    public  ByteArray(byte[] array);
    public  ByteArray(byte[] array, ByteOrder order);
    public  ByteArray(byte[] array, String encoding);
    public  ByteArray(byte[] array, String encoding, ByteOrder order);
    public  ByteArray(ByteArray byteArray);
    public  ByteArray(ByteBuffer buffer);
    public  ByteArray(ByteBuffer buffer, String encoding);

}