Class DataFileUtils

java.lang.Object
repast.simphony.integration.DataFileUtils

public class DataFileUtils extends Object
Class with some functions that can be used for working with data files.
Author:
Jerry Vos
  • Field Details

  • Constructor Details

    • DataFileUtils

      public DataFileUtils()
  • Method Details

    • loadDescriptor

      public static org.jdom.Document loadDescriptor(String fileName) throws org.jdom.JDOMException, IOException
      Loads in a descriptor file and returns the resulting Document. This will set the schema explicitly to the one found in the current package called SCHEMA_FILE_NAME, so the file need not have the schema specified.
      Parameters:
      fileName - the name of the descriptor file
      Returns:
      a Document object corresponding to the specified descriptor file
      Throws:
      org.jdom.JDOMException - if there was an error inside JDOM
      IOException - if there was an error reading
      RunTimeException - if the file cannot be found
    • findBestValue

      public static String findBestValue(Queryable queryable, org.jdom.Element nodeToHandle, String attributeName, boolean useXPath)
      Tries to retrieve an attribute from the nodeToHandle based on the target. If useXPath is true it then will query the Queryable using it's selectNode function and return the result of the Queryable's getValue on that result (or null if the result is null). If useXPath is false it will skip the XPath/Queryable steps and just return the toString of the attribute's value.
      Parameters:
      queryable - the queryable source for fetching values from
      element - the element to fetch the target from
      attributeName - the attribute's name.
      Returns:
      a value as speciied
    • findExplicitTargetParent

      public static Object findExplicitTargetParent(Queryable queryable, String targetPath)
      Parameters:
      queryable - the queryable source for fetching values from
      targetPath -
      Returns:
      a value as speciied
    • getName

      public static String getName(String targetPath)
      Parameters:
      targetPath -
      Returns:
      a value as speciied
    • isGarbage

      public static boolean isGarbage(String string)
      Checks if a string is null or "".
      Parameters:
      string - a string to check
      Returns:
      true if the string is either null or equal to ""
    • findBestValue

      public static String findBestValue(Queryable queryable, org.jdom.Element element, String attributeName)
      Same as findBestValue(queryable, element, attributeName, true)
      See Also:
    • main

      public static void main(String[] args)