This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
libtf:documentation:api:persistentobject [2018/02/25 08:51] – [(PersistentObject).aName] lee | libtf:documentation:api:persistentobject [2018/09/24 17:15] (current) – removed lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[libtf: | ||
- | |||
- | |||
- | ====== LibTF.PersistentObject ====== | ||
- | |||
- | The PersistentObject is the class from which all of the more complex persistent data types are derived. | ||
- | |||
- | Deriving types and classes in this way allows us to present a more straightforward API to the end-user of the library, saving them the headache of dealing directly with the Persistence API. | ||
- | |||
- | PersistentObjects use getters and setters to make the complex id-tagged persistence calls look like simple field accesses, to the end-user of the library. | ||
- | |||
- | ===== Fields ===== | ||
- | |||
- | ==== (PersistentObject).id ==== | ||
- | |||
- | * **Access:** Read-Only. | ||
- | * **Type:** String. | ||
- | |||
- | The persistence id of the object. | ||
- | |||
- | //Most of the time you'll only be interacting with the persistence id when you define your object at initialization time in Persistence.setDefaults(), | ||
- | |||
- | |||
- | ==== (PersistentObject).parentId ==== | ||
- | |||
- | * **Access:** Read-Only. | ||
- | * **Type:** String. | ||
- | |||
- | The persistence id of the object' | ||
- | |||
- | //This field is generally only used internally by derived classes. | ||
- | |||
- | |||
- | |||
- | ==== (PersistentObject).parent ==== | ||
- | |||
- | * **Access:** Read-Only. | ||
- | * **Type:** A PersistentObject, | ||
- | |||
- | The fully instantiated parent of this object. | ||
- | |||
- | //This field is generally only used internally by derived classes. | ||
- | |||
- | |||
- | ==== (PersistentObject).name ==== | ||
- | |||
- | * **Access:** Read-Write. | ||
- | * **Type:** String. | ||
- | |||
- | The display name of the object, without any article. | ||
- | |||
- | <code javascript> | ||
- | var someDude = tfGet(" | ||
- | alert( " | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).aName ==== | ||
- | |||
- | * **Access:** Read-Only. | ||
- | * **Type:** String. | ||
- | |||
- | The display name of the object, with the correct article prepended. | ||
- | |||
- | If the first character of the //.name// field is capitalized, | ||
- | |||
- | These rules do not always work. For example, "an honorable man" or "a European swallow" | ||
- | |||
- | <code javascript> | ||
- | alert( "You are carrying " + tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).nameIsProper ==== | ||
- | |||
- | * **Access:** Read-Write. | ||
- | * **Type:** Boolean. | ||
- | |||
- | Set this field to True to suppress the printing of an article in the //.aName// field. | ||
- | |||
- | // | ||
- | |||
- | <code javascript> | ||
- | var book = tfGet(" | ||
- | // book.name is " | ||
- | // With the " being the first character, it won't be recognized as proper. | ||
- | // So .aName will return: a "Atlas Shrugged" | ||
- | book.nameIsProper = true; | ||
- | // Now .aName will properly return just: "Atlas Shrugged" | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).nameIrregularArticle ==== | ||
- | |||
- | * **Access:** Read-Write. | ||
- | * **Type:** String. | ||
- | |||
- | Set this field to override the default article choice in // | ||
- | |||
- | // | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ===== Methods ===== | ||
- | |||
- | ==== (PersistentObject).hasPersistent( subid ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **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. | ||
- | |||
- | <code javascript> | ||
- | if( tfGet(" | ||
- | alert( "Joe has a lastName child field!" | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).getPersistent( subid ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns: | ||
- | * **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. | ||
- | |||
- | <code javascript> | ||
- | alert( " | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).setPersistent( subid, value ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **// | ||
- | * **Returns: | ||
- | * **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. | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).resetPersistent( subid ) ==== | ||
- | |||
- | * **Arguments: | ||
- | * **// | ||
- | * **Returns**: | ||
- | * **Throws**: Error if: subid contains invalid characters. | ||
- | |||
- | Resets the child data for the given //subid// on this object to whatever was defined in Persistence.setDefaults(). | ||
- | |||
- | //This method is generally only used internally by derived classes. | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | [[libtf: | ||