java.lang.Object
de.funfried.netbeans.plugins.external.formatter.eclipse.xml.ConfigReader

public class ConfigReader extends Object
This class reads a config file for Eclipse code formatter.
Author:
bahlef
  • Field Details

  • Constructor Details

    • ConfigReader

      public ConfigReader()
  • Method Details

    • readContentFromFilePath

      @NonNull public static String readContentFromFilePath(String filePath) throws IOException
      Reads the content of the given file path and returns it as a String.
      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 given fileContent for the given profileName as a Map.
      Parameters:
      fileContent - the file content to parse
      profileName - the profile name for which to get the settings
      Returns:
      a Map within all the configuration paramters of the given profileName read from the given fileContent, or throws an exception if there's a problem reading the input, e.g.: invalid XML.
      Throws:
      SAXException - if there are parsing issues
      IOException - if there is an I/O issue
      ConfigReadException - if the given fileContent is not a valid Eclipse formatter template
      ProfileNotFoundException - if no profile could be found with the given profileName in the given fileContent
    • getProfileNames

      @NonNull public static List<String> getProfileNames(String fileContent) throws ConfigReadException, IOException, SAXException
      Parses the given fileContent and returns a List within all profile names found in that fileContent.
      Parameters:
      fileContent - the file content to parse
      Returns:
      a List within all profile names found in the given fileContent
      Throws:
      SAXException - if there are parsing issues
      IOException - if there is an I/O issue
      ConfigReadException - if the given fileContent is not a valid Eclipse formatter template