Granule Code

From DocDataFlow
Revision as of 01:59, 30 December 2013 by Kris (Talk | contribs)

Jump to: navigation, search

The Granule class is the root class from which all granule types are derived.

It has a class identifier of com.rorohiko.granule

Granules are 'constant': once created they don't change. Any 'live' data related to the granule is carried in the associated context data structure.

It has the following methods:

  • granule.getId(): get the unique identifier for this granule.
  • granule.getContext(): retrieve the context for this granule.
  • granule.getData(): retrieve the core data for this granule. In most cases this is a reference to the document-specific data structure for the granule. E.g. if the granule is an InDesignTextFrameGranule, the granule.getData() will retrieve the associated InDesign TextFrame object (or a proxy thereof).
  • granule.getParentGranule(): retrieve the parent granule for this granule. Eventually will lead to an AppGranule - appGranules are the root(s) for the granule hierarchy.
  • granule.comparePosition(sortList, compareWithGranule): return an int (< 0, == 0, > 0) after comparing the granules. The sortList is a linear list of granule sort.