Package com.dtsx.astra.sdk.utils
Class AstraRc
java.lang.Object
com.dtsx.astra.sdk.utils.AstraRc
Utility class to load/save .astrarc file. This file is used to store Astra configuration.
- Author:
- Cedrick LUNVEN (@clunven)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ENV VAR to get part of the token: application token.static final String
Default filename we are looking for.static final String
Default filename we are looking for.static final String
line separator.static final String
Environment variable coding user home.static final String
line separator. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copySection
(String sectionOld, String sectionNew) Copy a section with all those key in another.void
createSectionWithToken
(String sectionName, String token) Create a section in the configuration file.boolean
deleteSection
(String sectionName) Delete a section is exist.Getter accessor for attribute 'configFile'.static String
Build default configuration filename.getSection
(String sectionName) Access a session from its name.getSectionKey
(String sectionName, String key) Read a key for a sectionGetter accessor for attribute 'sections'.static boolean
Assess if default config exist.boolean
isSectionExists
(String sectionName) Test session existence.void
renameSection
(String sectionOld, String sectionNew) Renaming a section (if exist)renderSection
(String sectionName) Display section as a string.Prepare file contentvoid
save()
Create configuration file with current sections.void
updateSectionKey
(String sectionName, String key, String value) Update only one key.
-
Field Details
-
ASTRARC_FILENAME
Default filename we are looking for.- See Also:
-
ASTRARC_DEFAULT
Default filename we are looking for.- See Also:
-
ENV_USER_HOME
Environment variable coding user home.- See Also:
-
ENV_LINE_SEPERATOR
line separator.- See Also:
-
LINE_SEPARATOR
line separator. -
ASTRA_DB_APPLICATION_TOKEN
ENV VAR to get part of the token: application token.- See Also:
-
-
Constructor Details
-
AstraRc
public AstraRc()Load from ~/.astrarc -
AstraRc
Load from specified file- Parameters:
fileName
- String
-
-
Method Details
-
isDefaultConfigFileExists
public static boolean isDefaultConfigFileExists()Assess if default config exist.- Returns:
- if default config exists
-
getDefaultConfigurationFileName
Build default configuration filename.- Returns:
- default configuration file name
-
isSectionExists
Test session existence.- Parameters:
sectionName
- section name- Returns:
- tell if the section exists
-
getSections
Getter accessor for attribute 'sections'.- Returns:
- current value of 'sections'
-
getSection
Access a session from its name.- Parameters:
sectionName
- section name- Returns:
- keys for this section
-
deleteSection
Delete a section is exist.- Parameters:
sectionName
- current name.- Returns:
- if delete or not
-
getSectionKey
Read a key for a section- Parameters:
sectionName
- Stringkey
- String- Returns:
- String
-
updateSectionKey
Update only one key.- Parameters:
sectionName
- Stringkey
- Stringvalue
- String
-
renameSection
Renaming a section (if exist)- Parameters:
sectionOld
- old namesectionNew
- new section name
-
copySection
Copy a section with all those key in another.- Parameters:
sectionOld
- old section namesectionNew
- new section name
-
save
public void save()Create configuration file with current sections. -
renderSections
Prepare file content- Returns:
- sections as a string
-
renderSection
Display section as a string.- Parameters:
sectionName
- name of section- Returns:
- section as a string
-
createSectionWithToken
Create a section in the configuration file.- Parameters:
sectionName
- current section nametoken
- token to authenticate
-
getConfigFile
Getter accessor for attribute 'configFile'.- Returns:
- current value of 'configFile'
-