stevedlawrence commented on a change in pull request #343: WIP: Daf 2302 ext var
URL: https://github.com/apache/incubator-daffodil/pull/343#discussion_r400130270
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala
##########
@@ -232,31 +285,85 @@ class Compiler(var validateDFDLSchemas: Boolean = true)
* @param value The variable's value.
*
*/
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables.")
def setExternalDFDLVariable(name: String, namespace: String, value: String):
Unit = {
+ externalDFDLVariables = externalDFDLVariables.enqueue(getBinding(name,
namespace, value))
+ }
+
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables")
+ def withExternalDFDLVariable(name: String, namespace: String, value:
String): Compiler =
+ copy(externalDFDLVariables =
externalDFDLVariables.enqueue(getBinding(name, namespace, value)))
+
+ /**
+ * Supports binding external variables programatically from the API.
+ * @param name
+ * @param namespace
+ * @param value
+ * @return
+ */
+ private def getBinding(name: String, namespace: String, value: String):
Binding = {
// We must tolerate null here for namespace in order to be compatible with
Java
val ns = namespace match {
case null => None // Figure out the namespace
case _ => Some(NS(namespace))
}
val b = Binding(name, ns, value)
- externalDFDLVariables.enqueue(b)
+ b
}
- def setExternalDFDLVariable(variable: Binding) =
externalDFDLVariables.enqueue(variable)
- def setExternalDFDLVariables(variables: Seq[Binding]) = variables.foreach(b
=> setExternalDFDLVariable(b))
- def setExternalDFDLVariables(extVarsFile: File): Unit = {
- val extVars = ExternalVariablesLoader.getVariables(extVarsFile)
- setExternalDFDLVariables(extVars)
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables.")
+ def setExternalDFDLVariable(variable: Binding): Unit =
+ externalDFDLVariables = externalDFDLVariables.enqueue(variable)
+
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables.")
+ def withExternalDFDLVariable(variable: Binding): Compiler =
+ copy(externalDFDLVariables = externalDFDLVariables.enqueue(variable))
+
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables.")
+ def setExternalDFDLVariables(variables: Seq[Binding]): Unit =
+ variables.foreach(b => externalDFDLVariables =
externalDFDLVariables.enqueue(b))
+
+ @deprecated("2020-03-26", "Use DataProcessor.withExternalVariables.")
+ def withExternalDFDLVariables(variables: Seq[Binding]): Compiler =
+ withExternalDFDLVariablesImpl(variables)
Review comment:
Why add the two new withExternalDFDLVariables methods to then deprecate them?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services