public final class HttpString extends Object implements Comparable<HttpString>, Serializable
Modifier and Type | Field and Description |
---|---|
static HttpString | EMPTY Empty HttpString instance. |
Constructor and Description |
---|
HttpString(byte[] bytes) Construct a new instance. |
HttpString(byte[] bytes, int offset, int length) Construct a new instance. |
HttpString(ByteBuffer buffer) Construct a new instance by reading the remaining bytes from a buffer. |
HttpString(String string) Construct a new instance from a String . |
Modifier and Type | Method and Description |
---|---|
void | appendTo(ByteBuffer buffer) Append to a byte buffer. |
byte | byteAt(int idx) Get the byte at an index. |
int | compareTo(HttpString other) Compare this string to another in a case-insensitive manner. |
void | copyTo(byte[] dst, int offs) Copy all the bytes from this string to the given array at the given offset. |
void | copyTo(byte[] dst, int offs, int len) Copy len bytes from this string to the given array at the given offset. |
void | copyTo(int srcOffs, byte[] dst, int offs, int len) Copy len bytes from this string at offset srcOffs to the given array at the given offset. |
boolean | equals(HttpString other) Determine if this HttpString is equal to another. |
boolean | equals(Object other) Determine if this HttpString is equal to another. |
boolean | equalToString(String headerName) |
int | hashCode() Get the hash code. |
int | length() Get the string length. |
String | toString() Get the String representation of this HttpString . |
static HttpString | tryFromString(String string) Attempt to convert a String to an HttpString . |
void | writeTo(OutputStream output) Append to an output stream. |
public static final HttpString EMPTY
public HttpString(byte[] bytes)
bytes
- the byte array to copypublic HttpString(byte[] bytes, int offset, int length)
bytes
- the byte array to copyoffset
- the offset into the array to start copyinglength
- the number of bytes to copypublic HttpString(ByteBuffer buffer)
buffer
- the buffer to readpublic HttpString(String string)
String
. The String
will be used as the cached toString()
value for this HttpString
.string
- the source stringpublic static HttpString tryFromString(String string)
String
to an HttpString
. If the string cannot be converted, null
is returned.string
- the string to trynull
if the string is not in a compatible encodingpublic int length()
public byte byteAt(int idx)
public void copyTo(int srcOffs, byte[] dst, int offs, int len)
len
bytes from this string at offset srcOffs
to the given array at the given offset.srcOffs
- the source offsetdst
- the destinationoffs
- the destination offsetlen
- the number of bytes to copypublic void copyTo(byte[] dst, int offs, int len)
len
bytes from this string to the given array at the given offset.dst
- the destinationoffs
- the destination offsetlen
- the number of bytespublic void copyTo(byte[] dst, int offs)
dst
- the destinationoffs
- the destination offsetpublic void appendTo(ByteBuffer buffer)
buffer
- the buffer to append topublic void writeTo(OutputStream output) throws IOException
output
- the stream to write toIOException
- if an error occurspublic int compareTo(HttpString other)
compareTo
in interface Comparable<HttpString>
other
- the other stringpublic int hashCode()
public boolean equals(Object other)
HttpString
is equal to another.public boolean equals(HttpString other)
HttpString
is equal to another.other
- the other objecttrue
if they are equal, false
otherwisepublic String toString()
String
representation of this HttpString
.public boolean equalToString(String headerName)
Copyright © 2020 JBoss by Red Hat. All rights reserved.