Model

Cog Nodes

When considering a cog as a single object, it is referred to as a node.

Each cog node can have:

  • a name
  • a numeric ID
  • a String GUID
  • a type
  • a data object
  • a parent cog
  • cog children
  • a cog header

All of these are optional and can be null.

The name, id, and guid fields allow for a variety of identification methods when doing lookups.

The type is not required, but allows association of a node with a CogDatatype that can be used to validate it, build GUIs or reports for it, etc.

Generally, the data object is only set for leaf nodes representing primitive values such as a text string, number, or date.

Nodes without parents are considered to be root nodes. Nodes without children are considered to be leaf nodes. Those with both are considered to be branch nodes.

Children are kept in an ordered list, and can be accessed via their name, id, or guid.

The cog header is only present in root nodes.

Cog Graphs

When discussing a cog as a group of interconnected nodes, it is referred to as a graph. Generally the root cog is associated with the entire graph as well as itself.

Cog Paths

Cogs or their data can be accessed at any depth in a graph using Path syntax. The com.partnersoft.v3x.data.structures.Path class is used for this, and you can specify a path using a Path object or a String. The latter is generally simpler, though you may be able to optimize performance-sensitive code or provide more precision by using a Path.

Here is an example:

node = cog.nodeFor(“bibbity/bobbity/boo”);

This would provide the node named boo, a child of the node named bobbity, which is a child of the node named bibbity of the node referred to by the cog variable.

Primitives and Conversion

Simple conversion routines are built into the cog primitive getters and setters.

For example, it is perfectly legal to:

String myString = “10”; cog.putString(“fiddle/faddle/foofoo”, myString); int intValue = cog.getInt(“fiddle/faddle/foofoo”);

Table Of Contents

Previous topic

Principles

Next topic

Coggable

This Page