Class StreamEncoder

java.lang.Object
de.craftsblock.craftsnet.api.http.encoding.StreamEncoder
Direct Known Subclasses:
DeflateStreamEncoder, GZIPStreamEncoder, IdentityStreamEncoder

public abstract class StreamEncoder extends Object
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 Details

    • StreamEncoder

      public StreamEncoder(@NotNull @NotNull String encodingName)
      Constructs a new StreamEncoder with the specified encoding name.
      Parameters:
      encodingName - The name of the encoding method; must not be null.
  • Method Details

    • encodeOutputStream

      @NotNull public @NotNull OutputStream encodeOutputStream(@NotNull @NotNull OutputStream raw)
      Encodes the provided OutputStream. 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

      @NotNull public @NotNull InputStream encodeInputStream(@NotNull @NotNull InputStream raw)
      Encodes the provided InputStream. 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:
      true if the encoding method is available; default is true.
    • getEncodingName

      @NotNull public final @NotNull String getEncodingName()
      Gets the name of the encoding method used by this encoder.
      Returns:
      The encoding name; never null.
    • equals

      public boolean equals(Object o)
      Compares this encoder to another object for equality. Two encoders are considered equal if they have the same encoding name.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare to.
      Returns:
      true if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Computes a hash code for this encoder based on its encoding name.
      Overrides:
      hashCode in class Object
      Returns:
      The computed hash code.