fr.ifremer.isisfish.mexico
Class MexicoHelper

java.lang.Object
  extended by fr.ifremer.isisfish.mexico.MexicoHelper

public class MexicoHelper
extends Object

Mexico helper class.

Since:
3.2.0.4 Last update : $Date: 2012-04-03 15:31:36 +0200 (Tue, 03 Apr 2012) $ By : $Author: echatellier $
Version:
$Revision: 3671 $
Author:
chatellier

Constructor Summary
MexicoHelper()
           
 
Method Summary
protected static StringBuffer appendString(StringBuffer buffer, Object o)
          Append object type and value in stringbuffer.
static String formatXML(String unformattedXml)
          Format xml string.
static String getDesignPlanAsXML(DesignPlan designPlan)
          Get xml representation of a design plan.
static DesignPlan getDesignPlanFromXML(File xmlFile, org.nuiton.topia.TopiaContext topiaContext)
          Parse xmlFile with sax, and return a DesignPlan.
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 a MatrixND.
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 getQualifiedName(Object o)
          Return object fully qualified name excepted for TopiaEntity.
static String getRulesAsXml(List<Rule> rules)
          Transform rules list as xml.
static List<Rule> 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MexicoHelper

public MexicoHelper()
Method Detail

getDesignPlanAsXML

public static String getDesignPlanAsXML(DesignPlan designPlan)
Get xml representation of a design plan.

Parameters:
designPlan - design plan
Returns:
xml design plan representation

getDesignPlanFromXML

public static DesignPlan getDesignPlanFromXML(File xmlFile,
                                              org.nuiton.topia.TopiaContext topiaContext)
                                       throws IOException
Parse xmlFile with sax, and return a DesignPlan.

Parameters:
xmlFile - file path to parse
topiaContext - database context
Returns:
DesignPlan
Throws:
IOException

formatXML

public static String formatXML(String unformattedXml)
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

public static String getMatrixAsXML(org.nuiton.math.matrix.MatrixND matrix)
Transform matrix into XML mexico format. Format is :
   
    
      
      
    
    
      
      
      
    
    2.0
    3.1415
    2.0
    3.1415
    2.0
    3.1415
  
 

Parameters:
matrix - matrix
Returns:
matrix as xml or null if matrix is null
Since:
3.3.0.0

appendString

protected static StringBuffer appendString(StringBuffer buffer,
                                           Object o)
Append object type and value in stringbuffer. Append it as :
fqn(value)

Parameters:
buffer - buffer to append to
o - 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 a MatrixND. Format is :
   
    
      
      
    
    
      
      
      
    
    2.0
    3.1415
    2.0
    3.1415
    2.0
    3.1415
  
 

Parameters:
mxElement - dom element
context - topia context
Returns:
matrix nd

getQualifiedName

protected static String getQualifiedName(Object o)
Return object fully qualified name excepted for TopiaEntity.

Parameters:
o - object to get fqn
Returns:
fqn for mexico file format

getRulesAsXml

public static String getRulesAsXml(List<Rule> rules)
Transform rules list as xml. Format is :
  
    
      param1
      topiaId1
    
    
      param2
      topiaId2
    
  
 

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 :
  
    
      param1
      topiaId1
    
    
      param2
      topiaId2
    
  
 

Parameters:
rulesElement - rules dom element
topiaContext - topia context (for rules parameters)
Returns:
rules as xml

getObjectFromString

public static Object getObjectFromString(String content,
                                         org.nuiton.topia.TopiaContext context)
Parse string content (human readable) to get isis fish instance for this object. For example:

Parameters:
content - content to parse
context - context to database
Returns:
object instance

getStringFromObject

public static String getStringFromObject(Object object)
Get string representation (human readable) for an object.

Parameters:
object -
Returns:
string representation


Copyright © 1999-2012 CodeLutin. All Rights Reserved.