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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected static StringBufferappendString(StringBuffer buffer, Object o) Append object type and value in stringbuffer.static StringFormat xml string.static StringgetDesignPlanAsXML(DesignPlan designPlan, String... args) Get xml representation of a design plan.static DesignPlangetDesignPlanFromXML(File xmlFile, org.nuiton.topia.TopiaContext topiaContext) Parse xmlFile with sax, and return aDesignPlan.static StringgetMatrixAsXML(org.nuiton.math.matrix.MatrixND matrix) Transform matrix into XML mexico format.static org.nuiton.math.matrix.MatrixNDgetMatrixFromXml(org.dom4j.Element mxElement, org.nuiton.topia.TopiaContext context) Parse a dom element (mx) as aMatrixND.static ObjectgetObjectFromString(String content, org.nuiton.topia.TopiaContext context) Parse string content (human readable) to get isis fish instance for this object.protected static StringReturn object fully qualified name excepted forTopiaEntity.static StringgetRulesAsXml(List<Rule> rules) Transform rules list as xml.getRulesFromXml(org.dom4j.Element rulesElement, org.nuiton.topia.TopiaContext topiaContext) Parse xml as rules list.static StringgetStringFromObject(Object object) Get string representation (human readable) for an object.static voidwriteDesignPlanToFile(File file, DesignPlan designPlan) Convert design plan to xml and write it to given file.
- 
Constructor Details- 
MexicoHelperpublic MexicoHelper()
 
- 
- 
Method Details- 
getDesignPlanAsXMLGet xml representation of a design plan.- Parameters:
- designPlan- design plan
- args- some meta information to put into generated xml (author, date, id, license)
- Returns:
- xml design plan representation
 
- 
writeDesignPlanToFileConvert design plan to xml and write it to given file.- Parameters:
- designPlan-
 
- 
getDesignPlanFromXMLpublic static DesignPlan getDesignPlanFromXML(File xmlFile, org.nuiton.topia.TopiaContext topiaContext) throws IOException Parse xmlFile with sax, and return aDesignPlan.- Parameters:
- xmlFile- file path to parse
- topiaContext- database context
- Returns:
- DesignPlan
- Throws:
- IOException
 
- 
formatXMLFormat 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
 
- 
getMatrixAsXMLTransform 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 nullif matrix is null
- Since:
- 3.3.0.0
 
- 
appendStringAppend object type and value in stringbuffer. Append it as :fqn(value) - Parameters:
- buffer- buffer to append to
- o- value to append
- Returns:
- stringbuffer
 
- 
getMatrixFromXmlpublic 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 element
- context- topia context
- Returns:
- matrix nd
 
- 
getQualifiedNameReturn object fully qualified name excepted forTopiaEntity.- Parameters:
- o- object to get fqn
- Returns:
- fqn for mexico file format
 
- 
getRulesAsXmlTransform 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
 
- 
getRulesFromXmlpublic 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 element
- topiaContext- topia context (for rules parameters)
- Returns:
- rules as xml
 
- 
getObjectFromStringParse string content (human readable) to get isis fish instance for this object. For example:- Species:Nephrops
- Population:Anchois
- TimeStep:21
- ...
 - Parameters:
- content- content to parse
- context- context to database
- Returns:
- object instance
 
- 
getStringFromObjectGet string representation (human readable) for an object.- Parameters:
- object-
- Returns:
- string representation
 
 
-