Class IniFile

java.lang.Object
org.hl7.fhir.utilities.IniFile

public final class IniFile extends Object
IniFile class provides methods for manipulating (Read/Write) windows ini files.
Since:
1.0
Version:
1.0
Author:
Prasad P. Khandekar
  • Constructor Details

    • IniFile

      public IniFile(String pathname)
      Create a IniFile object from the file named in the parameter.
      Parameters:
      pathname - The full path and name of the ini file to be used.
    • IniFile

      public IniFile(InputStream stream)
  • Method Details

    • getFileName

      public String getFileName()
      Returns the ini file name being used.
      Returns:
      the INI file name.
    • getStringProperty

      public String getStringProperty(String pstrSection, String pstrProp)
      Returns the specified string property from the specified section.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the string property value.
    • getBooleanProperty

      public Boolean getBooleanProperty(String pstrSection, String pstrProp)
      Returns the specified boolean property from the specified section. This method considers the following values as boolean values.
      1. YES/yes/Yes - boolean true
      2. NO/no/No - boolean false
      3. 1 - boolean true
      4. 0 - boolean false
      5. TRUE/True/true - boolean true
      6. FALSE/False/false - boolean false
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the boolean value
    • getIntegerProperty

      public Integer getIntegerProperty(String pstrSection, String pstrProp)
      Returns the specified integer property from the specified section.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the integer property value.
    • getLongProperty

      public Long getLongProperty(String pstrSection, String pstrProp)
      Returns the specified long property from the specified section.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the long property value.
    • getDoubleProperty

      public Double getDoubleProperty(String pstrSection, String pstrProp)
      Returns the specified double property from the specified section.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the double property value.
    • getDateProperty

      public Date getDateProperty(String pstrSection, String pstrProp)
      Returns the specified date property from the specified section.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be retrieved.
      Returns:
      the date property value.
    • getTimestampProperty

      public Date getTimestampProperty(String iniSectionName, String propertyKey)
      Returns the specified date property from the specified section.
      Parameters:
      iniSectionName - the INI section name.
      propertyKey - the property to be retrieved.
      Returns:
      the date property value.
    • addSection

      public void addSection(String pstrSection, String pstrComments)
      Sets the comments associated with a section.
      Parameters:
      pstrSection - the section name
      pstrComments - the comments.
    • setStringProperty

      public void setStringProperty(String pstrSection, String pstrProp, String pstrVal, String pstrComments)
      Sets the specified string property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
    • setBooleanProperty

      public void setBooleanProperty(String pstrSection, String pstrProp, boolean pblnVal, String pstrComments)
      Sets the specified boolean property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
      pblnVal - the boolean value to be persisted
    • setIntegerProperty

      public void setIntegerProperty(String pstrSection, String pstrProp, int pintVal, String pstrComments)
      Sets the specified integer property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
      pintVal - the int property to be persisted.
    • setLongProperty

      public void setLongProperty(String pstrSection, String pstrProp, long plngVal, String pstrComments)
      Sets the specified long property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
      plngVal - the long value to be persisted.
    • setDoubleProperty

      public void setDoubleProperty(String pstrSection, String pstrProp, double pdblVal, String pstrComments)
      Sets the specified double property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
      pdblVal - the double value to be persisted.
    • setDateProperty

      public void setDateProperty(String pstrSection, String pstrProp, Date pdtVal, String pstrComments)
      Sets the specified java.util.Date property.
      Parameters:
      pstrSection - the INI section name.
      pstrProp - the property to be set.
      pdtVal - the date value to be persisted.
    • setTimestampProperty

      public void setTimestampProperty(String iniSection, String propertyKey, ZonedDateTime propertyValue, String propertyComments)
      Sets the specified java.sql.Timestamp property.
      Parameters:
      iniSection - the INI section name.
      propertyKey - the property to be set.
      propertyValue - the timestamp value to be persisted.
    • setDateFormat

      public void setDateFormat(String pstrDtFmt) throws IllegalArgumentException
      Sets the format to be used to interpret date values.
      Parameters:
      pstrDtFmt - the format string
      Throws:
      IllegalArgumentException - if the if the given pattern is invalid
    • setTimeStampFormat

      public void setTimeStampFormat(String pstrTSFmt)
      Sets the format to be used to interpreat timestamp values.
      Parameters:
      pstrTSFmt - the format string
      Throws:
      IllegalArgumentException - if the if the given pattern is invalid
    • getTotalSections

      public int getTotalSections()
    • getAllSectionNames

      Returns a string array containing names of all sections in INI file.
      Returns:
      the string array of section names
    • getPropertyNames

      public String[] getPropertyNames(String pstrSection)
      Returns a string array containing names of all the properties under specified section.
      Parameters:
      pstrSection - the name of the section for which names of properties is to be retrieved.
      Returns:
      the string array of property names.
    • getProperties

      public Map<String,org.hl7.fhir.utilities.IniFile.INIProperty> getProperties(String pstrSection)
      Returns a map containing all the properties under specified section.
      Parameters:
      pstrSection - the name of the section for which properties are to be retrieved.
      Returns:
      the map of properties.
    • removeProperty

      public void removeProperty(String pstrSection, String pstrProp)
      Removed specified property from the specified section. If the specified section or the property does not exist, does nothing.
      Parameters:
      pstrSection - the section name.
      pstrProp - the name of the property to be removed.
    • removeSection

      public void removeSection(String pstrSection)
      Removes the specified section if one exists, otherwise does nothing.
      Parameters:
      pstrSection - the name of the section to be removed.
    • save

      public boolean save()
      Flush changes back to the disk file. If the disk file does not exists then creates the new one.
    • save

      public boolean save(OutputStream stream)
    • main

      public static void main(String[] pstrArgs)
      The main entry point for testing.
      Parameters:
      pstrArgs - the command line arguments array if any.
    • hasSection

      public boolean hasSection(String sectionName)
    • hasProperty

      public boolean hasProperty(String section, String name)