EGSimpleTableParser Class Reference

Collaboration diagram for EGSimpleTableParser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

NSData data ()
 EGSimpleTableParser (InputStream contentStream, NSDictionary fontDicts, NSDictionary styleDicts)
 EGSimpleTableParser (InputStream contentStream)
HSSFWorkbook workbook ()
void writeToStream (OutputStream out) throws IOException

Protected Attributes

final Logger log = Logger.getLogger(EGSimpleTableParser.class)

Private Member Functions

void addEntriesFromNode (NSMutableDictionary dictionary, Node node)
String attributeStringToKeyPath (String aString)
String dictValueForKey (NSDictionary dict, String key, String defaultValue)
HSSFFont fontWithID (String id)
String keyPathToAttributeString (String aString)
String nodeValueForKey (Node node, String key, String defaultValue)
void parse ()
void parseFont (Node node)
void parseNode (Node node)
void parseStyle (Node node)
void parseTable (Node tableNode)
HSSFCellStyle styleWithDictionary (NSDictionary dict)
void takeBooleanValueForKey (NSDictionary dict, String key, Object target, String defaultValue)
void takeClassValueForKey (NSDictionary dict, String key, Object target, Class source, String defaultValue)
void takeClassValueForKey (NSDictionary dict, String key, Object target, String defaultValue)
void takeNumberValueForKey (NSDictionary dict, String key, Object target, String defaultValue)

Private Attributes

InputStream _contentStream
NSMutableDictionary _fontDicts
NSMutableDictionary _fonts = new NSMutableDictionary()
NSMutableDictionary _styleDicts
NSMutableDictionary _styles = new NSMutableDictionary()
HSSFWorkbook _workbook

Static Private Attributes

static final NSArray STYLE_KEYS


Detailed Description

Parses an input stream for tables and converts them into excel sheets. You must have a surrounding element as there is only one root element in XML allowed.
Eg:<div><table 1><table 2>...</div> You <emp>must</emp> take care that your content is XML readable. Futhermore, there is support for a CSS-like style tagging. Either supply font and style dictionaries in the constructor or via <style> and <font> tags. The tags are shown in the example, but mainly the attributes are named the same as the properties of the HSSFCellStyle and HSSFFont objects. The symbolic names from theses classes (eg. ALIGN_RIGHT) are also supported. In addition, the tags <emp>must</emp> have an id attribute and can specify an extends attribute that contains the ID of the style that is extended - all properties from this style and it's predecessors are copied to the current style.
In addition, you can specify an attribute in any <table>, <tr>, <th> and <td> tag, when this happens a new style is created and it applies to the contents of this tag.
The value is copied as text from the cell's content, so you better take care that it is parsable and matches the cellStyle and cellFormat definition.

The parser also supports the some-name attribute names in addition to someName as using the Reformat command in WOBuilder messes up the case of the tags. When used in .wod files, the attributes must be enclosed in quotes ("cell-type"=foo;). Some care must be taken when the attributes in the current node override the ones from the parent as this is not thouroughly tested.
A client would use this class like:


 EGSimpleTableParser parser = new EGSimpleTableParser(new ByteArrayInputStream(someContentString));
 NSData result = parser.data();
 
Author:
ak

Constructor & Destructor Documentation

EGSimpleTableParser ( InputStream  contentStream  ) 

EGSimpleTableParser ( InputStream  contentStream,
NSDictionary  fontDicts,
NSDictionary  styleDicts 
)


Member Function Documentation

void addEntriesFromNode ( NSMutableDictionary  dictionary,
Node  node 
) [private]

Parameters:
fontDictionary 
tableNode 

String attributeStringToKeyPath ( String  aString  )  [private]

NSData data (  ) 

String dictValueForKey ( NSDictionary  dict,
String  key,
String  defaultValue 
) [private]

HSSFFont fontWithID ( String  id  )  [private]

String keyPathToAttributeString ( String  aString  )  [private]

String nodeValueForKey ( Node  node,
String  key,
String  defaultValue 
) [private]

void parse (  )  [private]

void parseFont ( Node  node  )  [private]

void parseNode ( Node  node  )  [private]

void parseStyle ( Node  node  )  [private]

void parseTable ( Node  tableNode  )  [private]

HSSFCellStyle styleWithDictionary ( NSDictionary  dict  )  [private]

void takeBooleanValueForKey ( NSDictionary  dict,
String  key,
Object  target,
String  defaultValue 
) [private]

void takeClassValueForKey ( NSDictionary  dict,
String  key,
Object  target,
Class  source,
String  defaultValue 
) [private]

void takeClassValueForKey ( NSDictionary  dict,
String  key,
Object  target,
String  defaultValue 
) [private]

void takeNumberValueForKey ( NSDictionary  dict,
String  key,
Object  target,
String  defaultValue 
) [private]

HSSFWorkbook workbook (  ) 

void writeToStream ( OutputStream  out  )  throws IOException


Member Data Documentation

InputStream _contentStream [private]

HSSFWorkbook _workbook [private]

final Logger log = Logger.getLogger(EGSimpleTableParser.class) [protected]

logging support

final NSArray STYLE_KEYS [static, private]

Initial value:

 new NSArray(new Object[] {
                "font","hidden","locked","wrapText",
                        "leftBorderColor","rightBorderColor","topBorderColor","bottomBorderColor",
                        "borderLeft","borderRight","borderTop","borderBottom",
                        "fillForegroundColor","fillBackgroundColor","fillPattern",
                        "rotation","indention", "wrapText",
                        "alignment","verticalAlignment","format"
        })


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:01 2012 for Project Wonder by  doxygen 1.5.8