//read data >> consider changing it to stategy pattern
switch ( type )
{
case MLArray.mxSTRUCT_CLASS:
MLStructure struct = new MLStructure(name, dims, type, attributes);
//field name length - this subelement always uses the compressed data element format
tag = new ISMatTag(buf);
int maxlen = buf.getInt(); //maximum field length
////// read fields data as Int8
tag = new ISMatTag(buf);
//calculate number of fields
int numOfFields = tag.size/maxlen;
//padding after field names
int padding = (tag.size%8) != 0 ? 8-(tag.size%8) : 0;
String[] fieldNames = new String[numOfFields];
for ( int i = 0; i < numOfFields; i++ )
{
byte[] names = new byte[maxlen];
buf.get(names);
fieldNames[i] = zeroEndByteArrayToString(names);
}
buf.position( buf.position() + padding );
//read fields
for ( int index = 0; index < struct.getM()*struct.getN(); index++ )
{
for ( int i = 0; i < numOfFields; i++ )
{
//read matrix recursively
tag = new ISMatTag(buf);
MLArray fieldValue = readMatrix( buf, false);
struct.setField(fieldNames[i], fieldValue, index);
}
}
mlArray = struct;
break;
case MLArray.mxCELL_CLASS: