cz.cmc.tcgui.datamanip
Class AbstractExporter

java.lang.Object
  extended bycz.cmc.tcgui.datamanip.AbstractExporter
All Implemented Interfaces:
Exporter
Direct Known Subclasses:
DefaultClassExporter, DefaultFilterExporter, DefaultQDiscExporter

public abstract class AbstractExporter
extends Object
implements Exporter

AbstractExporter is abstract superclass implementing Exporter interface. Subclasses should implement method export(...), in which they append specific Strings to appropriate StringBuffers 'tcCmd' and 'tcCmt'. As a result, it exports given tcgui.TCObject into OutputStream in format suitable for standart shell script executable under "tc aware" Linux OS.


Field Summary
protected  AttributeEntryInstance aei
          common AttributeEntryInstance for indexing tc attribute maps
protected  TCObject ddTCO
          datadef.TCObject of given 'tco' tcgui.TCObject
protected  OutputStream os
          OutputStream into which to export all output (usually tcCmt and tcCmd).
protected  Object parentAtrEntry
          AttributeEntry of parent's datadef object.
protected  Map parentAtrGroupMap
          Map corresponding to parent's root AttributeGroup.
protected  TCObject parentDdTCO
          datadef.TCObject of given 'tco' tcgui.TCObject's parent
protected  Map parentTcAtrMap
          Map with tc attributes of given 'tco' tcgui.TCObject's parent
protected  TCObject parentTCO
          Parent tcgui.TCObject of given 'tco' tcgui.TCObject
protected  Map tcAtrMap
          Map with tc attributes of given 'tco' tcgui.TCObject
protected  StringBuffer tcCmd
          StringBuffer in which the tc command to export (ie.
protected  StringBuffer tcCmt
          StringBuffer in which the comment to insert before tc command (ie. '# some info...') is created.
 
Constructor Summary
AbstractExporter()
           
 
Method Summary
protected abstract  void export(TCExport tce, TCObject tco)
          Subclasses should implement this to add their specialized export functionality and append Strings for export to 'tcCmd' and 'tcCmt' StringBuffers.
protected  void exportAttributeEntry(Map m, AttributeEntry ae, TCObject tco)
          Exports given AttributeEntry into 'tcCmd' and 'tcCmt' StringBuffers.
protected  void exportAttributeGroup(Map m, AttributeGroup ag, TCObject tco)
          Exports AttributeEntries within given AttributeGroup into 'tcCmd' and 'tcCmt' StringBuffers.
protected  boolean exportHandle(Map aMap, TCObject dTCO, String hType, TCObject tco)
          Searches root AttributeGroup for handle specified by given String (usually "classid" or "handle") and exports its value into 'tcCmd' StringBuffer.
protected  boolean exportParentHandle(String hType, TCObject tco)
          Searches parent's root AttributeGroup for handle specified by given String (usually "classid" or "handle") and exports its value into 'tcCmd' StringBuffer.
 void exportTCObject(OutputStream os, TCExport tce, TCObject tco)
          Exports the TCObject into given OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tcCmt

protected transient StringBuffer tcCmt
StringBuffer in which the comment to insert before tc command (ie. '# some info...') is created.


tcCmd

protected transient StringBuffer tcCmd
StringBuffer in which the tc command to export (ie. 'tc qdisc add...') is created.


os

protected transient OutputStream os
OutputStream into which to export all output (usually tcCmt and tcCmd).


aei

protected transient AttributeEntryInstance aei
common AttributeEntryInstance for indexing tc attribute maps


tcAtrMap

protected transient Map tcAtrMap
Map with tc attributes of given 'tco' tcgui.TCObject


ddTCO

protected transient TCObject ddTCO
datadef.TCObject of given 'tco' tcgui.TCObject


parentTCO

protected transient TCObject parentTCO
Parent tcgui.TCObject of given 'tco' tcgui.TCObject


parentTcAtrMap

protected transient Map parentTcAtrMap
Map with tc attributes of given 'tco' tcgui.TCObject's parent


parentDdTCO

protected transient TCObject parentDdTCO
datadef.TCObject of given 'tco' tcgui.TCObject's parent


parentAtrEntry

protected transient Object parentAtrEntry
AttributeEntry of parent's datadef object.


parentAtrGroupMap

protected transient Map parentAtrGroupMap
Map corresponding to parent's root AttributeGroup.

Constructor Detail

AbstractExporter

public AbstractExporter()
Method Detail

exportTCObject

public void exportTCObject(OutputStream os,
                           TCExport tce,
                           TCObject tco)
                    throws ExportException
Description copied from interface: Exporter
Exports the TCObject into given OutputStream

Specified by:
exportTCObject in interface Exporter
Parameters:
os - OutputStream to export the TCObject to
tce - TCExport instance for accessing the schema
tco - TCObject to export
Throws:
ExportException - if any unrecoverable error occurs during export

export

protected abstract void export(TCExport tce,
                               TCObject tco)
                        throws ExportException
Subclasses should implement this to add their specialized export functionality and append Strings for export to 'tcCmd' and 'tcCmt' StringBuffers.

Parameters:
tce - TCExport instance for accessing the schema
tco - TCObject to export
Throws:
ExportException - if any unrecoverable error occurs during export

exportAttributeEntry

protected void exportAttributeEntry(Map m,
                                    AttributeEntry ae,
                                    TCObject tco)
                             throws ExportException
Exports given AttributeEntry into 'tcCmd' and 'tcCmt' StringBuffers. If it is AttributeGroup, it is recursively exported with help of exportAttributeGroup(...) method. Subclasses can use this, to simplify their code, or override it if unusual export format is needed.

Parameters:
m - Map containing value to export for key (AttributeEntry,index)
ae - AttributeEntry which value should be exported
tco - tcgui.TCObject which is beeing exported (used for exception description)
Throws:
ExportException - if any unrecoverable error occurs during export

exportAttributeGroup

protected void exportAttributeGroup(Map m,
                                    AttributeGroup ag,
                                    TCObject tco)
                             throws ExportException
Exports AttributeEntries within given AttributeGroup into 'tcCmd' and 'tcCmt' StringBuffers. For each AttributeEntry method exportAttributeEntry(...) is called. Subclasses can use this, to simplify their code, or override it if unusual export format is needed.

Parameters:
m - Map containing values for all AttributeEntries within the group
ag - AttributeGroup which AttributeEntries to export
tco - tcgui.TCObject which is beeing exported (used for exception description)
Throws:
ExportException - if any unrecoverable error occurs during export

exportParentHandle

protected boolean exportParentHandle(String hType,
                                     TCObject tco)
                              throws ExportException
Searches parent's root AttributeGroup for handle specified by given String (usually "classid" or "handle") and exports its value into 'tcCmd' StringBuffer.

Parameters:
hType - type of handle to search for (usually "classid" or "handle")
tco - tcgui.TCObject which is beeing exported (used for exception description)
Returns:
true if handle found and its value is String so it was exported, false otherwise
Throws:
ExportException - if any unrecoverable error occurs during export

exportHandle

protected boolean exportHandle(Map aMap,
                               TCObject dTCO,
                               String hType,
                               TCObject tco)
                        throws ExportException
Searches root AttributeGroup for handle specified by given String (usually "classid" or "handle") and exports its value into 'tcCmd' StringBuffer.

Parameters:
aMap - attribute map inside which to search for AttributeEntry with given handle
hType - type of handle to search for (usually "classid" or "handle")
tco - tcgui.TCObject which is beeing exported (used for exception description)
Returns:
true if handle found and its value is String so it was exported, false otherwise
Throws:
ExportException - if any unrecoverable error occurs during export