Class JSONUtil


  • public class JSONUtil
    extends Object
    • Constructor Detail

      • JSONUtil

        public JSONUtil()
    • Method Detail

      • readConfigurationsFromBundle

        public static BundleState readConfigurationsFromBundle​(BinUtil.ResourceProvider provider,
                                                               Set<String> paths,
                                                               JSONUtil.Report report)
        Read all configurations from a bundle
        Parameters:
        provider - The bundle provider
        paths - The paths to read from
        report - The report for errors and warnings
        Returns:
        The bundle state.
      • readJSON

        public static ConfigurationFile readJSON​(BinaryManager binaryManager,
                                                 String name,
                                                 URL url,
                                                 long bundleId,
                                                 String contents,
                                                 JSONUtil.Report report)
        Read a single JSON file
        Parameters:
        binaryManager - The binary manager
        name - The name of the file
        url - The url to that file or null
        bundleId - The bundle id of the bundle containing the file
        contents - The contents of the file
        report - The report for errors and warnings
        Returns:
        The configuration file or null.
      • createModel

        public static List<Config> createModel​(BinaryManager binaryManager,
                                               long bundleId,
                                               org.apache.felix.cm.json.io.ConfigurationResource rsrc,
                                               Map<String,​Integer> rankingMap,
                                               Map<String,​ConfigPolicy> policyMap)
        Create the model
        Parameters:
        binaryManager - The binary manager
        bundleId - The bundle id
        rsrc - The map containing the configurations
        rankingMap - The map with ranking information
        policyMap - The map with policy information
        Returns:
        The list of Configs
      • getResource

        public static String getResource​(String name,
                                         URL url)
                                  throws IOException
        Read the contents of a resource, encoded as UTF-8
        Parameters:
        name - The resource name
        url - The resource URL
        Returns:
        The contents
        Throws:
        IOException - If anything goes wrong