@haxall/haxall
    Preparing search index...

    Class OutStream

    OutStream is used to write binary and text data to an output stream.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • The current charset used to encode Unicode characters into bytes. The default charset should always be UTF-8.

      Returns Charset

    • The current charset used to encode Unicode characters into bytes. The default charset should always be UTF-8.

      Parameters

      Returns void

    • Close the output stream. This method is guaranteed to never throw an IOErr. Return true if the stream was closed successfully or false if the stream was closed abnormally. Default implementation does nothing and returns true.

      Returns boolean

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Byte order mode for binary writes. Default is Endian.big (network byte order).

      Returns Endian

    • Byte order mode for binary writes. Default is Endian.big (network byte order).

      Parameters

      Returns void

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Flush the stream so any buffered bytes are written out. Default implementation does nothing. Throw IOErr on error. Return this.

      Returns this

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Convenience for writeChars(obj.toStr). If obj is null, then print the string "null". Return this.

      Parameters

      Returns this

    • Convenience for writeChars(obj.toStr + "\n"). If obj is null then print the string "null\n". Return this.

      Parameters

      Returns this

    • If this output stream is mapped to a file device, then synchronize all memory buffers to the physical storage device. Throw IOErr on error. Return this.

      Returns this

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return a string representation of this object.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Write a byte to the output stream. Throw IOErr on error. Return this.

      Parameters

      • byte: number

      Returns this

    • Write between 0 and 64 bits of the given integer value. Bits which are only a partial byte are bufferred in RAM until flush.

      Parameters

      • val: number
      • num: number

      Returns this

    • Write one byte, one if true or zero if false. This method is paired with InStream.readBool. Throw IOErr on error. Return this.

      Parameters

      • b: boolean

      Returns this

    • Write n bytes from the specified Buf at its current position to this output stream. If n is defaulted to buf.remaining(), then everything left in the buffer is drained to this output stream. The buf's position is advanced n bytes upon return. Throw IOErr on error. Return this.

      Parameters

      • buf: Buf
      • Optionaln: number

      Returns this

    • Write one or more bytes to the stream for the specified Unicode character based on the current charset encoding. Return this.

      Parameters

      • char: number

      Returns this

    • Write the Unicode characters in the specified string to the stream using the current charset encoding. The off arg specifies the index offset to start writing characters and len the number of characters in str to write. Return this.

      Parameters

      • str: string
      • Optionaloff: number
      • Optionallen: number

      Returns this

    • Write a decimal as a string according to writeUtf.

      Parameters

      • d: number

      Returns this

    • Write four bytes as a 32-bit floating point number using configured endian order according to Float.bits32. This is paired with InStream.readF4. Throw IOErr on error. Return this.

      Parameters

      • r: number

      Returns this

    • Write eight bytes as a 64-bit floating point number using configured endian order according to Float.bits. This is paired with InStream.readF8. Throw IOErr on error. Return this.

      Parameters

      • r: number

      Returns this

    • Write two bytes as a 16-bit number using configured endian. This method may be paired with InStream.readU2 or InStream.readS2. Throw IOErr on error. Return this.

      Parameters

      • n: number

      Returns this

    • Write four bytes as a 32-bit number using configured endian. This method may be paired with InStream.readU4 or InStream.readS4. Throw IOErr on error. Return this.

      Parameters

      • n: number

      Returns this

    • Write eight bytes as a 64-bit number using configured endian. This is paired with InStream.readS8. Throw IOErr on error. Return this.

      Parameters

      • n: number

      Returns this

    • Write a serialized object from the stream according to the Fantom serialization format. Throw IOErr on error. Return this.

      The options may be used to specify the format of the output:

      • "indent": Int specifies how many spaces to indent each level. Default is 0.
      • "skipDefaults": Bool specifies if we should skip fields at their default values. Field values are compared according to the equals method. Default is false.
      • "skipErrors": Bool specifies if we should skip objects which aren't serializable. If true then we output null and a comment. Default is false.

      Parameters

      Returns this

    • Write the given map of Str name/value pairs to the output stream according to the Fantom props file format (see InStream.readProps for full specification). The props are written using UTF-8 regardless of this stream's current charset. If close argument is true, then automatically close the stream. Return this.

      Parameters

      • props: Map<string, string>
      • Optionalclose: boolean

      Returns this

    • Write a Str in modified UTF-8 format according to the java.io.DataOutput specification. This method is paired with InStream.readUtf. Throw IOErr on error. Return this.

      Parameters

      • s: string

      Returns this

    • Write a string to this output stream using XML escape sequences. By default only the < > & characters are escaped. You can use the following flags to escape additional characters:

      Any control character less than 0x20 which is not \t, \n or \r is always escaped with a numeric reference. Return this.

      Parameters

      • str: string
      • Optionalmode: number

      Returns this

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • XML escape newline characters. See writeXml.

      Returns number

    • XML escape single and double quotes. See writeXml.

      Returns number

    • XML escape any character greater then 0x7f. See writeXml.

      Returns number