hop-2012/hop/SexpBytes.java

45 lines
885 B
Java

/*
* Copyright (c) 2011 Tony Garnock-Jones. All rights reserved.
*/
package hop;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
/**
*/
public class SexpBytes {
public byte[] _bytes;
public SexpBytes(byte[] bytes) {
_bytes = bytes;
}
public byte[] getData() {
return _bytes;
}
public String getDataString() {
return new String(getData());
}
public void writeTo(OutputStream stream) throws IOException {
SexpWriter.writeSimpleString(stream, _bytes);
}
public String toString() {
return SexpWriter.writeString(this);
}
public boolean equals(Object other) {
return (other instanceof SexpBytes) &&
Arrays.equals(_bytes, ((SexpBytes) other).getData());
}
public int hashCode() {
return Arrays.hashCode(_bytes);
}
}