rename ConfigUtil to ConfigImplUtil

Because I want to add a public ConfigUtil class.
This commit is contained in:
Havoc Pennington 2011-12-09 09:46:14 -05:00
parent 46c6d639b5
commit 694dd9bef5
16 changed files with 46 additions and 46 deletions

View File

@ -11,7 +11,7 @@ import java.util.Map;
import java.util.Properties;
import com.typesafe.config.impl.ConfigImpl;
import com.typesafe.config.impl.ConfigUtil;
import com.typesafe.config.impl.ConfigImplUtil;
import com.typesafe.config.impl.Parseable;
/**
@ -179,7 +179,7 @@ public final class ConfigFactory {
try {
return DefaultConfigHolder.defaultConfig;
} catch (ExceptionInInitializerError e) {
throw ConfigUtil.extractInitializerError(e);
throw ConfigImplUtil.extractInitializerError(e);
}
}

View File

@ -144,7 +144,7 @@ abstract class AbstractConfigValue implements ConfigValue, MergeableValue {
return canEqual(other)
&& (this.valueType() ==
((ConfigValue) other).valueType())
&& ConfigUtil.equalsHandlingNull(this.unwrapped(),
&& ConfigImplUtil.equalsHandlingNull(this.unwrapped(),
((ConfigValue) other).unwrapped());
} else {
return false;
@ -178,7 +178,7 @@ abstract class AbstractConfigValue implements ConfigValue, MergeableValue {
protected void render(StringBuilder sb, int indent, String atKey, boolean formatted) {
if (atKey != null) {
sb.append(ConfigUtil.renderJsonString(atKey));
sb.append(ConfigImplUtil.renderJsonString(atKey));
sb.append(" : ");
}
render(sb, indent, formatted);

View File

@ -189,7 +189,7 @@ final class ConfigDelayedMerge extends AbstractConfigValue implements
indent(sb, indent);
if (atKey != null) {
sb.append("# unmerged value " + i + " for key "
+ ConfigUtil.renderJsonString(atKey) + " from ");
+ ConfigImplUtil.renderJsonString(atKey) + " from ");
} else {
sb.append("# unmerged value " + i + " from ");
}
@ -200,7 +200,7 @@ final class ConfigDelayedMerge extends AbstractConfigValue implements
}
if (atKey != null) {
sb.append(ConfigUtil.renderJsonString(atKey));
sb.append(ConfigImplUtil.renderJsonString(atKey));
sb.append(" : ");
}
v.render(sb, indent, formatted);

View File

@ -334,7 +334,7 @@ public class ConfigImpl {
try {
return DefaultIncluderHolder.defaultIncluder;
} catch (ExceptionInInitializerError e) {
throw ConfigUtil.extractInitializerError(e);
throw ConfigImplUtil.extractInitializerError(e);
}
}
@ -352,7 +352,7 @@ public class ConfigImpl {
try {
return SystemPropertiesHolder.systemProperties;
} catch (ExceptionInInitializerError e) {
throw ConfigUtil.extractInitializerError(e);
throw ConfigImplUtil.extractInitializerError(e);
}
}
@ -388,7 +388,7 @@ public class ConfigImpl {
try {
return EnvVariablesHolder.envVariables;
} catch (ExceptionInInitializerError e) {
throw ConfigUtil.extractInitializerError(e);
throw ConfigImplUtil.extractInitializerError(e);
}
}
@ -410,7 +410,7 @@ public class ConfigImpl {
try {
return ReferenceHolder.referenceConfig;
} catch (ExceptionInInitializerError e) {
throw ConfigUtil.extractInitializerError(e);
throw ConfigImplUtil.extractInitializerError(e);
}
}
}

View File

@ -11,7 +11,7 @@ import com.typesafe.config.ConfigException;
/** This is public just for the "config" package to use, don't touch it */
final public class ConfigUtil {
final public class ConfigImplUtil {
static boolean equalsHandlingNull(Object a, Object b) {
if (a == null && b != null)
return false;

View File

@ -32,6 +32,6 @@ final class ConfigString extends AbstractConfigValue {
@Override
protected void render(StringBuilder sb, int indent, boolean formatted) {
sb.append(ConfigUtil.renderJsonString(value));
sb.append(ConfigImplUtil.renderJsonString(value));
}
}

View File

@ -266,7 +266,7 @@ final class ConfigSubstitution extends AbstractConfigValue implements
if (p instanceof SubstitutionExpression) {
sb.append(p.toString());
} else {
sb.append(ConfigUtil.renderJsonString((String) p));
sb.append(ConfigImplUtil.renderJsonString((String) p));
}
}
}

View File

@ -384,7 +384,7 @@ public abstract class Parseable implements ConfigParseable {
// we want file: URLs and files to always behave the same, so switch
// to a file if it's a file: URL
if (input.getProtocol().equals("file")) {
return newFile(ConfigUtil.urlToFile(input), options);
return newFile(ConfigImplUtil.urlToFile(input), options);
} else {
return new ParseableURL(input, options);
}

View File

@ -393,7 +393,7 @@ final class Parser {
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (!ConfigUtil.isWhitespace(c))
if (!ConfigImplUtil.isWhitespace(c))
return false;
}
return true;
@ -838,7 +838,7 @@ final class Parser {
// do something much faster than the full parser if
// we just have something like "foo" or "foo.bar"
private static Path speculativeFastParsePath(String path) {
String s = ConfigUtil.unicodeTrim(path);
String s = ConfigImplUtil.unicodeTrim(path);
if (s.isEmpty())
return null;
if (hasUnsafeChars(s))

View File

@ -125,7 +125,7 @@ final class Path {
if (other instanceof Path) {
Path that = (Path) other;
return this.first.equals(that.first)
&& ConfigUtil.equalsHandlingNull(this.remainder,
&& ConfigImplUtil.equalsHandlingNull(this.remainder,
that.remainder);
} else {
return false;
@ -167,7 +167,7 @@ final class Path {
private void appendToStringBuilder(StringBuilder sb) {
if (hasFunkyChars(first) || first.isEmpty())
sb.append(ConfigUtil.renderJsonString(first));
sb.append(ConfigImplUtil.renderJsonString(first));
else
sb.append(first);
if (remainder != null) {

View File

@ -466,10 +466,10 @@ final class SimpleConfig implements Config, MergeableValue {
*/
public static long parseDuration(String input,
ConfigOrigin originForException, String pathForException) {
String s = ConfigUtil.unicodeTrim(input);
String s = ConfigImplUtil.unicodeTrim(input);
String originalUnitString = getUnits(s);
String unitString = originalUnitString;
String numberString = ConfigUtil.unicodeTrim(s.substring(0, s.length()
String numberString = ConfigImplUtil.unicodeTrim(s.substring(0, s.length()
- unitString.length()));
TimeUnit units = null;
@ -618,9 +618,9 @@ final class SimpleConfig implements Config, MergeableValue {
*/
public static long parseBytes(String input, ConfigOrigin originForException,
String pathForException) {
String s = ConfigUtil.unicodeTrim(input);
String s = ConfigImplUtil.unicodeTrim(input);
String unitString = getUnits(s);
String numberString = ConfigUtil.unicodeTrim(s.substring(0,
String numberString = ConfigImplUtil.unicodeTrim(s.substring(0,
s.length() - unitString.length()));
// this would be caught later anyway, but the error message

View File

@ -97,7 +97,7 @@ final class SimpleConfigOrigin implements ConfigOrigin {
&& this.lineNumber == otherOrigin.lineNumber
&& this.endLineNumber == otherOrigin.endLineNumber
&& this.originType == otherOrigin.originType
&& ConfigUtil.equalsHandlingNull(this.urlOrNull, otherOrigin.urlOrNull);
&& ConfigImplUtil.equalsHandlingNull(this.urlOrNull, otherOrigin.urlOrNull);
} else {
return false;
}
@ -227,7 +227,7 @@ final class SimpleConfigOrigin implements ConfigOrigin {
}
String mergedURL;
if (ConfigUtil.equalsHandlingNull(a.urlOrNull, b.urlOrNull)) {
if (ConfigImplUtil.equalsHandlingNull(a.urlOrNull, b.urlOrNull)) {
mergedURL = a.urlOrNull;
} else {
mergedURL = null;
@ -252,7 +252,7 @@ final class SimpleConfigOrigin implements ConfigOrigin {
count += 1;
if (a.endLineNumber == b.endLineNumber)
count += 1;
if (ConfigUtil.equalsHandlingNull(a.urlOrNull, b.urlOrNull))
if (ConfigImplUtil.equalsHandlingNull(a.urlOrNull, b.urlOrNull))
count += 1;
}

View File

@ -159,11 +159,11 @@ final class Tokenizer {
}
static boolean isWhitespace(int c) {
return ConfigUtil.isWhitespace(c);
return ConfigImplUtil.isWhitespace(c);
}
static boolean isWhitespaceNotNewline(int c) {
return c != '\n' && ConfigUtil.isWhitespace(c);
return c != '\n' && ConfigImplUtil.isWhitespace(c);
}
private int slurpComment() {

View File

@ -152,7 +152,7 @@ final class Tokens {
return super.equals(other) && ((Problem) other).what.equals(what)
&& ((Problem) other).message.equals(message)
&& ((Problem) other).suggestQuotes == suggestQuotes
&& ConfigUtil.equalsHandlingNull(((Problem) other).cause, cause);
&& ConfigImplUtil.equalsHandlingNull(((Problem) other).cause, cause);
}
@Override

View File

@ -183,7 +183,7 @@ class JsonTest extends TestUtils {
@Test
def renderingJsonStrings() {
def r(s: String) = ConfigUtil.renderJsonString(s)
def r(s: String) = ConfigImplUtil.renderJsonString(s)
assertEquals(""""abcdefg"""", r("""abcdefg"""))
assertEquals(""""\" \\ \n \b \f \r \t"""", r("\" \\ \n \b \f \r \t"))
// control characters are escaped. Remember that unicode escapes

View File

@ -21,15 +21,15 @@ class UtilTest extends TestUtils {
@Test
def unicodeTrimSupplementaryChars() {
assertEquals("", ConfigUtil.unicodeTrim(""))
assertEquals("a", ConfigUtil.unicodeTrim("a"))
assertEquals("abc", ConfigUtil.unicodeTrim("abc"))
assertEquals("", ConfigUtil.unicodeTrim(" \n \n \u00A0 "))
assertEquals(supplementaryChars, ConfigUtil.unicodeTrim(supplementaryChars))
assertEquals("", ConfigImplUtil.unicodeTrim(""))
assertEquals("a", ConfigImplUtil.unicodeTrim("a"))
assertEquals("abc", ConfigImplUtil.unicodeTrim("abc"))
assertEquals("", ConfigImplUtil.unicodeTrim(" \n \n \u00A0 "))
assertEquals(supplementaryChars, ConfigImplUtil.unicodeTrim(supplementaryChars))
val s = " \u00A0 \n " + supplementaryChars + " \n \u00A0 "
val asciiTrimmed = s.trim()
val unitrimmed = ConfigUtil.unicodeTrim(s)
val unitrimmed = ConfigImplUtil.unicodeTrim(s)
assertFalse(asciiTrimmed.equals(unitrimmed))
assertEquals(supplementaryChars, unitrimmed)
@ -37,23 +37,23 @@ class UtilTest extends TestUtils {
@Test
def definitionOfWhitespace() {
assertTrue(ConfigUtil.isWhitespace(' '))
assertTrue(ConfigUtil.isWhitespace('\n'))
assertTrue(ConfigImplUtil.isWhitespace(' '))
assertTrue(ConfigImplUtil.isWhitespace('\n'))
// these three are nonbreaking spaces
assertTrue(ConfigUtil.isWhitespace('\u00A0'))
assertTrue(ConfigUtil.isWhitespace('\u2007'))
assertTrue(ConfigUtil.isWhitespace('\u202F'))
assertTrue(ConfigImplUtil.isWhitespace('\u00A0'))
assertTrue(ConfigImplUtil.isWhitespace('\u2007'))
assertTrue(ConfigImplUtil.isWhitespace('\u202F'))
// vertical tab, a weird one
assertTrue(ConfigUtil.isWhitespace('\u000B'))
assertTrue(ConfigImplUtil.isWhitespace('\u000B'))
// file separator, another weird one
assertTrue(ConfigUtil.isWhitespace('\u001C'))
assertTrue(ConfigImplUtil.isWhitespace('\u001C'))
}
@Test
def equalsThatHandlesNull() {
assertTrue(ConfigUtil.equalsHandlingNull(null, null))
assertFalse(ConfigUtil.equalsHandlingNull(new Object(), null))
assertFalse(ConfigUtil.equalsHandlingNull(null, new Object()))
assertTrue(ConfigUtil.equalsHandlingNull("", ""))
assertTrue(ConfigImplUtil.equalsHandlingNull(null, null))
assertFalse(ConfigImplUtil.equalsHandlingNull(new Object(), null))
assertFalse(ConfigImplUtil.equalsHandlingNull(null, new Object()))
assertTrue(ConfigImplUtil.equalsHandlingNull("", ""))
}
}