-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial refactor for ConfigDocumentFactory
- Loading branch information
Showing
7 changed files
with
122 additions
and
92 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
sconfig/js/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala.js platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory extends ConfigDocumentFactoryShared {} |
6 changes: 6 additions & 0 deletions
6
...g/jvm-native/src/main/scala/org/ekrich/config/parser/ConfigDocumentFactoryJvmNative.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods common to JVM and Native | ||
*/ | ||
abstract class ConfigDocumentFactoryJvmNative extends ConfigDocumentFactoryShared {} |
6 changes: 6 additions & 0 deletions
6
sconfig/jvm/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala JVM platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory extends ConfigDocumentFactoryJvmNative {} |
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
sconfig/native/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala Native platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory extends ConfigDocumentFactoryJvmNative {} |
93 changes: 1 addition & 92 deletions
93
sconfig/shared/src/main/scala/org/ekrich/config/parser/ConfigDocumentFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,6 @@ | ||
package org.ekrich.config.parser | ||
|
||
import org.ekrich.config.ConfigParseOptions | ||
import org.ekrich.config.impl.Parseable | ||
import java.io.File | ||
import java.io.Reader | ||
|
||
/** | ||
* Factory for creating [[org.ekrich.config.parser.ConfigDocument]] instances. | ||
*/ | ||
object ConfigDocumentFactory { | ||
|
||
/** | ||
* Parses a Reader into a ConfigDocument instance. | ||
* | ||
* @param reader | ||
* the reader to parse | ||
* @param options | ||
* parse options to control how the reader is interpreted | ||
* @return | ||
* the parsed configuration | ||
* @throws ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseReader(reader: Reader, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newReader(reader, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a reader into a Config instance as with | ||
* [[#parseReader(reader:java\.io\.Reader,options:org\.ekrich\.config\.ConfigParseOptions)* parseReader(Reader, ConfigParseOptions)]] | ||
* but always uses the default parse options. | ||
* | ||
* @param reader | ||
* the reader to parse | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseReader(reader: Reader): ConfigDocument = | ||
parseReader(reader, ConfigParseOptions.defaults) | ||
|
||
/** | ||
* Parses a file into a ConfigDocument instance. | ||
* | ||
* @param file | ||
* the file to parse | ||
* @param options | ||
* parse options to control how the file is interpreted | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseFile(file: File, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newFile(file, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a file into a ConfigDocument instance as with | ||
* [[#parseFile(file:java\.io\.File,options:org\.ekrich\.config\.ConfigParseOptions)* parseFile(File, ConfigParseOptions)]] | ||
* but always uses the default parse options. | ||
* | ||
* @param file | ||
* the file to parse | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseFile(file: File): ConfigDocument = | ||
parseFile(file, ConfigParseOptions.defaults) | ||
|
||
/** | ||
* Parses a string which should be valid HOCON or JSON. | ||
* | ||
* @param s | ||
* string to parse | ||
* @param options | ||
* parse options | ||
* @return | ||
* the parsed configuration | ||
*/ | ||
def parseString(s: String, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newString(s, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a string (which should be valid HOCON or JSON). Uses the default | ||
* parse options. | ||
* | ||
* @param s | ||
* string to parse | ||
* @return | ||
* the parsed configuration | ||
*/ | ||
def parseString(s: String): ConfigDocument = | ||
parseString(s, ConfigParseOptions.defaults) | ||
} | ||
object ConfigDocumentFactory extends PlatformConfigDocumentFactory {} |
97 changes: 97 additions & 0 deletions
97
sconfig/shared/src/main/scala/org/ekrich/config/parser/ConfigDocumentFactoryShared.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package org.ekrich.config.parser | ||
|
||
import org.ekrich.config.ConfigParseOptions | ||
import org.ekrich.config.impl.Parseable | ||
import java.io.File | ||
import java.io.Reader | ||
|
||
/** | ||
* Shared Factory methods for creating [[org.ekrich.config.parser.ConfigDocument]] instances. | ||
*/ | ||
abstract class ConfigDocumentFactoryShared { | ||
|
||
/** | ||
* Parses a Reader into a ConfigDocument instance. | ||
* | ||
* @param reader | ||
* the reader to parse | ||
* @param options | ||
* parse options to control how the reader is interpreted | ||
* @return | ||
* the parsed configuration | ||
* @throws ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseReader(reader: Reader, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newReader(reader, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a reader into a Config instance as with | ||
* [[#parseReader(reader:java\.io\.Reader,options:org\.ekrich\.config\.ConfigParseOptions)* parseReader(Reader, ConfigParseOptions)]] | ||
* but always uses the default parse options. | ||
* | ||
* @param reader | ||
* the reader to parse | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseReader(reader: Reader): ConfigDocument = | ||
parseReader(reader, ConfigParseOptions.defaults) | ||
|
||
/** | ||
* Parses a file into a ConfigDocument instance. | ||
* | ||
* @param file | ||
* the file to parse | ||
* @param options | ||
* parse options to control how the file is interpreted | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseFile(file: File, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newFile(file, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a file into a ConfigDocument instance as with | ||
* [[#parseFile(file:java\.io\.File,options:org\.ekrich\.config\.ConfigParseOptions)* parseFile(File, ConfigParseOptions)]] | ||
* but always uses the default parse options. | ||
* | ||
* @param file | ||
* the file to parse | ||
* @return | ||
* the parsed configuration | ||
* @throws org.ekrich.config.ConfigException | ||
* on IO or parse errors | ||
*/ | ||
def parseFile(file: File): ConfigDocument = | ||
parseFile(file, ConfigParseOptions.defaults) | ||
|
||
/** | ||
* Parses a string which should be valid HOCON or JSON. | ||
* | ||
* @param s | ||
* string to parse | ||
* @param options | ||
* parse options | ||
* @return | ||
* the parsed configuration | ||
*/ | ||
def parseString(s: String, options: ConfigParseOptions): ConfigDocument = | ||
Parseable.newString(s, options).parseConfigDocument() | ||
|
||
/** | ||
* Parses a string (which should be valid HOCON or JSON). Uses the default | ||
* parse options. | ||
* | ||
* @param s | ||
* string to parse | ||
* @return | ||
* the parsed configuration | ||
*/ | ||
def parseString(s: String): ConfigDocument = | ||
parseString(s, ConfigParseOptions.defaults) | ||
} |