Class BaseDevice

java.lang.Object
org.aesh.terminal.BaseDevice
All Implemented Interfaces:
Device

public class BaseDevice extends Object implements Device
Abstract base implementation of the Device interface providing common functionality for terminal device capabilities.
Author:
Ståle W. Pedersen
  • Field Details

    • bools

      protected final Set<Capability> bools
      Set of boolean capabilities supported by this device.
    • ints

      protected final Map<Capability,Integer> ints
      Map of numeric capabilities and their values.
    • strings

      protected final Map<Capability,String> strings
      Map of string capabilities and their values.
    • type

      protected String type
      The terminal type identifier.
  • Constructor Details

    • BaseDevice

      public BaseDevice()
      Creates a new BaseDevice with the default "ansi" terminal type.
    • BaseDevice

      public BaseDevice(String type)
      Creates a new BaseDevice with the specified terminal type.
      Parameters:
      type - the terminal type identifier
  • Method Details

    • type

      public String type()
      Description copied from interface: Device
      Returns the terminal type identifier for this device.
      Specified by:
      type in interface Device
      Returns:
      the terminal type (e.g., "xterm", "ansi", "vt100")
    • getBooleanCapability

      public boolean getBooleanCapability(Capability capability)
      Description copied from interface: Device
      Checks if this device has the specified boolean capability.
      Specified by:
      getBooleanCapability in interface Device
      Parameters:
      capability - the capability to check
      Returns:
      true if the capability is supported, false otherwise
    • getNumericCapability

      public Integer getNumericCapability(Capability capability)
      Description copied from interface: Device
      Gets the value of a numeric capability.
      Specified by:
      getNumericCapability in interface Device
      Parameters:
      capability - the capability to retrieve
      Returns:
      the numeric value, or null if the capability is not set
    • getStringCapability

      public String getStringCapability(Capability capability)
      Description copied from interface: Device
      Gets the value of a string capability.
      Specified by:
      getStringCapability in interface Device
      Parameters:
      capability - the capability to retrieve
      Returns:
      the string value, or null if the capability is not set
    • getStringCapabilityAsInts

      public int[] getStringCapabilityAsInts(Capability capability, Object... params)
      Description copied from interface: Device
      Gets a string capability as an array of code points, with parameter substitution.
      Specified by:
      getStringCapabilityAsInts in interface Device
      Parameters:
      capability - the capability to retrieve
      params - optional parameters to substitute into the capability string
      Returns:
      the capability string as an int array of code points, or null if not set
    • puts

      public boolean puts(Consumer<int[]> output, Capability capability, Object... params)
      Description copied from interface: Device
      Outputs a capability string to the given consumer with parameter substitution.
      Specified by:
      puts in interface Device
      Parameters:
      output - the consumer to receive the output as an int array
      capability - the capability to output
      params - optional parameters to substitute into the capability string
      Returns:
      true if the capability was found and output, false otherwise
    • puts

      public boolean puts(Consumer<int[]> output, String capability, Object... params)
      Description copied from interface: Device
      Outputs a capability string to the given consumer with parameter substitution.
      Specified by:
      puts in interface Device
      Parameters:
      output - the consumer to receive the output as an int array
      capability - the capability name to look up and output
      params - optional parameters to substitute into the capability string
      Returns:
      true if the capability was found and output, false otherwise