Package com.partnersoft.cog

A generic, yet complex, data structure.

See: Description

Package com.partnersoft.cog Description

A generic, yet complex, data structure.

Cogs are designed to store the many types of "payload" data encountered in a system. This data is typically just a record-like structure (named values), but may consist of lists or nested hierarchies. The primitive data stored within is often of indeterminate type, so conversions between e.g. string and numeric types need to be easy.

Cog is also designed to be simple and natural to use from a script, and to remove a lot of the bulk code required to build complex objects. It is designed to be flexible and forgiving, rather than strict and rigid.

Cogs can be used in two major ways. The first is "untyped", where there is no schema or assigned type for the Cog's nodes. Untyped cogs can be used for temporary or casual data storage, or for cases when (e.g. loading old files for backwards compatibility) you don't want to apply validation rules to the data.

"Typed" cogs, on the other hand, have a CogSchema and a data type associated with them. This data type describes the cog's organization and metadata, such as the defined fields for a structure, the allowed contents for a list, etc. It contains user-oriented items such as field labels and descriptions, and also contains validation rules that can be run on the data.

Cogs consist of Cog nodes, connected together in a hierarchy, doubly-linked so that you can traverse both up and down the structure. Cogs can be treated as primitives (leaf nodes), as lists or associations, or as structures, depending on need and upon the data type.

An optional CogHeader is defined only for the root Cog in a structure; this contains pointers to the schema and maintains event listeners and dispatch.

Cogs fit very naturally into XML format, since the nodes form hierarchical documents. CogXmlLib provides simple reading and writing methods for this format.

Cogs intentionally form a separate, language- and platform-independent typing and data modelling system from Java. Cogs are readable from other platforms, and the type and metadata associated with them are expressed in generic terms. However, it is also useful to use Cog as a serialization method for Java, and direct support for this is provided via the Coggable interface.

Copyright 2006-2009 Partner Software, Inc.

Author:
Paul Reavis, Russell Cagle