Difference between revisions of "Granule Code"

From DocDataFlow
Jump to: navigation, search
Line 3: Line 3:
 
It has a [[Class identifier|''class identifier'']] of <code>com.rorohiko.granule</code>
 
It has a [[Class identifier|''class identifier'']] of <code>com.rorohiko.granule</code>
  
Granules are 'constant': once created they don't change. Any 'live' data related to the granule is carried in the associated [[Context|''context'']] or meta-data structures.
+
Granules are 'constant': once created they don't change. Any 'live' data related to the granule is carried in the associated [[Context|''context'']] or associated meta-data structures.
  
 
It has the following methods:
 
It has the following methods:

Revision as of 02:09, 30 December 2013

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 or associated meta-data structures.

It has the following methods:

  • granule.comparePosition(orderingList, compareWithGranule): return an int (< 0, == 0, > 0) after comparing the granules. The orderingList is a linear list of granule ordering.
  • 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.getDataAsDebugString(): retrieve the core data for this granule in human-readable form.
  • granule.getDataAsString(): retrieve the core data for this granule in string form.
  • granule.getMetaData(metaDataKey): return some meta-data associated with the granule. To associate meta-data, use granule.setMetaData. To avoid meta data key clashes, use reverse-domain names for the meta data keys. This mechanism can be used for attaching some temporary helper-data to a granule, and communicate meta-data between adapters along the data flow.
  • 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.getName(): retrieve a human-readable name for the granule.
  • granule.getRoutingGranuleClass(): Granules can be replaced by proxies if necessary. This method provides access to the granule class of the original granule, which is used for routing the proxy through the data flow as if it is the original granule.
  • granule.getRoutingId(): Granules can be replaced by proxies if necessary. This method provides access to the granule identifier of the original granule, which is used for routing the proxy through the data flow as if it is the original granule (e.g. it is used to determine the visit counts for the granule).