Package org.eolang

Class BytesOf

java.lang.Object
org.eolang.BytesOf
All Implemented Interfaces:
Bytes

public final class BytesOf extends Object implements Bytes
Bytes.
Since:
0.1.0
  • Constructor Details

    • BytesOf

      public BytesOf(String str)
      Ctor.
      Parameters:
      str - UTF-8 Text.
    • BytesOf

      public BytesOf(int number)
      Ctor.
      Parameters:
      number - Integer number.
    • BytesOf

      public BytesOf(char chr)
      Ctor.
      Parameters:
      chr - Character.
    • BytesOf

      public BytesOf(long number)
      Ctor.
      Parameters:
      number - Long number.
    • BytesOf

      public BytesOf(double number)
      Ctor.
      Parameters:
      number - Double number.
    • BytesOf

      public BytesOf(byte[] data)
      Ctor.
      Parameters:
      data - Data.
    • BytesOf

      public BytesOf(Bytes bytes)
      Ctor.
      Parameters:
      bytes - Bytes.
  • Method Details

    • not

      public Bytes not()
      Description copied from interface: Bytes
      NOT operation.
      Specified by:
      not in interface Bytes
      Returns:
      Bytes.
    • and

      public Bytes and(Bytes other)
      Description copied from interface: Bytes
      AND operation.
      Specified by:
      and in interface Bytes
      Parameters:
      other - Bytes.
      Returns:
      Bytes.
    • or

      public Bytes or(Bytes other)
      Description copied from interface: Bytes
      OR operation.
      Specified by:
      or in interface Bytes
      Parameters:
      other - Bytes.
      Returns:
      Bytes.
    • xor

      public Bytes xor(Bytes other)
      Description copied from interface: Bytes
      XOR operation.
      Specified by:
      xor in interface Bytes
      Parameters:
      other - Bytes.
      Returns:
      Bytes.
    • shift

      public Bytes shift(int bits)
      Description copied from interface: Bytes
      Big-endian unsigned shift. Shifts left if value is positive, or right otherwise. Does not perform sign extension.
      Specified by:
      shift in interface Bytes
      Parameters:
      bits - Bits to shift, negative to shift left.
      Returns:
      Bytes.
    • sshift

      public Bytes sshift(int bits)
      Description copied from interface: Bytes
      Big-endian signed right shift. Performs sign extension, i.e. it will fill the top bits with 1 if the first bit is 1 and with 0 otherwise.
      Specified by:
      sshift in interface Bytes
      Parameters:
      bits - Bits to shift, negative value causes exception.
      Returns:
      Bytes.
    • asNumber

      public Double asNumber()
      Description copied from interface: Bytes
      Convert to double number.
      Specified by:
      asNumber in interface Bytes
      Returns:
      Number.
    • asNumber

      public <T extends Number> T asNumber(Class<T> type)
      Description copied from interface: Bytes
      Convert to number.
      Specified by:
      asNumber in interface Bytes
      Type Parameters:
      T - Type
      Parameters:
      type - Number type
      Returns:
      Number
    • asString

      public String asString()
      Description copied from interface: Bytes
      Convert to string.
      Specified by:
      asString in interface Bytes
      Returns:
      String.
    • take

      public byte[] take()
      Description copied from interface: Bytes
      Get bytes itself.
      Specified by:
      take in interface Bytes
      Returns:
      Bytes.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object