Class ConfigReader
java.lang.Object
de.funfried.netbeans.plugins.external.formatter.eclipse.xml.ConfigReader
This class reads a config file for Eclipse code formatter.
- Author:
- bahlef
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetProfileNames
(String fileContent) getProfileSettings
(String fileContent, String profileName) Parses and returns the key/value pairs from the givenfileContent
for the givenprofileName
as aMap
.static String
readContentFromFilePath
(String filePath) Reads the content of the given file path and returns it as aString
.
-
Field Details
-
ATTRIBUTE_PROFILE_KIND
- See Also:
-
ATTRIBUTE_PROFILE_NAME
- See Also:
-
ATTRIBUTE_SETTING_ID
- See Also:
-
ATTRIBUTE_SETTING_VALUE
- See Also:
-
TAG_NAME_PROFILES
- See Also:
-
TAG_NAME_PROFILE
- See Also:
-
TAG_NAME_SETTING
- See Also:
-
PROFILE_KIND
- See Also:
-
-
Constructor Details
-
ConfigReader
public ConfigReader()
-
-
Method Details
-
readContentFromFilePath
Reads the content of the given file path and returns it as aString
.- Parameters:
filePath
- a file path- Returns:
- the content of the file at the fiven
filePath
- Throws:
IOException
- if there is an issue accessing the file at the given path
-
getProfileSettings
@NonNull public static Map<String,String> getProfileSettings(String fileContent, String profileName) throws ConfigReadException, ProfileNotFoundException, IOException, SAXException Parses and returns the key/value pairs from the givenfileContent
for the givenprofileName
as aMap
.- Parameters:
fileContent
- the file content to parseprofileName
- the profile name for which to get the settings- Returns:
- a
Map
within all the configuration paramters of the givenprofileName
read from the givenfileContent
, or throws an exception if there's a problem reading the input, e.g.: invalid XML. - Throws:
SAXException
- if there are parsing issuesIOException
- if there is an I/O issueConfigReadException
- if the givenfileContent
is not a valid Eclipse formatter templateProfileNotFoundException
- if no profile could be found with the givenprofileName
in the givenfileContent
-
getProfileNames
@NonNull public static List<String> getProfileNames(String fileContent) throws ConfigReadException, IOException, SAXException - Parameters:
fileContent
- the file content to parse- Returns:
- a
List
within all profile names found in the givenfileContent
- Throws:
SAXException
- if there are parsing issuesIOException
- if there is an I/O issueConfigReadException
- if the givenfileContent
is not a valid Eclipse formatter template
-