Loading pom.xml 0 → 100644 +89 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>jmatio</groupId> <artifactId>jmatio</artifactId> <version>0.2.3</version> <name>The OpenIMAJ branch of JMATIO</name> <url>http://www.openimaj.org/thirdparty/jmatio</url> <inceptionYear>2011</inceptionYear> <description> Originally developed by Wojciech Gradkowski over here: http://sourceforge.net/projects/jmatio/ </description> <licenses> <license> <name>New BSD</name> <url>http://www.openimaj.org/LICENSE.txt</url> <distribution>repo,manual</distribution> <comments>The New BSD License</comments> </license> </licenses> <organization> <name>The University of Southampton</name> <url>http://www.soton.ac.uk</url> </organization> <developers> <developer> <id>wgradkowski</id> <name>Wojciech Gradkowski</name> <url>http://www.sourceforge.net/projects/jmatio</url> <roles> <role>architect</role> </roles> </developer> <developer> <id>ss</id> <name>Sina Samangooei</name> <email>ss@ecs.soton.ac.uk</email> <url>http://www.ecs.soton.ac.uk/people/ss</url> <organization>The University of Southampton</organization> <organizationUrl>http://www.soton.ac.uk</organizationUrl> <roles> <role>architect</role> <role>developer</role> </roles> <timezone>0</timezone> </developer> </developers> <issueManagement> <system>Sourceforge/Allura</system> <url>https://sourceforge.net/p/openimaj/tickets/</url> </issueManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.6</version> <configuration> <argLine>-Xmx1G -Djava.awt.headless=true</argLine> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <proc>none</proc> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>Octopussy maven repository</id> <url>http://octopussy.ecs.soton.ac.uk/m2/thirdparty/</url> </repository> </repositories> </project> src/main/java/com/jmatio/common/MatDataTypes.java 0 → 100755 +130 −0 Original line number Diff line number Diff line package com.jmatio.common; /** * MAT-file data types * * @author Wojciech Gradkowski <wgradkowski@gmail.com> */ public class MatDataTypes { /* MAT-File Data Types */ public static final int miUNKNOWN = 0; public static final int miINT8 = 1; public static final int miUINT8 = 2; public static final int miINT16 = 3; public static final int miUINT16 = 4; public static final int miINT32 = 5; public static final int miUINT32 = 6; public static final int miSINGLE = 7; public static final int miDOUBLE = 9; public static final int miINT64 = 12; public static final int miUINT64 = 13; public static final int miMATRIX = 14; public static final int miCOMPRESSED = 15; public static final int miUTF8 = 16; public static final int miUTF16 = 17; public static final int miUTF32 = 18; public static final int miSIZE_INT32 = 4; public static final int miSIZE_INT16 = 2; public static final int miSIZE_INT8 = 1; public static final int miSIZE_UINT32 = 4; public static final int miSIZE_UINT16 = 2; public static final int miSIZE_UINT8 = 1; public static final int miSIZE_DOUBLE = 8; public static final int miSIZE_CHAR = 1; /** * Return number of bytes for given type. * * @param type - <code>MatDataTypes</code> * @return */ public static int sizeOf(int type) { switch ( type ) { case MatDataTypes.miINT8: return miSIZE_INT8; case MatDataTypes.miUINT8: return miSIZE_UINT8; case MatDataTypes.miINT16: return miSIZE_INT16; case MatDataTypes.miUINT16: return miSIZE_UINT16; case MatDataTypes.miINT32: return miSIZE_INT32; case MatDataTypes.miUINT32: return miSIZE_UINT32; case MatDataTypes.miDOUBLE: return miSIZE_DOUBLE; default: return 1; } } /** * Get String representation of a data type * * @param type - data type * @return - String representation */ public static String typeToString(int type) { String s; switch (type) { case MatDataTypes.miUNKNOWN: s = "unknown"; break; case MatDataTypes.miINT8: s = "int8"; break; case MatDataTypes.miUINT8: s = "uint8"; break; case MatDataTypes.miINT16: s = "int16"; break; case MatDataTypes.miUINT16: s = "uint16"; break; case MatDataTypes.miINT32: s = "int32"; break; case MatDataTypes.miUINT32: s = "uint32"; break; case MatDataTypes.miSINGLE: s = "single"; break; case MatDataTypes.miDOUBLE: s = "double"; break; case MatDataTypes.miINT64: s = "int64"; break; case MatDataTypes.miUINT64: s = "uint64"; break; case MatDataTypes.miMATRIX: s = "matrix"; break; case MatDataTypes.miCOMPRESSED: s = "compressed"; break; case MatDataTypes.miUTF8: s = "uft8"; break; case MatDataTypes.miUTF16: s = "utf16"; break; case MatDataTypes.miUTF32: s = "utf32"; break; default: s = "unknown"; } return s; } } src/main/java/com/jmatio/io/MatFileFilter.java 0 → 100644 +78 −0 Original line number Diff line number Diff line package com.jmatio.io; import java.util.HashSet; import java.util.Set; /** * File filter. * * This class is used to tell <code>MatFileReader</code> which matrices * should be processed. This is useful when operating on big MAT-files, * when there's no need to load all arrays into memory. * * Usage: * <pre></code> * //create new filter instance * MatFileFilter filter = new MatFileFilter(); * //add a needle * filter.addArrayName( "your_array_name" ); * * //read array form file (haystack) looking _only_ for pecified array (needle) * MatFileReader mfr = new MatFileReader( fileName, filter ); * </code></pre> * * @see com.jmatio.io.MatFileReader * @author Wojciech Gradkowski (<a href="mailto:wgradkowski@gmail.com">wgradkowski@gmail.com</a>) */ public class MatFileFilter { private Set<String> filter; /** * Creates empty filter intance. * * <i>Note: empty filter acceps all results.</i> */ public MatFileFilter() { filter = new HashSet<String>(); } /** * Create filter intance and add array names. * * @param names - array of names (needles) */ public MatFileFilter( String[] names ) { this(); for ( String name : names ) { addArrayName( name ); } } /** * Add array name to the filter. This array will be processed * while crawling thourg the MAT-file * * @param name - array name (needle) */ public void addArrayName( String name ) { filter.add( name ); } /** * Test if given name matches the filter. * * @param name - array name to be tested * @return - <code>true</code> if array (matrix) of this name should be processed */ public boolean matches( String name ) { if ( filter.size() == 0 ) { return true; } return filter.contains( name ); } } src/main/java/com/jmatio/io/MatFileHeader.java 0 → 100755 +101 −0 Original line number Diff line number Diff line package com.jmatio.io; import java.util.Date; /** * MAT-file header * * Level 5 MAT-files begin with a 128-byte header made up of a 124 byte text field * and two, 16-bit flag fields * * @author Wojciech Gradkowski (<a href="mailto:wgradkowski@gmail.com">wgradkowski@gmail.com</a>) */ public class MatFileHeader { private static String DEFAULT_DESCRIPTIVE_TEXT = "MATLAB 5.0 MAT-file, Platform: " + System.getProperty("os.name") + ", CREATED on: "; private static int DEFAULT_VERSION = 0x0100; private static byte[] DEFAULT_ENDIAN_INDICATOR = new byte[] {(byte)'M', (byte)'I'}; private int version; private String description; private byte[] endianIndicator; /** * New MAT-file header * * @param description - descriptive text (no longer than 116 characters) * @param version - by default is set to 0x0100 * @param endianIndicator - byte array size of 2 indicating byte-swapping requirement */ public MatFileHeader(String description, int version, byte[] endianIndicator) { this.description = description; this.version = version; this.endianIndicator = endianIndicator; } /** * Gets descriptive text * * @return */ public String getDescription() { return description; } /** * Gets endian indicator. Bytes written as "MI" suggest that byte-swapping operation is required * in order to interpret data correctly. If value is set to "IM" byte-swapping is not needed. * * @return - a byte array size of 2 */ public byte[] getEndianIndicator() { return endianIndicator; } /** * When creating a MAT-file, set version to 0x0100 * * @return */ public int getVersion() { return version; } //@facotry /** * A factory. Creates new <code>MatFileHeader</code> instance with default header values: * <ul> * <li>MAT-file is 5.0 version</li> * <li>version is set to 0x0100</li> * <li>no byte-swapping ("IM")</li> * </ul> * * @return - new <code>MatFileHeader</code> instance */ public static MatFileHeader createHeader() { return new MatFileHeader( DEFAULT_DESCRIPTIVE_TEXT + (new Date()).toString(), DEFAULT_VERSION, DEFAULT_ENDIAN_INDICATOR); } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("["); sb.append("desriptive text: " + description); sb.append(", version: " + version); sb.append(", endianIndicator: " + new String(endianIndicator) ); sb.append("]"); return sb.toString(); } } src/main/java/com/jmatio/io/MatFileIncrementalWriter.java 0 → 100755 +0 −0 File added.Preview size limit exceeded, changes collapsed. Show changes Loading
pom.xml 0 → 100644 +89 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>jmatio</groupId> <artifactId>jmatio</artifactId> <version>0.2.3</version> <name>The OpenIMAJ branch of JMATIO</name> <url>http://www.openimaj.org/thirdparty/jmatio</url> <inceptionYear>2011</inceptionYear> <description> Originally developed by Wojciech Gradkowski over here: http://sourceforge.net/projects/jmatio/ </description> <licenses> <license> <name>New BSD</name> <url>http://www.openimaj.org/LICENSE.txt</url> <distribution>repo,manual</distribution> <comments>The New BSD License</comments> </license> </licenses> <organization> <name>The University of Southampton</name> <url>http://www.soton.ac.uk</url> </organization> <developers> <developer> <id>wgradkowski</id> <name>Wojciech Gradkowski</name> <url>http://www.sourceforge.net/projects/jmatio</url> <roles> <role>architect</role> </roles> </developer> <developer> <id>ss</id> <name>Sina Samangooei</name> <email>ss@ecs.soton.ac.uk</email> <url>http://www.ecs.soton.ac.uk/people/ss</url> <organization>The University of Southampton</organization> <organizationUrl>http://www.soton.ac.uk</organizationUrl> <roles> <role>architect</role> <role>developer</role> </roles> <timezone>0</timezone> </developer> </developers> <issueManagement> <system>Sourceforge/Allura</system> <url>https://sourceforge.net/p/openimaj/tickets/</url> </issueManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.6</version> <configuration> <argLine>-Xmx1G -Djava.awt.headless=true</argLine> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <proc>none</proc> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>Octopussy maven repository</id> <url>http://octopussy.ecs.soton.ac.uk/m2/thirdparty/</url> </repository> </repositories> </project>
src/main/java/com/jmatio/common/MatDataTypes.java 0 → 100755 +130 −0 Original line number Diff line number Diff line package com.jmatio.common; /** * MAT-file data types * * @author Wojciech Gradkowski <wgradkowski@gmail.com> */ public class MatDataTypes { /* MAT-File Data Types */ public static final int miUNKNOWN = 0; public static final int miINT8 = 1; public static final int miUINT8 = 2; public static final int miINT16 = 3; public static final int miUINT16 = 4; public static final int miINT32 = 5; public static final int miUINT32 = 6; public static final int miSINGLE = 7; public static final int miDOUBLE = 9; public static final int miINT64 = 12; public static final int miUINT64 = 13; public static final int miMATRIX = 14; public static final int miCOMPRESSED = 15; public static final int miUTF8 = 16; public static final int miUTF16 = 17; public static final int miUTF32 = 18; public static final int miSIZE_INT32 = 4; public static final int miSIZE_INT16 = 2; public static final int miSIZE_INT8 = 1; public static final int miSIZE_UINT32 = 4; public static final int miSIZE_UINT16 = 2; public static final int miSIZE_UINT8 = 1; public static final int miSIZE_DOUBLE = 8; public static final int miSIZE_CHAR = 1; /** * Return number of bytes for given type. * * @param type - <code>MatDataTypes</code> * @return */ public static int sizeOf(int type) { switch ( type ) { case MatDataTypes.miINT8: return miSIZE_INT8; case MatDataTypes.miUINT8: return miSIZE_UINT8; case MatDataTypes.miINT16: return miSIZE_INT16; case MatDataTypes.miUINT16: return miSIZE_UINT16; case MatDataTypes.miINT32: return miSIZE_INT32; case MatDataTypes.miUINT32: return miSIZE_UINT32; case MatDataTypes.miDOUBLE: return miSIZE_DOUBLE; default: return 1; } } /** * Get String representation of a data type * * @param type - data type * @return - String representation */ public static String typeToString(int type) { String s; switch (type) { case MatDataTypes.miUNKNOWN: s = "unknown"; break; case MatDataTypes.miINT8: s = "int8"; break; case MatDataTypes.miUINT8: s = "uint8"; break; case MatDataTypes.miINT16: s = "int16"; break; case MatDataTypes.miUINT16: s = "uint16"; break; case MatDataTypes.miINT32: s = "int32"; break; case MatDataTypes.miUINT32: s = "uint32"; break; case MatDataTypes.miSINGLE: s = "single"; break; case MatDataTypes.miDOUBLE: s = "double"; break; case MatDataTypes.miINT64: s = "int64"; break; case MatDataTypes.miUINT64: s = "uint64"; break; case MatDataTypes.miMATRIX: s = "matrix"; break; case MatDataTypes.miCOMPRESSED: s = "compressed"; break; case MatDataTypes.miUTF8: s = "uft8"; break; case MatDataTypes.miUTF16: s = "utf16"; break; case MatDataTypes.miUTF32: s = "utf32"; break; default: s = "unknown"; } return s; } }
src/main/java/com/jmatio/io/MatFileFilter.java 0 → 100644 +78 −0 Original line number Diff line number Diff line package com.jmatio.io; import java.util.HashSet; import java.util.Set; /** * File filter. * * This class is used to tell <code>MatFileReader</code> which matrices * should be processed. This is useful when operating on big MAT-files, * when there's no need to load all arrays into memory. * * Usage: * <pre></code> * //create new filter instance * MatFileFilter filter = new MatFileFilter(); * //add a needle * filter.addArrayName( "your_array_name" ); * * //read array form file (haystack) looking _only_ for pecified array (needle) * MatFileReader mfr = new MatFileReader( fileName, filter ); * </code></pre> * * @see com.jmatio.io.MatFileReader * @author Wojciech Gradkowski (<a href="mailto:wgradkowski@gmail.com">wgradkowski@gmail.com</a>) */ public class MatFileFilter { private Set<String> filter; /** * Creates empty filter intance. * * <i>Note: empty filter acceps all results.</i> */ public MatFileFilter() { filter = new HashSet<String>(); } /** * Create filter intance and add array names. * * @param names - array of names (needles) */ public MatFileFilter( String[] names ) { this(); for ( String name : names ) { addArrayName( name ); } } /** * Add array name to the filter. This array will be processed * while crawling thourg the MAT-file * * @param name - array name (needle) */ public void addArrayName( String name ) { filter.add( name ); } /** * Test if given name matches the filter. * * @param name - array name to be tested * @return - <code>true</code> if array (matrix) of this name should be processed */ public boolean matches( String name ) { if ( filter.size() == 0 ) { return true; } return filter.contains( name ); } }
src/main/java/com/jmatio/io/MatFileHeader.java 0 → 100755 +101 −0 Original line number Diff line number Diff line package com.jmatio.io; import java.util.Date; /** * MAT-file header * * Level 5 MAT-files begin with a 128-byte header made up of a 124 byte text field * and two, 16-bit flag fields * * @author Wojciech Gradkowski (<a href="mailto:wgradkowski@gmail.com">wgradkowski@gmail.com</a>) */ public class MatFileHeader { private static String DEFAULT_DESCRIPTIVE_TEXT = "MATLAB 5.0 MAT-file, Platform: " + System.getProperty("os.name") + ", CREATED on: "; private static int DEFAULT_VERSION = 0x0100; private static byte[] DEFAULT_ENDIAN_INDICATOR = new byte[] {(byte)'M', (byte)'I'}; private int version; private String description; private byte[] endianIndicator; /** * New MAT-file header * * @param description - descriptive text (no longer than 116 characters) * @param version - by default is set to 0x0100 * @param endianIndicator - byte array size of 2 indicating byte-swapping requirement */ public MatFileHeader(String description, int version, byte[] endianIndicator) { this.description = description; this.version = version; this.endianIndicator = endianIndicator; } /** * Gets descriptive text * * @return */ public String getDescription() { return description; } /** * Gets endian indicator. Bytes written as "MI" suggest that byte-swapping operation is required * in order to interpret data correctly. If value is set to "IM" byte-swapping is not needed. * * @return - a byte array size of 2 */ public byte[] getEndianIndicator() { return endianIndicator; } /** * When creating a MAT-file, set version to 0x0100 * * @return */ public int getVersion() { return version; } //@facotry /** * A factory. Creates new <code>MatFileHeader</code> instance with default header values: * <ul> * <li>MAT-file is 5.0 version</li> * <li>version is set to 0x0100</li> * <li>no byte-swapping ("IM")</li> * </ul> * * @return - new <code>MatFileHeader</code> instance */ public static MatFileHeader createHeader() { return new MatFileHeader( DEFAULT_DESCRIPTIVE_TEXT + (new Date()).toString(), DEFAULT_VERSION, DEFAULT_ENDIAN_INDICATOR); } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("["); sb.append("desriptive text: " + description); sb.append(", version: " + version); sb.append(", endianIndicator: " + new String(endianIndicator) ); sb.append("]"); return sb.toString(); } }
src/main/java/com/jmatio/io/MatFileIncrementalWriter.java 0 → 100755 +0 −0 File added.Preview size limit exceeded, changes collapsed. Show changes