org.ekrich.config.impl.ConfigNodeSimpleValue.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sconfig_sjs1.0-RC2_2.13 Show documentation
Show all versions of sconfig_sjs1.0-RC2_2.13 Show documentation
Configuration library for Scala using HOCON files
The newest version!
/**
* Copyright (C) 2015 Typesafe Inc.
*/
package org.ekrich.config.impl
import org.ekrich.config.ConfigException
import java.{util => ju}
final class ConfigNodeSimpleValue private[impl] (val token: Token)
extends AbstractConfigNodeValue {
override def tokens: ju.Collection[Token] =
ju.Collections.singletonList(token)
private[impl] def value: AbstractConfigValue = {
if (Tokens.isValue(token)) return Tokens.getValue(token)
else if (Tokens.isUnquotedText(token))
return new ConfigString.Unquoted(
token.origin,
Tokens.getUnquotedText(token)
)
else if (Tokens.isSubstitution(token)) {
val expression =
Tokens.getSubstitutionPathExpression(token)
val path =
PathParser.parsePathExpression(expression.iterator, token.origin)
val optional = Tokens.getSubstitutionOptional(token)
return new ConfigReference(
token.origin,
new SubstitutionExpression(path, optional)
)
}
throw new ConfigException.BugOrBroken(
"ConfigNodeSimpleValue did not contain a valid value token"
)
}
}