Author: echatellier Date: 2012-08-06 14:47:29 +0200 (Mon, 06 Aug 2012) New Revision: 425 Url: http://nuiton.org/repositories/revision/nuiton-matrix/425 Log: Udpate documentation Modified: trunk/src/site/rst/importexport.rst Modified: trunk/src/site/rst/importexport.rst =================================================================== --- trunk/src/site/rst/importexport.rst 2012-07-09 10:21:26 UTC (rev 424) +++ trunk/src/site/rst/importexport.rst 2012-08-06 12:47:29 UTC (rev 425) @@ -5,7 +5,7 @@ .. * $Id$ .. * $HeadURL$ .. * %% -.. * Copyright (C) 2011 CodeLutin, Chatellier Eric +.. * Copyright (C) 2011 - 2012 CodeLutin, Chatellier Eric .. * %% .. * This program is free software: you can redistribute it and/or modify .. * it under the terms of the GNU Lesser General Public License as @@ -62,10 +62,85 @@ With semantics ~~~~~~~~~~~~~~ - Without semantics ~~~~~~~~~~~~~~~~~ n dimensional matrix -------------------- +With n dimension import, file format is a little bit more complicated. It's +must include: + +- matrix dimensions +- dimensions semantics +- value for each dimension + +For example, importing a 2*2*2 matrix: + + [2, 2, 2] + java.lang.String:2009,2010 + java.lang.String:Nantes,Lille + java.lang.String:Informatique,Administration + 0;0;0;0.0 + 0;0;1;1.0 + 0;1;1;4.0 + 1;0;0;-4.0E-7 + 1;0;1;2.0 + 1;1;0;4.0 + 1;1;1;42.0 + +Using semantics mapper +~~~~~~~~~~~~~~~~~~~~~~ + +Previous example was using only "String" to lookup for semantics. You can use +an additional SemanticMapper to use custom object. + +For example: + [2, 2, 2] + Year:2009,2010 + City:Nantes,Lille + Department:Informatique,Administration + 0;0;0;0.0 + 0;0;1;1.0 + 0;1;1;4.0 + 1;0;0;-4.0E-7 + 1;0;1;2.0 + 1;1;0;4.0 + 1;1;1;42.0 + +The SemanticMapper will be called to resolv object identified by ids such as '2009', +'2010'... + +Here is a SemanticMapper sample code:: + + public class IsisMatrixSemanticMapper extends SemanticMapper { + + public Class getType(String typeName) { + + // In simulation context : + Class clazz = null; + try { + clazz = Class.forName("org.exemple." + typeName); + } catch (Exception ex) { + clazz = String.class; + } + return clazz; + } + + public Object getValue(Class type, String valueId) { + + // In simulation context : + Object value = null; + try { + // lookup in database object identified by valueId + [...] + + } catch (Exception ex) { + log.warn("Can't get value for " + valueId, ex); + value = valueId; + } + return value; + + //return valueId; + } + } \ No newline at end of file