com.threerings.getdown.util
Class ConfigUtil

java.lang.Object
  extended by com.threerings.getdown.util.ConfigUtil

public class ConfigUtil
extends Object

Parses a file containing key/value pairs and returns a HashMap with the values. Keys may be repeated, in which case they will be made to reference an array of values.


Constructor Summary
ConfigUtil()
           
 
Method Summary
static String[] getMultiValue(Map<String,Object> data, String name)
          Massages a single string into an array and leaves existing array values as is.
static Map<String,Object> parseConfig(File config, boolean checkPlatform)
          Parses a configuration file containing key/value pairs.
static List<String[]> parsePairs(File config, boolean checkPlatform)
          Parses a configuration file containing key/value pairs.
static List<String[]> parsePairs(Reader config, boolean checkPlatform)
          See parsePairs(File,boolean).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigUtil

public ConfigUtil()
Method Detail

parsePairs

public static List<String[]> parsePairs(File config,
                                        boolean checkPlatform)
                                 throws IOException
Parses a configuration file containing key/value pairs. The file must be in the UTF-8 encoding.

Parameters:
checkPlatform - if true, platform qualifiers will be used to filter out pairs that do not match the current platform; if false, all pairs will be returned.
Returns:
a list of String[] instances containing the key/value pairs in the order they were parsed from the file.
Throws:
IOException

parsePairs

public static List<String[]> parsePairs(Reader config,
                                        boolean checkPlatform)
                                 throws IOException
See parsePairs(File,boolean).

Throws:
IOException

parseConfig

public static Map<String,Object> parseConfig(File config,
                                             boolean checkPlatform)
                                      throws IOException
Parses a configuration file containing key/value pairs. The file must be in the UTF-8 encoding.

Returns:
a map from keys to values, where a value will be an array of strings if more than one key/value pair in the config file was associated with the same key.
Throws:
IOException

getMultiValue

public static String[] getMultiValue(Map<String,Object> data,
                                     String name)
Massages a single string into an array and leaves existing array values as is. Simplifies access to parameters that are expected to be arrays.



Copyright © 2013. All Rights Reserved.