Package org.hl7.fhir.utilities
Class IniFile
java.lang.Object
org.hl7.fhir.utilities.IniFile
IniFile class provides methods for manipulating (Read/Write) windows ini files.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Prasad P. Khandekar
-
Constructor Summary
ConstructorsConstructorDescriptionIniFile(InputStream stream) Create a IniFile object from the file named in the parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSection(String pstrSection, String pstrComments) Sets the comments associated with a section.String[]Returns a string array containing names of all sections in INI file.getBooleanProperty(String pstrSection, String pstrProp) Returns the specified boolean property from the specified section.getDateProperty(String pstrSection, String pstrProp) Returns the specified date property from the specified section.getDoubleProperty(String pstrSection, String pstrProp) Returns the specified double property from the specified section.Returns the ini file name being used.getIntegerProperty(String pstrSection, String pstrProp) Returns the specified integer property from the specified section.getLongProperty(String pstrSection, String pstrProp) Returns the specified long property from the specified section.getProperties(String pstrSection) Returns a map containing all the properties under specified section.String[]getPropertyNames(String pstrSection) Returns a string array containing names of all the properties under specified section.getStringProperty(String pstrSection, String pstrProp) Returns the specified string property from the specified section.getTimestampProperty(String iniSectionName, String propertyKey) Returns the specified date property from the specified section.intbooleanhasProperty(String section, String name) booleanhasSection(String sectionName) static voidThe main entry point for testing.voidremoveProperty(String pstrSection, String pstrProp) Removed specified property from the specified section.voidremoveSection(String pstrSection) Removes the specified section if one exists, otherwise does nothing.booleansave()Flush changes back to the disk file.booleansave(OutputStream stream) voidsetBooleanProperty(String pstrSection, String pstrProp, boolean pblnVal, String pstrComments) Sets the specified boolean property.voidsetDateFormat(String pstrDtFmt) Sets the format to be used to interpret date values.voidsetDateProperty(String pstrSection, String pstrProp, Date pdtVal, String pstrComments) Sets the specified java.util.Date property.voidsetDoubleProperty(String pstrSection, String pstrProp, double pdblVal, String pstrComments) Sets the specified double property.voidsetIntegerProperty(String pstrSection, String pstrProp, int pintVal, String pstrComments) Sets the specified integer property.voidsetLongProperty(String pstrSection, String pstrProp, long plngVal, String pstrComments) Sets the specified long property.voidsetStringProperty(String pstrSection, String pstrProp, String pstrVal, String pstrComments) Sets the specified string property.voidsetTimeStampFormat(String pstrTSFmt) Sets the format to be used to interpreat timestamp values.voidsetTimestampProperty(String iniSection, String propertyKey, ZonedDateTime propertyValue, String propertyComments) Sets the specified java.sql.Timestamp property.
-
Constructor Details
-
IniFile
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
-
-
Method Details
-
getFileName
Returns the ini file name being used.- Returns:
- the INI file name.
-
getStringProperty
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
Returns the specified boolean property from the specified section. This method considers the following values as boolean values.- YES/yes/Yes - boolean true
- NO/no/No - boolean false
- 1 - boolean true
- 0 - boolean false
- TRUE/True/true - boolean true
- FALSE/False/false - boolean false
- Parameters:
pstrSection- the INI section name.pstrProp- the property to be retrieved.- Returns:
- the boolean value
-
getIntegerProperty
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
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
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
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
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
Sets the comments associated with a section.- Parameters:
pstrSection- the section namepstrComments- 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
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
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
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
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
-
getAllSectionNames
Returns a string array containing names of all sections in INI file.- Returns:
- the string array of section names
-
getPropertyNames
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
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
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
Removes the specified section if one exists, otherwise does nothing.- Parameters:
pstrSection- the name of the section to be removed.
-
save
Flush changes back to the disk file. If the disk file does not exists then creates the new one. -
save
-
main
The main entry point for testing.- Parameters:
pstrArgs- the command line arguments array if any.
-
hasSection
-
hasProperty
-