Package org.hl7.fhir.utilities
Class IniFile
- java.lang.Object
-
- org.hl7.fhir.utilities.IniFile
-
-
Constructor Summary
Constructors Constructor Description IniFile(InputStream stream)IniFile(String pstrPathAndName)Create a IniFile object from the file named in the parameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSection(String pstrSection, String pstrComments)Sets the comments associated with a section.String[]getAllSectionNames()Returns a string array containing names of all sections in INI file.BooleangetBooleanProperty(String pstrSection, String pstrProp)Returns the specified boolean property from the specified section.DategetDateProperty(String pstrSection, String pstrProp)Returns the specified date property from the specified section.DoublegetDoubleProperty(String pstrSection, String pstrProp)Returns the specified double property from the specified section.StringgetFileName()Returns the ini file name being used.IntegergetIntegerProperty(String pstrSection, String pstrProp)Returns the specified integer property from the specified section.LonggetLongProperty(String pstrSection, String pstrProp)Returns the specified long property from the specified section.Map<String,org.hl7.fhir.utilities.IniFile.INIProperty>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.StringgetStringProperty(String pstrSection, String pstrProp)Returns the specified string property from the specified section.DategetTimestampProperty(String pstrSection, String pstrProp)Returns the specified date property from the specified section.intgetTotalSections()booleanhasProperty(String section, String name)booleanhasSection(String sectionName)static voidmain(String[] pstrArgs)The 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 interpreat 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 pstrSection, String pstrProp, Timestamp ptsVal, String pstrComments)Sets the specified java.sql.Timestamp property.
-
-
-
Constructor Detail
-
IniFile
public IniFile(String pstrPathAndName)
Create a IniFile object from the file named in the parameter.- Parameters:
pstrPathAndName- The full path and name of the ini file to be used.
-
IniFile
public IniFile(InputStream stream)
-
-
Method Detail
-
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.- 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
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 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.
-
addSection
public void addSection(String pstrSection, String pstrComments)
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
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 pstrSection, String pstrProp, Timestamp ptsVal, String pstrComments)
Sets the specified java.sql.Timestamp property.- Parameters:
pstrSection- the INI section name.pstrProp- the property to be set.ptsVal- the timestamp value to be persisted.
-
setDateFormat
public void setDateFormat(String pstrDtFmt) throws IllegalArgumentException
Sets the format to be used to interpreat 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
public String[] 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)
-
-