Home > Class Reference > %SYS namespace > %Library.AbstractStream

%Library.AbstractStream

abstract stream class %Library.AbstractStream extends %Stream.Object

Deprecated class, the base stream class is %Stream.Object. This is kept for legacy reasons.

A stream represents an arbitrary array of characters (or bytes) and a current position. The basic stream interface provides the ability to read data from a stream, write data to the stream, and rewind the current position to the beginning of the stream.

Within InterSystems IRIS streams are used to create large (greater than 32K) object attributes.

Property Inventory (Including Private)

Method Inventory (Including Private)

Parameters

parameter MAXLEN = 2147483647;
The maximum number of characters (or bytes) allowed in a stream.
parameter MAXLOCALSIZE = 32000;
parameter PROPERTYVALIDATION = 0;
Turns off property validation.
final parameter READCHANGED = 2;
final parameter READNODATA = 0;
final parameter READNOTCHANGED = 1;
final parameter WRITE = 3;

Properties (Including Private)

property Attributes as %String [ MultiDimensional ];
An array of strings containing any attribute values associated with this stream.
Property methods: AttributesDisplayToLogical(), AttributesGet(), AttributesIsValid(), AttributesLogicalToDisplay(), AttributesLogicalToOdbc(), AttributesNormalize(), AttributesSet()
property LineTerminator as %String (MAXLEN = 10) [ InitialExpression = $char(13,10) ];
Type of line terminator we use for this stream, defaults to Cr/Lf. Maximum length is 10 characters. This is stored as an attribute of the stream called 'LineTerminator'.
Property methods: LineTerminatorDisplayToLogical(), LineTerminatorGet(), LineTerminatorIsValid(), LineTerminatorLogicalToDisplay(), LineTerminatorLogicalToOdbc(), LineTerminatorNormalize(), LineTerminatorSet()
property Mode as %Integer [ Private , InitialExpression = 0 ];
Property methods: ModeDisplayToLogical(), ModeGet(), ModeIsValid(), ModeLogicalToDisplay(), ModeNormalize(), ModeSet()

Methods (Including Private)

private classmethod %DeleteData(soid As %String, concurrency As %Integer) as %Status [ Language = objectscript ]
private method %GetSerial(force As %Integer = 0) as %String [ Language = objectscript ]
method %Id() as %String [ Language = objectscript ]
Returns the persistent object Id, if there is one, of this object.

Returns a null string if there is no object Id.

method %IsModified() as %Integer [ Language = objectscript ]
Inherited description: Returns true (1) if a property of this instance has been modified, otherwise false (0). A TRUE result does not necessarily mean that any property has actually been changed. If %IsModified() returns false then the object has not been modified. There are some situations where we simply cannot efficiently detect a change in value. In these cases we will set the modified status of the property.
method %IsNull() as %Boolean [ Language = objectscript ]
Returns true if this is a "NULL" stream; that is, a stream which has never been written to and saved. This is used by the InterSystems IRIS ODBC server.
private method %Load(sid As %String) as %Status [ Language = objectscript ]
private method %LoadData(serialized As %String) as %Status [ Language = objectscript ]
method %ObjectModified() as %Integer [ Language = objectscript ]
Inherited description: This method is somewhat similar to %IsModified but it also checks to see if swizzled references would cause the object to become modified should they be serialized. This works on the assumption that a reference to a persistent object will never be modified if the ID has already been assigned. For references to serial objects, a call to %ObjectModified indicates whether or not the serialized value is different. If the reference to a swizzled object is different from the initial object state then the $$$objModAll macro will already return true. Reference the Set code. Returns true (1) if this instance has been modified, otherwise false (0).
private method %OnClose() as %Status [ Language = objectscript ]
Inherited description: This callback method is invoked by the %Close() method to provide notification that the current object is being closed.

The return value of this method is ignored.

private method %OnNew(initval As %String = "") as %Status [ Language = objectscript ]
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

private method %SaveData(ByRef sid As %String) as %Status [ Language = objectscript ]
private method %SetSerial(serialized As %String) as %Status [ Language = objectscript ]
method CopyFrom(source As %Stream.Object) as %Status [ Language = objectscript ]
Copies the contents of source into this Stream.

For example, you can copy oldstream into a new stream:

  Set newstream=##class(%GlobalCharacterStream).%New()
  Do newstream.CopyFrom(oldstream)
  

Returns a %Status value indicating success or failure.

final method DeleteAttribute(name As %String) as %Boolean [ Language = objectscript ]
Removes this attribute variable from the collection. Returns true is it existed and false if it did not exist.
classmethod DeleteStream(oid As %ObjectIdentity, concurrency As %Integer = 0) as %Status [ Language = objectscript ]
Deprecated method, use %Delete() instead. Deletes the stored stream identified by oid. This will not remove the stream attributes of any saved streams, it will just remove the stream data. If you need to clear the attributes as well you will have to call Clear() on the stream object.
method Flush() as %Status [ Language = objectscript ]
Inherited description: Flush any output in the stream not already saved.
final method GetAttribute(name As %String, default As %String = "") as %String [ Language = objectscript ]
Retrieves the named attribute value
method GetAttributeList() as %String [ Language = objectscript ]
method GetStreamId() as %String [ Language = objectscript ]
Returns an full id value (including class name) with which the Stream implementation has stored the stream.
private classmethod IODeleteStream(sid As %String, concurrency As %Integer = 0) as %Status [ Language = objectscript ]
Delete the storage for the stream identified by sid.
private method IOFlush() as %Status [ Language = objectscript ]
private method IOGetSize() as %Integer [ Language = objectscript ]
Return the current size of the data stream.
private method IOGetStreamId() as %String [ Language = objectscript ]
Return the id for a stream; that is, an identifier that can later be used to open the same stream.
private method IOInit() [ Language = objectscript ]
Initialize member variable used by the StreamAdaptor. This This is called when the containing stream is opened via %SetSerial.
private method IOMoveToEnd() as %Status [ Language = objectscript ]
Move to the end of the stream and set ourselves to #WRITE mode so the next IOWriteData() will append data to the stream.
private method IOOnClose() as %Status [ Language = objectscript ]
Perform any clean up required by the StreamAdaptor. This is called by the containing stream's %OnClose method.
private method IOOnNew(initval As %String = "") as %Status [ Language = objectscript ]
Perform any initialization required by the StreamAdaptor. This is called by the containing stream's %OnNew method.
private method IOOpenStream(sid As %String) as %Status [ Language = objectscript ]
Open the stream identified by sid.
private method IOReadData(ByRef len As %Integer, ByRef sc As %Status) as %String [ Language = objectscript ]
Reads up to len characters from the current position in the stream. The current position is advanced by the number of characers read. Upon exit, len is set to the actual number of characters read. If a read occurs when the stream position is at the end of the stream, len will be set to 0 and IOReadData() will return a null string ("").

Returns a string up to len characters long.

private method IORewind() as %Status [ Language = objectscript ]
private method IOSaveStream() as %Status [ Language = objectscript ]
Write the stream to storage.
private method IOWriteData(data As %String) as %Status [ Language = objectscript ]
Writes data to the stream at the current location.
final method IsDefinedAttribute(name As %String) as %Boolean [ Language = objectscript ]
Returns true if the named attribute variable exists in the collection, false otherwise
method IsNull() as %Boolean [ Language = objectscript ]
Returns true if this is a "NULL" stream; that is, a stream which has never been written to and saved. This is used by the InterSystems IRIS ODBC server.
method LineTerminatorSet(terminator As %String) as %Status [ Language = objectscript ]
method MoveToEnd() as %Status [ Language = objectscript ]
Inherited description: Move to the end of the stream so the next Write will be appended to the end. This allows you to read from a stream, then MoveToEnd() and append new data, where just calling Write() after a read will clear the stream before writing new data.

Returns a %Status value indicating success or failure.

final method NextAttribute(name As %String) as %String [ Language = objectscript ]
Retrieves the next attribute variable name in the sequence, skip any '%' names
method OpenStream(sid As %String) as %Status [ Language = objectscript ]
method Read(ByRef len As %Integer = 32656, ByRef sc As %Status) as %RawString [ Language = objectscript ]
Inherited description: Reads up to len characters from the current position in the stream. The current position is advanced by the number of characters read. Upon exit, len is set to the actual number of characters read. If a read occurs when the stream position is at the end of the stream, len will be set to -1 and Read() will return a null string (""). If no len is passed in, ie. 'Read()()' then it is up to the Read implementation as to how much data to return. Some stream classes use this to optimize the amount of data returned to align this with the underlying storage of the stream.

You must call Rewind() if you want to read a stream from the beginning again. Calling Read() after Write() implicitly ends the Write() operation and rewinds to the start of the stream.

Returns a string up to len characters long. The byref argument sc will return a %Status if any error occurred during the read.

method ReadLine(ByRef len As %Integer = 32000, ByRef sc As %Status, ByRef eol As %Boolean) as %RawString [ Language = objectscript ]
Inherited description: Read a line from the stream. This will look for the line terminator in the stream and once it finds the terminator it will return the string minus the terminator character/s. If it reaches the end of the stream before it finds a terminator it will return the data it has so far, and if you specify a maximum size in len it will only read up to this number of characters. On exit len will contain the actual number of characters read. The byref argument sc will return a %Status() if any error occured during the read and the byref argument eol is true if it found the line terminator and false otherwise. So for example you can read in a stream a line at a time and output the results to the current device with:
While 'stream.AtEnd { Write stream.ReadLine(,.sc,.eol) If $$$ISERR(sc) { Write "ERROR" Quit } If eol { Write ! } }
method ReadLineIntoStream(ByRef sc As %Library.Status) as %AbstractStream [ Language = objectscript ]
This reads from the stream until it find the LineTerminator and returns this as a stream. If the stream does not contain the line terminator this can potentially be the entire stream.
method Rewind() as %Status [ Language = objectscript ]
Inherited description: Go back to the start of the stream.
method SaveStream() as %Status [ Language = objectscript ]
Deprecated method, use %Save() instead. Saves the temporary copy of the stream data to a persistent location. Note that any locking or transaction handling must be done by the caller.

Returns a %Status value indicating success or failure.

final method SetAttribute(name As %String, value As %String) [ Language = objectscript ]
Inserts an attribute variable by name into the collection
method SetAttributeList(attr As %String) [ Language = objectscript ]
method SizeGet() as %Integer [ Language = objectscript ]
method Write(data As %RawString = "") as %Status [ Language = objectscript ]
Inherited description: Appends the string data to the stream and advances the current stream position by the number of characters in data.

Note that a write operation immediately following a read or rewind will clear out the existing data in the stream.

Returns a %Status value indicating success or failure.

method WriteLine(data As %RawString = "") as %Status [ Language = objectscript ]
Appends the string data along with a line terminator to the stream and advances the current stream position by the number of characters in data plus the line terminator.

Returns a %Status value indicating success or failure.

Inherited Members

Inherited Properties (Including Private)

Inherited Methods (Including Private)

Subclasses

FeedbackOpens in a new window