IRISLIB database
AbstractDocument Class Reference

To implement a new routine type to be used by Studio you subclass from this abstract routine class and fill in the methods to perform your own Load/Save/Compile/Delete/Lock functions. More...

Inheritance diagram for AbstractDocument:
Collaboration diagram for AbstractDocument:

Public Member Functions

_.Library.Status OnNew (_.Library.String name)
 Set the name property.
 
_.Library.Status Clear ()
 Clear the contents of this Stream from permanent storage. More...
 
_.Library.Status Compile (_.Library.String flags)
 Compile the document, with source control hooks.
 
_.Library.Status CompileDocument (_.Library.String qstruct)
 CompileDocument is called when the document is to be compiled. More...
 
_.Library.Status ExportToXML (_.Library.String flags)
 Export this document to the current device in XML format.
 
_.Library.Status Flush ()
 Flush any output in the stream not already saved.
 
_.Library.Status ImportFromXML (_.Library.RegisteredObject stream, _.Library.String flags)
 Passed a stream containing the XML document, this method should insert this. More...
 
_.Library.Status Load ()
 Load the routine in Name into the stream Code.
 
_.Library.Status Lock (_.Library.String flags)
 Lock the current routine. More...
 
_.Library.Status MoveToEnd ()
 Move to the end of the stream so the next <METHOD>Write</METHOD> will be appended to the end. More...
 
_.Library.String Read (_.Library.Integer len, _.Library.Status sc)
 Reads up to len characters from the current position. More...
 
_.Library.String ReadLine (_.Library.Integer len, _.Library.Status sc, _.Library.Boolean eol)
 Read a line from the stream. More...
 
_.Library.Status Rewind ()
 Go back to the start of the stream.
 
_.Library.Status Save ()
 Save the routine stored in Code.
 
_.Library.Status SaveAs (_.Library.String name)
 Save this document with a new name. More...
 
_.Library.Status Unlock (_.Library.String flags)
 Unlock the current routine. More...
 
- Public Member Functions inherited from AbstractStream
_.Library.Status OnClose ()
 This callback method is invoked by the <METHOD>Close</METHOD> method to. More...
 
_.Library.Status CopyFrom (_.Stream.Object source)
 Copies the contents of source into this Stream. More...
 
_.Library.Boolean DeleteAttribute (_.Library.String name)
 Removes this attribute variable from the collection. More...
 
_.Library.String GetAttribute (_.Library.String name, _.Library.String default)
 Retrieves the named attribute value.
 
_.Library.String GetStreamId ()
 Returns an full id value (including class name) with which the Stream implementation has stored. More...
 
_.Library.Boolean IsDefinedAttribute (_.Library.String name)
 Returns true if the named attribute variable exists in the collection, false otherwise.
 
_.Library.Boolean IsNull ()
 Returns true if this is a "NULL" stream; that is, a stream which has never. More...
 
_.Library.String NextAttribute (_.Library.String name)
 Retrieves the next attribute variable name in the sequence, skip any '' names.
 
_.Library.AbstractStream ReadLineIntoStream ()
 This reads from the stream until it find the <property>LineTerminator</property> and returns. More...
 
_.Library.Status SaveStream ()
 Deprecated method, use <method>Save</method> instead. More...
 
 SetAttribute (_.Library.String name, _.Library.String value)
 Inserts an attribute variable by name into the collection.
 
_.Library.Status WriteLine (_.Library.RawString data)
 Appends the string data along with a line terminator to the stream and advances the. More...
 
- Public Member Functions inherited from Object
_.Library.Status AcquireLock (locktype)
 Acquires a lock for the current instance. More...
 
_.Library.Status OnAfterSave (_.Library.Boolean insert)
 This callback method is invoked by the <METHOD>Save</METHOD> method to. More...
 
_.Library.Status OnBeforeSave (_.Library.Boolean insert)
 This callback method is invoked by the <METHOD>Save</METHOD> method to. More...
 
_.Library.Status OnOpen ()
 This callback method is invoked by the <METHOD>Open</METHOD> method to. More...
 
_.Library.Status OnReload ()
 This callback method is invoked by the <METHOD>Reload</METHOD> method to. More...
 
_.Library.Status OnRollBack ()
 This callback method is invoked by the <METHOD>Save</METHOD> method to. More...
 
_.Library.Status CopyFrom (_.Stream.Object source)
 Copies the contents of source into this Stream. More...
 
_.Library.Status CopyFromAndSave (_.Stream.Object source)
 Copy the stream from source into the current stream ignoring anything already in the current stream. More...
 
_.Library.Integer FindAt (_.Library.Integer position, _.Library.RawString target, _.Library.RawString tmpstr, _.Library.Boolean caseinsensitive)
 Find the first occurrence of target in the stream, starting the search at position. More...
 
_.Library.Status InputFromDevice (_.Library.Integer len, _.Library.Integer timeout)
 Input len characters from the current device into the stream. More...
 
_.Library.Boolean MoveTo (_.Library.Integer position)
 Move to this position in the stream. More...
 
_.Library.Status OutputToDevice (_.Library.Integer len)
 Write out len characters of the stream to the current device starting from the current position. More...
 
_.Library.Status OutputToDeviceAt (_.Library.Integer position, _.Library.Integer length)
 Output the stream to the current device starting at position of length. More...
 
_.Library.String ReadSQL (_.Library.Integer start, _.Library.Integer end)
 SQL specific method for reading stream data.
 
_.Library.Status SerializeToSyncSet (_.SYNC.SyncSet ss, _.Library.Integer iPtr, _.Library.String property)
 SerializeToSyncSet copies the stream value from the current object to the sync set global. More...
 
_.Library.Status SyncStreamIn (_.SYNC.SyncSet ss, _.Library.Integer iPtr, _.Library.String property)
 SyncStreamIn copies the stream value from the sync set global into the current object.
 
_.Library.Status Write (_.Library.RawString data)
 Appends the string data to the stream and advances the. More...
 
_.Library.Status WriteLine (_.Library.RawString data)
 Appends the string data along with a line terminator to the stream and advances the. More...
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 

Static Public Member Functions

_.Library.TimeStamp CompileTime (_.Library.String name)
 Return the compile time of routine 'name' in TimeStamp format. More...
 
_.Library.Status Delete (_.Library.String name)
 Delete the routine 'name' which includes the routine extension.
 
_.Library.Boolean Exists (_.Library.String name)
 Return 1 if the routine 'name' exists and 0 if it does not.
 
_.Library.String GetOther (_.Library.String Name)
 Return other document types that this is related to. More...
 
_.Library.String GetPrevious (_.Library.String Name)
 Return other document types that this is related to. More...
 
_.Library.Boolean IsEnabled ()
 Returns true if this document type is enabled, and false to disable it.
 
_.Library.Boolean IsGenerated (_.Library.String name)
 Return true if this is generated and zero otherwise. More...
 
_.Library.Boolean IsMapped (_.Library.String name, _.Library.String sourcedb)
 Return true if this is mapped from a database other than the default routine database and zero otherwise. More...
 
_.Library.Boolean IsUpToDate (_.Library.String name)
 Return true if the document is up to date with respect to the compiled version, i.e. More...
 
_.Library.Status ItemList (_.Library.Integer Idx, _.Library.String Ext, _.Library.String Work, _.Library.String Start, _.Library.String End, _.Library.String Directory, _.Library.Integer Sort, _.Library.Boolean System, _.Library.Boolean Flat, _.Library.Boolean ShowGenerated, _.Library.Boolean NewFormat)
 This method ties into the open dialog in Studio. More...
 
_.Library.Status LockName (_.Library.String name)
 Lock a document by name. More...
 
 Search (_.Library.String Name, _.Library.String Pattern, _.Library.Boolean WholeWords, _.Library.Boolean CaseSensitive, _.Library.Integer Max, _.Library.Integer Found)
 Override this to support searching inside your document type. More...
 
 SearchRegex (_.Library.String Name, _.Regex.Matcher Matcher, _.Library.Integer Max, _.Library.Integer Found)
 Override this to support searching inside your document type with a regular expression. More...
 
_.Library.TimeStamp TimeStamp (_.Library.String name)
 Return the timestamp of routine 'name' in TimeStamp format. More...
 
_.Library.Status TranslateExportName (_.Library.String name, _.Library.String items)
 Can be used to translate the type of document to be exported to XML. More...
 
_.Library.Status UnlockName (_.Library.String name)
 Unlock a document by name. More...
 
- Static Public Member Functions inherited from AbstractStream
_.Library.Status DeleteStream (_.Library.ObjectIdentity oid, _.Library.Integer concurrency)
 Deprecated method, use <method>Delete</method> instead. More...
 
- Static Public Member Functions inherited from Object
_.Library.String GetLockReference (_.Library.String pLocation, _.Library.String pId)
 Returns the global reference used to lock the current stream object. More...
 
_.Library.Status OnDelete (_.Library.ObjectIdentity oid)
 This callback method is invoked by the <METHOD>Delete</METHOD> method to. More...
 
_.Library.String IsCharacter ()
 Return true if this is a character stream and false if it is a binary stream.
 
_.Library.Boolean StreamOIDIsNull (_.Library.ObjectIdentity soid)
 Return true if this stream oid is a null stream and false if the stream is not null.
 

Public Attributes

 Code
 The body of the routine is held in this stream. More...
 
 CompileTime
 Timestamp of the last compile of this document. More...
 
 Generated
 True if this routine is generated from something else. More...
 
 Locked
 Used to hold the number of times this document is locked. More...
 
 Name
 The name of this routine, this includes the routine extension. More...
 
 TimeStamp
 Timestamp of the current document. More...
 
 UpToDate
 Return true if the document is up to date with respect to the compiled version, i.e. More...
 
- Public Attributes inherited from AbstractStream
 Attributes
 An array of strings containing any attribute values associated with this stream. More...
 
 LineTerminator
 Type of line terminator we use for this stream, defaults to Cr/Lf. More...
 
- Public Attributes inherited from Object
 AtEnd
 The AtEnd property is set to true (1) when, during a read,. More...
 
 LastModified
 LastModified is a read-only property containing the <class>TimeStamp</class> of More...
 
 Size
 Size is a read-only property containing the current size of the stream (in bytes More...
 

Static Public Attributes

 Delimiter = None
 Delimiter to use when constructing directories for this document type. More...
 
- Static Public Attributes inherited from AbstractStream
 MAXLEN = None
 The maximum number of characters (or bytes) allowed in a stream.
 
 PROPERTYVALIDATION = None
 Turns off property validation.
 
- Static Public Attributes inherited from Object
 DEFAULTCONCURRENCY = None
 
- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 

Static Private Member Functions

_.Library.Boolean __checkMatch (_.Library.String value, _.Library.String Pattern, _.Library.Boolean WholeWords, _.Library.Boolean CaseSensitive)
 Helper method for <method>Search</method>. More...
 
_.Library.String __escapeCData (_.Library.String data)
 Utility method to quote any ']]>' inside the code as these end the CDATA section.
 
 __escapeCDataStream (_.Stream.Object stream)
 Utility method to escape any ']]>' inside a CDATA section.
 
_.Library.String __unescapeCData (_.Library.String data)
 Utility method to quote any ']]>' inside the code as these end the CDATA section.
 

Detailed Description

To implement a new routine type to be used by Studio you subclass from this abstract routine class and fill in the methods to perform your own Load/Save/Compile/Delete/Lock functions.

Member Function Documentation

◆ Clear()

_.Library.Status Clear ( )

Clear the contents of this Stream from permanent storage.

This will remove the permanent stream storage and

any temporary stream and initialise the stream to its initial state, including removing all the stream attributes.

Returns a <CLASS>Status</CLASS> value indicating success or failure.

Reimplemented from Object.

◆ CompileDocument()

_.Library.Status CompileDocument ( _.Library.String  qstruct)

CompileDocument is called when the document is to be compiled.

It has already called the source control hooks at this point.

Reimplemented in StudioRoutines.

◆ CompileTime()

_.Library.TimeStamp CompileTime ( _.Library.String  name)
static

Return the compile time of routine 'name' in TimeStamp format.

The format should be $zdatetime($horolog,3),

or "" if the routine does not exist.

Reimplemented in FolderItemDocument.

◆ GetOther()

_.Library.String GetOther ( _.Library.String  Name)
static

Return other document types that this is related to.

Passed a name and you return a comma separated list of the other documents it is related to or "" if it is not related to anything. Note that this can be passed a document of another type for example if your 'test.XXX' document creates a 'test.INT' routine then it will also be called with 'test.INT' so you can return 'test.XXX' to complete the cycle.

Reimplemented in AbstractDocument, and StudioRoutines.

◆ GetPrevious()

_.Library.String GetPrevious ( _.Library.String  Name)
static

Return other document types that this is related to.

Passed a name and you return a comma separated list of the other documents it is related to or "" if it is not related to anything. This goes in opposite direction to <method>GetOther</method> function. It can be called with documents that are not of this document type as with <method>GetOther</method>.

◆ ImportFromXML()

_.Library.Status ImportFromXML ( _.Library.RegisteredObject  stream,
_.Library.String  flags 
)

Passed a stream containing the XML document, this method should insert this.

into the current document. Once this is done the importer will call Save on the document. This default handler in assumes the export <method>ExportToXML</method> just wrote the data in a CDATA structure

Reimplemented in FolderItemDocument.

◆ IsGenerated()

_.Library.Boolean IsGenerated ( _.Library.String  name)
static

Return true if this is generated and zero otherwise.

Default implementation opens instance to find the property value, it is much more efficient to override this to provide a better implementation.

◆ IsMapped()

_.Library.Boolean IsMapped ( _.Library.String  name,
_.Library.String  sourcedb 
)
static

Return true if this is mapped from a database other than the default routine database and zero otherwise.

Also set the source database in sourcedb.

◆ IsUpToDate()

_.Library.Boolean IsUpToDate ( _.Library.String  name)
static

Return true if the document is up to date with respect to the compiled version, i.e.

if you recompiled this document

then the generated compiled code would be the same. Return false if the source document is modified but not compiled or the generated code has been modified manually.

◆ ItemList()

_.Library.Status ItemList ( _.Library.Integer  Idx,
_.Library.String  Ext,
_.Library.String  Work,
_.Library.String  Start,
_.Library.String  End,
_.Library.String  Directory,
_.Library.Integer  Sort,
_.Library.Boolean  System,
_.Library.Boolean  Flat,
_.Library.Boolean  ShowGenerated,
_.Library.Boolean  NewFormat 
)
static

This method ties into the open dialog in Studio.

It is passed a list of information based on the search criteria from the user and it should populate the ^||RoutineList(Idx) global with the items it wishes to show in the following format:

^||RoutineList(Idx,dirtype,order_$char(0)_index)=$listbuild(name,dirsymbol,type,size,date/time,description)

  • Idx - The index provided in the 'Idx' parameter
  • dirtype - This is 1 if this is a regular openable item and 0 if this is a directory so that directories show up before the other items in the open dialog
  • order - The value based on the sorting order of items, e.g. size or date/time last modified, more information on this below
  • index - An integer index to prevent multiple items with for example the same size from over writing each other.
  • name - The name to display in the open dialog
  • dirsymbol - The symbol to use to navigate directories, for regular items this is "" but for directories this should be the character to append to the directory in order to browse into this directory. Do not use '/' or '\' as these are reserved for CSP files
  • type - This is an integer version of the type of the item, see the list below for details
  • size - The size of this item as an integer
  • date/time - The date/time this item was last modified in TimeStamp format, or "" if not known

The type of the item which can be one of:

  • 0 - MAC file, a routine containing macros
  • 1 - INT file, a standard routine
  • 2 - INC file, an include file
  • 3 - BAS file, a Cache Basic routine
  • 4 - CLS, a class
  • 5 - CSP, a Cache Server Page or another file in this directory
  • 7 - GBL, a Global
  • 8 - PRJ, a Project
  • 9 - a Package
  • 10 - a CSP application

Further numbers are reserved for future use. User defined items should start at 100.

order is one of:

  • 1 - Name of the file non case sensitive (the default)
  • 2 - Date/Time the file was saved
  • 3 - Size of the file
  • 4 - Type of the file i.e. the number from the 'type' list
  • 5 - Name of the file case sensitive

.

The arguments to this method are:

  • Idx - Index into ^||RoutineList to write data
  • Ext - Extension name we are processing
  • Work - Array of pattern match information that we test each item against, root node is $listbuild(mapped) so you can see if we want to return mapped items
  • Start - First possible match, can be used to optimise the query
  • End - Last possible match, can be used to optimise the query
  • Directory - The directory name we are searching
  • Sort - The entry to sort by, same as the list for 'order'
  • System - If true then include the '' routines/classes
  • Flat - If true then flatten directories to return items inside them, this is used by the 'Namespace' tab in Studio to display all items in the system
  • ShowGenerated - If false then do not show items generated from something else, e.g. do not show TEST.INT if this is compiled from TEST.MAC
  • NewFormat - Returned by reference, if set to true use the new ^||RoutineList format, else caller will convert output to the new format

Reimplemented in StudioRoutines.

◆ Lock()

Lock the current routine.

The default method just locks the ^ROUTINE global with the name of the routine.

If it fails then return a status code of the error, otherise return $$$OK

◆ LockName()

_.Library.Status LockName ( _.Library.String  name)
static

Lock a document by name.

The default method just locks the ^ROUTINE global with the name of the document.

◆ MoveToEnd()

_.Library.Status MoveToEnd ( )

Move to the end of the stream so the next <METHOD>Write</METHOD> will be appended to the end.

This allows you to read from a stream, then MoveToEnd() and append new data, where just calling <METHOD>Write</METHOD> after a read will clear the stream before writing new data.

Returns a <CLASS>Status</CLASS> value indicating success or failure.

Reimplemented from AbstractStream.

◆ Read()

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 <method>Read</method> will return a null string (""). If no len is passed in, ie. '<method>Read</method>()' 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 <method>Rewind</method> if you want to read a stream from the beginning again. Calling <method>Read</method> after <method>Write</method> implicitly ends the <method>Write</method> 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.

Reimplemented from Object.

◆ ReadLine()

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 <method>Status</method> 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 ! } }

Reimplemented from Object.

◆ SaveAs()

Save this document with a new name.

You may want to modify this depending on how this implementation will work for your class.

◆ Search()

Search ( _.Library.String  Name,
_.Library.String  Pattern,
_.Library.Boolean  WholeWords,
_.Library.Boolean  CaseSensitive,
_.Library.Integer  Max,
_.Library.Integer  Found 
)
static

Override this to support searching inside your document type.

By default it will open the document and search the <property>Code</property>.

  • Name - Name of document to search
  • Pattern - String to search for
  • WholeWords - True if we only want to find whole words, false otherwise
  • CaseSensitive - True if this is a case sensitive search
  • Max - The maximum number of items to find, if we get to this limit stop outputting results and return
  • Found - Passed by reference, contains a count of the number of matches we find. Increment by one for each match

When a match is found write out the match to the current device using the format

<CrLf><Name>(<Line offset>): <Match line>

◆ SearchRegex()

SearchRegex ( _.Library.String  Name,
_.Regex.Matcher  Matcher,
_.Library.Integer  Max,
_.Library.Integer  Found 
)
static

Override this to support searching inside your document type with a regular expression.

By default it will open the document and search the <property>Code</property>.

  • Name - Name of document to search
  • Matcher - A <class>Regex.Matcher</class> object initialised with the search expression
  • Max - The maximum number of items to find, if we get to this limit stop outputting results and return
  • Found - Passed by reference, contains a count of the number of matches we find. Increment by one for each match

When a match is found write out the match to the current device using the format

<CrLf><Name>(<Line offset>): <Match line>

◆ TimeStamp()

Return the timestamp of routine 'name' in TimeStamp format.

This is used to determine if the routine has

been updated on the server and so needs reloading from Studio. So the format should be $zdatetime($horolog,3), or "" if the routine does not exist.

Reimplemented in AbstractDocument, StudioRoutines, and FolderItemDocument.

◆ TranslateExportName()

_.Library.Status TranslateExportName ( _.Library.String  name,
_.Library.String  items 
)
static

Can be used to translate the type of document to be exported to XML.

For example if asked to export 'abc.tst' it can:

Set items("User.abc.cls")=""

Which will cause the XML export to export the class User.abc instead of this abc.tst document. Default behavior is to export the regular document.

◆ Unlock()

Unlock the current routine.

The default method just unlocks the ^ROUTINE global with the name of the routine.

◆ UnlockName()

_.Library.Status UnlockName ( _.Library.String  name)
static

Unlock a document by name.

The default method just unlocks the ^ROUTINE global with the name of the document.

◆ __checkMatch()

_.Library.Boolean __checkMatch ( _.Library.String  value,
_.Library.String  Pattern,
_.Library.Boolean  WholeWords,
_.Library.Boolean  CaseSensitive 
)
staticprivate

Helper method for <method>Search</method>.

Check if this really matches the item we are searching for.

Member Data Documentation

◆ Delimiter

Delimiter = None
static

Delimiter to use when constructing directories for this document type.

This only applies if you write the List query. If you override the <method>ItemList</method> then you must insert this into ^IRIS.Temp structure yourself. Note do not use '/' or '\' as a delimiter as these are reserved for CSP files.

◆ Code

Code

The body of the routine is held in this stream.

 

◆ CompileTime

CompileTime

Timestamp of the last compile of this document.

 

◆ Generated

Generated

True if this routine is generated from something else.

 

◆ Locked

Locked

Used to hold the number of times this document is locked.

It happens to be used by the default lock implementation but you may ignore this in your subclass if you wish.  

◆ Name

Name

The name of this routine, this includes the routine extension.

 

◆ TimeStamp

Timestamp of the current document.

 

◆ UpToDate

UpToDate

Return true if the document is up to date with respect to the compiled version, i.e.

if you recompiled this document

then the generated compiled code would be the same. Return false if the source document is modified but not compiled or the generated code has been modified manually.