Class StreamEncoder
java.lang.Object
de.craftsblock.craftsnet.api.http.encoding.StreamEncoder
- Direct Known Subclasses:
DeflateStreamEncoder,GZIPStreamEncoder,IdentityStreamEncoder
Abstract class representing a stream encoder, which can be used to encode and decode input and output streams.
Subclasses should implement specific encoding mechanisms as needed.
- Since:
- 3.3.3-SNAPSHOT
-
Constructor Summary
ConstructorsConstructorDescriptionStreamEncoder(@NotNull String encodingName) Constructs a newStreamEncoderwith the specified encoding name. -
Method Summary
Modifier and TypeMethodDescription@NotNull InputStreamencodeInputStream(@NotNull InputStream raw) Encodes the providedInputStream.@NotNull OutputStreamencodeOutputStream(@NotNull OutputStream raw) Encodes the providedOutputStream.booleanCompares this encoder to another object for equality.final @NotNull StringGets the name of the encoding method used by this encoder.inthashCode()Computes a hash code for this encoder based on its encoding name.booleanChecks whether the encoding method is available.
-
Constructor Details
-
StreamEncoder
Constructs a newStreamEncoderwith the specified encoding name.- Parameters:
encodingName- The name of the encoding method; must not be null.
-
-
Method Details
-
encodeOutputStream
Encodes the providedOutputStream. By default, this method returns the raw stream. Subclasses should override this method to provide actual encoding functionality.- Parameters:
raw- The raw output stream to be encoded; must not be null.- Returns:
- The encoded output stream; by default, returns the same raw stream.
-
encodeInputStream
Encodes the providedInputStream. By default, this method returns the raw stream. Subclasses should override this method to provide actual encoding functionality.- Parameters:
raw- The raw input stream to be encoded; must not be null.- Returns:
- The encoded input stream; by default, returns the same raw stream.
-
isAvailable
public boolean isAvailable()Checks whether the encoding method is available. Subclasses may override this method to implement specific availability checks.- Returns:
trueif the encoding method is available; default istrue.
-
getEncodingName
Gets the name of the encoding method used by this encoder.- Returns:
- The encoding name; never null.
-
equals
Compares this encoder to another object for equality. Two encoders are considered equal if they have the same encoding name. -
hashCode
public int hashCode()Computes a hash code for this encoder based on its encoding name.
-