Examples of MLStructure


Examples of com.jmatio.types.MLStructure

        //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:
View Full Code Here

Examples of com.jmatio.types.MLStructure

                xhtml.element("p", varName + ":" + String.valueOf(varData));

                // If the variable is a structure, extract variable info from structure
                if (varData.isStruct()){
                    MLStructure mlStructure = (MLStructure) mfr.getMLArray(varName);
                    xhtml.startElement("ul");
                    xhtml.newline();
                    for (MLArray element : mlStructure.getAllFields()){
                        xhtml.startElement("li");
                        xhtml.characters(String.valueOf(element));

                        // If there is an embedded structure, extract variable info.
                        if (element.isStruct()){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.