Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


libtf:documentation:api:persistentobject

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
libtf:documentation:api:persistentobject [2018/02/24 18:45] leelibtf:documentation:api:persistentobject [2018/09/24 17:15] (current) – removed lee
Line 1: Line 1:
-[[libtf:documentation:api:start|<-- Back]] 
- 
- 
-====== LibTF.PersistentObject ====== 
- 
-Blurb. 
- 
- 
-===== Fields ===== 
- 
-==== (PersistentObject).id ==== 
- 
-  * Getter: Returns the persistence id of this object. 
-  * Setter: None. 
- 
- 
-==== (PersistentObject).parentId ==== 
- 
-  * Getter: Returns the persistence id of this object's parent, or null if it doesn't have a parent. 
-  * Setter: None. 
- 
- 
-==== (PersistentObject).parent ==== 
- 
-  * Getter: Returns fully instantiated parent of this object. 
-  * Setter: None. 
- 
- 
-===== Methods ===== 
- 
-==== (PersistentObject).hasPersistent( subid ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * Returns: True if there is a record for the specified child data on this object, or False if there is not. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Checks to see if there is child data for the given //subid// available for this object. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code> 
-if( tfGet("joe").hasPersistent("lastName") ) 
- alert( "Joe has a lastName child field!" ); 
-</code> 
- 
- 
-==== (PersistentObject).getPersistent( subid ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * Returns: The specified child data from this object, or null if there is none. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Returns the child data for the given //subid// on this object. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code> 
-alert( "Joe's last name is " + tfGet("joe").getPersistent("lastName") + "!" ); 
-</code> 
- 
- 
-==== (PersistentObject).setPersistent( subid, value ) ==== 
- 
-  * //subid// is a persistence id fragment referring to some child data record for this object. 
-  * //value// is what to set that child data to. 
-  * Returns: Nothing, but that is a bug and it ought to return the previous value. 
-  * Throws: Error if: subid contains invalid characters. 
- 
-Sets the child data for the given //subid// on this object to //value//. 
- 
-//This method is generally only used internally by derived classes.  You probably won't need to use this method unless you are actually extending the library itself.// 
- 
-<code> 
-tfGet("joe").setPersistent( "lastName", "Josephson" ); 
-</code> 
-  
-<code> 
- this.resetPersistent = function( subid ) 
- { 
- if( subid == null ) 
- throw "Null id!"; 
- return Persistence.reset( id+"."+subid ); 
- } 
-</code> 
-      
-<code> 
-     this.getName = function() 
-     { 
-     if( this.hasPersistent("name") ) 
-     return this.getPersistent("name"); 
-     return null; 
-     } 
-</code> 
-      
-<code> 
- this.getAName = function() 
- { 
- var name = this.getName(); 
- if( this.getPersistent("nameIsProper") || name.charAt(0) == name.charAt(0).toUpperCase() ) 
- return name; 
- if( this.hasPersistent("nameIrregularArticle") ) 
- return this.getPersistent("nameIrregularArticle")+" "+name; 
- switch( name.charAt(0) ) 
- { 
- case 'a': 
- case 'e': 
- case 'i': 
- case 'o': 
- case 'u': 
- return "an " + name; 
- default: 
- return "a " + name; 
- } 
- } 
-</code> 
- 
-[[libtf:documentation:api:start|<-- Back]] 
  
libtf/documentation/api/persistentobject.1519526705.txt.gz · Last modified: 2018/02/24 18:45 by lee