Package fr.ifremer.isisfish.mexico
Class MexicoHelper
java.lang.Object
fr.ifremer.isisfish.mexico.MexicoHelper
Mexico helper class.
- Since:
- 3.2.0.4 Last update : $Date$ By : $Author$
- Version:
- $Revision$
- Author:
- chatellier
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static StringBuffer
appendString
(StringBuffer buffer, Object o) Append object type and value in stringbuffer.static String
Format xml string.static String
getDesignPlanAsXML
(DesignPlan designPlan, String... args) Get xml representation of a design plan.static DesignPlan
getDesignPlanFromXML
(File xmlFile, org.nuiton.topia.TopiaContext topiaContext) Parse xmlFile with sax, and return aDesignPlan
.static String
getMatrixAsXML
(org.nuiton.math.matrix.MatrixND matrix) Transform matrix into XML mexico format.static org.nuiton.math.matrix.MatrixND
getMatrixFromXml
(org.dom4j.Element mxElement, org.nuiton.topia.TopiaContext context) Parse a dom element (mx) as aMatrixND
.static Object
getObjectFromString
(String content, org.nuiton.topia.TopiaContext context) Parse string content (human readable) to get isis fish instance for this object.protected static String
Return object fully qualified name excepted forTopiaEntity
.static String
getRulesAsXml
(List<Rule> rules) Transform rules list as xml.getRulesFromXml
(org.dom4j.Element rulesElement, org.nuiton.topia.TopiaContext topiaContext) Parse xml as rules list.static String
getStringFromObject
(Object object) Get string representation (human readable) for an object.static void
writeDesignPlanToFile
(File file, DesignPlan designPlan) Convert design plan to xml and write it to given file.
-
Constructor Details
-
MexicoHelper
public MexicoHelper()
-
-
Method Details
-
getDesignPlanAsXML
Get xml representation of a design plan.- Parameters:
designPlan
- design planargs
- some meta information to put into generated xml (author, date, id, license)- Returns:
- xml design plan representation
-
writeDesignPlanToFile
Convert design plan to xml and write it to given file.- Parameters:
designPlan
-
-
getDesignPlanFromXML
public static DesignPlan getDesignPlanFromXML(File xmlFile, org.nuiton.topia.TopiaContext topiaContext) throws IOException Parse xmlFile with sax, and return aDesignPlan
.- Parameters:
xmlFile
- file path to parsetopiaContext
- database context- Returns:
- DesignPlan
- Throws:
IOException
-
formatXML
Format xml string.- Parameters:
unformattedXml
- non formatted xml string (must be valid xml)- Returns:
- xml, formatted and indented Code from http://stackoverflow.com/questions/139076/how-to-pretty-print-xml-from-java
- Throws:
IsisFishRuntimeException
IllegalArgumentException
- if input xml is not valid
-
getMatrixAsXML
Transform matrix into XML mexico format. Format is :<mx name="une matrice"> <dimension name="classe" size="2"> <label>jeune</label> <label>vieux</label> </dimension> <dimension name="x" size="3"> <label>0</label> <label>1</label> <label>2</label> </dimension> <d>2.0</d> <d>3.1415</d> <d>2.0</d> <d>3.1415</d> <d>2.0</d> <d>3.1415</d> </mx>
- Parameters:
matrix
- matrix- Returns:
- matrix as xml or
null
if matrix is null - Since:
- 3.3.0.0
-
appendString
Append object type and value in stringbuffer. Append it as :fqn(value)
- Parameters:
buffer
- buffer to append too
- value to append- Returns:
- stringbuffer
-
getMatrixFromXml
public static org.nuiton.math.matrix.MatrixND getMatrixFromXml(org.dom4j.Element mxElement, org.nuiton.topia.TopiaContext context) Parse a dom element (mx) as aMatrixND
. Format is :<mx name="une matrice"> <dimension name="classe" size="2"> <label>jeune</label> <label>vieux</label> </dimension> <dimension name="x" size="3"> <label>0</label> <label>1</label> <label>2</label> </dimension> <d>2.0</d> <d>3.1415</d> <d>2.0</d> <d>3.1415</d> <d>2.0</d> <d>3.1415</d> </mx>
- Parameters:
mxElement
- dom elementcontext
- topia context- Returns:
- matrix nd
-
getQualifiedName
Return object fully qualified name excepted forTopiaEntity
.- Parameters:
o
- object to get fqn- Returns:
- fqn for mexico file format
-
getRulesAsXml
Transform rules list as xml. Format is :<rules> <rule name="RuleName1"> <param key="rule.0.parameter.param1">param1</param> <param key="rule.0.parameter.pop">topiaId1</param> </rule> <rule name="RuleName2"> <param key="rule.0.parameter.param1">param2</param> <param key="rule.0.parameter.pop">topiaId2</param> </rule> </rules>
- Parameters:
rules
- rules list- Returns:
- rules as xml
-
getRulesFromXml
public static List<Rule> getRulesFromXml(org.dom4j.Element rulesElement, org.nuiton.topia.TopiaContext topiaContext) Parse xml as rules list. Format is :<rules> <rule name="RuleName1"> <param key="rule.0.parameter.param1">param1</param> <param key="rule.0.parameter.pop">topiaId1</param> </rule> <rule name="RuleName2"> <param key="rule.0.parameter.param1">param2</param> <param key="rule.0.parameter.pop">topiaId2</param> </rule> </rules>
- Parameters:
rulesElement
- rules dom elementtopiaContext
- topia context (for rules parameters)- Returns:
- rules as xml
-
getObjectFromString
Parse string content (human readable) to get isis fish instance for this object. For example:- Species:Nephrops
- Population:Anchois
- TimeStep:21
- ...
- Parameters:
content
- content to parsecontext
- context to database- Returns:
- object instance
-
getStringFromObject
Get string representation (human readable) for an object.- Parameters:
object
-- Returns:
- string representation
-