Package de.labathome

Class FortranNamelist

java.lang.Object
de.labathome.FortranNamelist

public class FortranNamelist extends Object
Class to parse Fortran namelists into Java classes. This uses the information given in the class definition to constrain the parser.
Version:
0.9.0 2018-07-25 intial implementation, 1.0.1 2018-09-11 1d and 2d arrays with fancy specifiers
Author:
Jonathan Schilling (jonathan.schilling@mail.de)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    set to true to be enable verbal diarrhea with lots of debug output
  • Constructor Summary

    Constructors
    Constructor
    Description
    FortranNamelist(String _namelist, String _groupName, Object _parseInto)
    Define parser for group groupName from the namelist given as text in namelist according to the Object definition given as parseInto.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    allowedArrayIndex(int minIdx, int maxIdx, int idxToCheck, String varname)
    Check index boundaries for inserting values into array; named version.
    Call the parser and return the parsed Object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _debug

      public boolean _debug
      set to true to be enable verbal diarrhea with lots of debug output
  • Constructor Details

    • FortranNamelist

      public FortranNamelist(String _namelist, String _groupName, Object _parseInto)
      Define parser for group groupName from the namelist given as text in namelist according to the Object definition given as parseInto.
      Parameters:
      _namelist - String containing the namelist
      _groupName - group name of the group to be parsed into the object parseInto
      _parseInto - Object definition for parsing target. Use annotation namelist_variable(name="lstell_sym") to specify which variables to parse. name is optional (default=take variable name as identifier in namelist) and can be used to map from Fortran names (e.g. lstell_sym) to your own defitions (e.g. stellaratorSymmetric).
  • Method Details

    • getParsed

      public Object getParsed()
      Call the parser and return the parsed Object.
      Returns:
      Object of same type as parseInto with member variables filled out as stated in namelist.
    • allowedArrayIndex

      public static boolean allowedArrayIndex(int minIdx, int maxIdx, int idxToCheck, String varname)
      Check index boundaries for inserting values into array; named version.
      Parameters:
      minIdx - minimum allowable index, i.e. 0 for int[] a = int[10];
      maxIdx - maximum allowable index, i.e. 9 for int[] a = int[10];
      idxToCheck - index to check, i.e. 5 or 11
      varname - name of variable to be included in error message for debugging
      Returns:
      true: idxToCheck within bounds (i.e. for idxToCheck=5); false if not (i.e. for idxToCheck=11)