Difference between revisions of "Granule Code"

From DocDataFlow
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
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'']] data structure.
+
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:
 +
 +
* <code>granule.comparePosition(orderingList, compareWithGranule)</code>: return an int (< 0, == 0, > 0) after comparing the granules. The orderingList is a linear list of [[Granule Ordering|granule ordering]].
  
 
* <code>granule.getId()</code>: get the unique identifier for this granule.
 
* <code>granule.getId()</code>: get the unique identifier for this granule.
Line 12: Line 14:
  
 
* <code>granule.getData()</code>: 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).
 
* <code>granule.getData()</code>: 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).
 +
 +
* <code>granule.getDataAsDebugString()</code>: retrieve the core data for this granule in human-readable form.
 +
 +
* <code>granule.getDataAsString()</code>: retrieve the core data for this granule in string form.
 +
 +
* <code>granule.getMetaData(metaDataKey)</code>: return some meta-data associated with the granule. To associate meta-data, use <code>granule.setMetaData</code>. 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.
  
 
* <code>granule.getParentGranule()</code>: retrieve the parent granule for this granule. Eventually will lead to an AppGranule - appGranules are the root(s) for the granule hierarchy.
 
* <code>granule.getParentGranule()</code>: retrieve the parent granule for this granule. Eventually will lead to an AppGranule - appGranules are the root(s) for the granule hierarchy.
  
* <code>granule.comparePosition(orderingList, compareWithGranule)</code>: return an int (< 0, == 0, > 0) after comparing the granules. The orderingList is a linear list of [[Granule Ordering|granule ordering]].
+
* <code>granule.getName()</code>: retrieve a human-readable name for the granule.
 +
 
 +
* <code>granule.getRoutingGranuleClass()</code>: 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.
 +
 
 +
* <code>granule.getRoutingId()</code>: 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).
 +
 
 +
* <code>granule.setMetaData(metaDataKey, metaData)</code>: associate some meta-data with the granule. To avoid meta data key clashes, use reverse-domain names for the meta data keys.

Latest revision as of 02:10, 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).
  • granule.setMetaData(metaDataKey, metaData): associate some meta-data with the granule. To avoid meta data key clashes, use reverse-domain names for the meta data keys.