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
FieldsModifier and TypeFieldDescriptionstatic final StringENV VAR to get part of the token: application token.static final StringKey to add tarfet environment.static final StringDefault filename we are looking for.static final StringDefault filename we are looking for.static final Stringline separator.static final StringEnvironment variable coding user home.static final Stringline separator. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopySection(String sectionOld, String sectionNew) Copy a section with all those key in another.voidcreateSectionWithToken(String sectionName, String token) Create a section in the configuration file.booleandeleteSection(String sectionName) Delete a section is exist.Getter accessor for attribute 'configFile'.static StringBuild 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 booleanAssess if default config exist.booleanisSectionExists(String sectionName) Test session existence.voidrenameSection(String sectionOld, String sectionNew) Renaming a section (if exist)renderSection(String sectionName) Display section as a string.Prepare file contentvoidsave()Create configuration file with current sections.voidupdateSectionKey(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:
-
ASTRA_ENV
Key to add tarfet environment.- 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'
-