AsciiString Class — netty Architecture
Architecture documentation for the AsciiString class in AsciiString.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a41de6d4_fd08_8a12_95fd_35db12fdb4cc["AsciiString"] 1824b1c8_6aad_53a8_a73b_c1a550fcd02d["AsciiString.java"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|defined in| 1824b1c8_6aad_53a8_a73b_c1a550fcd02d a72e30a9_4d56_8b77_3c6b_123012c39eb8["AsciiString()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| a72e30a9_4d56_8b77_3c6b_123012c39eb8 a5b1546d_4d5a_8b83_8038_39d6ff8582f3["forEachByte()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| a5b1546d_4d5a_8b83_8038_39d6ff8582f3 b8b73d94_f1a6_829c_c517_2c01af5da462["forEachByte0()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| b8b73d94_f1a6_829c_c517_2c01af5da462 c76f81bd_77bd_272b_68ce_0af364045ddb["forEachByteDesc()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| c76f81bd_77bd_272b_68ce_0af364045ddb 265d4a41_5398_150f_d619_b7afe487f1e7["forEachByteDesc0()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| 265d4a41_5398_150f_d619_b7afe487f1e7 d6afc68a_9991_3f66_cbde_8ec9fd5579cf["byteAt()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| d6afc68a_9991_3f66_cbde_8ec9fd5579cf d502283b_4732_c41c_51fb_b9176b171d6d["isEmpty()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| d502283b_4732_c41c_51fb_b9176b171d6d fb319f55_ebbc_4b58_3f44_4a89b340c1b2["length()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| fb319f55_ebbc_4b58_3f44_4a89b340c1b2 99a738a1_6781_e984_46ee_ea134412203f["arrayChanged()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| 99a738a1_6781_e984_46ee_ea134412203f e0501b8d_8613_85a6_b3ee_d2f164ec59f1["array()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| e0501b8d_8613_85a6_b3ee_d2f164ec59f1 563104d5_0779_8bf9_4289_ded808a3624b["arrayOffset()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| 563104d5_0779_8bf9_4289_ded808a3624b da15e4a0_e17b_86e8_40f0_d709892f40b3["isEntireArrayUsed()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| da15e4a0_e17b_86e8_40f0_d709892f40b3 cecd5f66_9883_37db_e014_17e65febe287["toByteArray()"] a41de6d4_fd08_8a12_95fd_35db12fdb4cc -->|method| cecd5f66_9883_37db_e014_17e65febe287
Relationship Graph
Source Code
common/src/main/java/io/netty/util/AsciiString.java lines 47–1853
public final class AsciiString implements CharSequence, Comparable<CharSequence> {
public static final AsciiString EMPTY_STRING = cached("");
private static final char MAX_CHAR_VALUE = 255;
public static final int INDEX_NOT_FOUND = -1;
/**
* If this value is modified outside the constructor then call {@link #arrayChanged()}.
*/
private final byte[] value;
/**
* Offset into {@link #value} that all operations should use when acting upon {@link #value}.
*/
private final int offset;
/**
* Length in bytes for {@link #value} that we care about. This is independent from {@code value.length}
* because we may be looking at a subsection of the array.
*/
private final int length;
/**
* The hash code is cached after it is first computed. It can be reset with {@link #arrayChanged()}.
*/
private int hash;
/**
* Used to cache the {@link #toString()} value.
*/
private String string;
/**
* Initialize this byte string based upon a byte array. A copy will be made.
*/
public AsciiString(byte[] value) {
this(value, true);
}
/**
* Initialize this byte string based upon a byte array.
* {@code copy} determines if a copy is made or the array is shared.
*/
public AsciiString(byte[] value, boolean copy) {
this(value, 0, value.length, copy);
}
/**
* Construct a new instance from a {@code byte[]} array.
* @param copy {@code true} then a copy of the memory will be made. {@code false} the underlying memory
* will be shared.
*/
public AsciiString(byte[] value, int start, int length, boolean copy) {
if (copy) {
final byte[] rangedCopy = new byte[length];
System.arraycopy(value, start, rangedCopy, 0, rangedCopy.length);
this.value = rangedCopy;
this.offset = 0;
} else {
if (isOutOfBounds(start, length, value.length)) {
throw new IndexOutOfBoundsException("expected: " + "0 <= start(" + start + ") <= start + length(" +
length + ") <= " + "value.length(" + value.length + ')');
}
this.value = value;
this.offset = start;
}
this.length = length;
}
/**
* Create a copy of the underlying storage from {@code value}.
* The copy will start at {@link ByteBuffer#position()} and copy {@link ByteBuffer#remaining()} bytes.
*/
public AsciiString(ByteBuffer value) {
this(value, true);
}
/**
* Initialize an instance based upon the underlying storage from {@code value}.
* There is a potential to share the underlying array storage if {@link ByteBuffer#hasArray()} is {@code true}.
* if {@code copy} is {@code true} a copy will be made of the memory.
* if {@code copy} is {@code false} the underlying storage will be shared, if possible.
*/
public AsciiString(ByteBuffer value, boolean copy) {
this(value, value.position(), value.remaining(), copy);
Source
Frequently Asked Questions
What is the AsciiString class?
AsciiString is a class in the netty codebase, defined in common/src/main/java/io/netty/util/AsciiString.java.
Where is AsciiString defined?
AsciiString is defined in common/src/main/java/io/netty/util/AsciiString.java at line 47.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free