Class Device

java.lang.Object
io.ciera.runtime.api.types.Device
Direct Known Subclasses:
ReadableDevice

public abstract class Device extends Object
A device represents a readable or read-writable object. Streams can be read from devices or directed as output to devices.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Device(String name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Device
    Get a reference to the built in console device.
    abstract void
    Flush the output stream.
    static Device
     
    abstract <T> T
    read(Class<T> cls)
    Read a single token from the device stream and attempt to convert the token to type cls.
    abstract String
    Read a single line from the stream and return as a String.
     
    abstract void
    Convert an instance of an object to a String and append to the stream.
    abstract void
    Convert an instance of an object to a String and append to the stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Device

      public Device(String name)
  • Method Details

    • read

      public abstract <T> T read(Class<T> cls)
      Read a single token from the device stream and attempt to convert the token to type cls. The tokenization of the stream is left up to the individual implementation, however, by default tokens are delimited by whitespace.
      Parameters:
      cls - The type to interpret tokens as.
      Returns:
      A parsed instance of the type represented by the token.
    • readLine

      public abstract String readLine()
      Read a single line from the stream and return as a String. The line terminator is determined by the system.
      Returns:
      a line of text from the stream.
    • write

      public abstract void write(Object o)
      Convert an instance of an object to a String and append to the stream.
      Parameters:
      o - The instance to write.
    • writeLine

      public abstract void writeLine(Object o)
      Convert an instance of an object to a String and append to the stream. Append an additional line separator. The line separator is determined by the system.
      Parameters:
      o -
    • flush

      public abstract void flush()
      Flush the output stream.
    • console

      public static Device console()
      Get a reference to the built in console device.
      Returns:
      A Device instance that represents input and output from standard input and output.
    • toString

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

      public static Device fromString(String s)