mbeckerle commented on a change in pull request #343: WIP: Daf 2302 ext var
URL: https://github.com/apache/incubator-daffodil/pull/343#discussion_r399600899
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DataProcessor.scala
##########
@@ -114,70 +150,156 @@ class DataProcessor(
// not configure the size of the regex match buffers.
@transient lazy val regexMatchState = new ThreadLocal[(CharBuffer,
LongBuffer)] {
override def initialValue = {
- val cb =
CharBuffer.allocate(tunablesObj.maximumRegexMatchLengthInCharacters)
- val lb =
LongBuffer.allocate(tunablesObj.maximumRegexMatchLengthInCharacters)
+ val cb =
CharBuffer.allocate(tunables.maximumRegexMatchLengthInCharacters)
+ val lb =
LongBuffer.allocate(tunables.maximumRegexMatchLengthInCharacters)
(cb, lb)
}
}
- def setValidationMode(mode: ValidationMode.Type): Unit = {
ssrd.validationMode = mode }
- def getValidationMode() = ssrd.validationMode
- def getVariables = ssrd.variables
- def getTunables = tunablesObj
+ /**
+ * Returns a data processor with the same schema, but with no tunables, no
external variable bindings,
+ * and the default validation mode.
+ */
+ def clear(): DataProcessor = new DataProcessor(ssrd, tunables)
- @transient private var areDebugging_ = false
+ /**
+ * Returns a data processor with the same state.
+ */
+ override def clone(): DataProcessor = copy()
+ /**
+ * Returns a data processor with all the same state, but the validation mode
changed to that of the argument.
+ *
+ * Note that the default validation mode is "off", that is, no validation is
performed.
+ * @param mode
+ * @return the new DataProcessor instance
+ */
- def areDebugging = areDebugging_
+ @deprecated("2020-03-26", "Use withValidationMode.")
+ def setValidationMode(mode: ValidationMode.Type): Unit = { validationMode =
mode }
- @transient private var optDebugger_ : Option[Debugger] = None
+ def withValidationMode(mode:ValidationMode.Type): DataProcessor =
copy(validationMode = mode)
- private def optDebugger = {
- if (optDebugger_ == null) {
- // transient value restored as null
- optDebugger_ = None
- }
- optDebugger_
- }
+ // TODO Deprecate and replace usages with just tunables.
+ def getTunables: DaffodilTunables = tunables
def debugger = {
Assert.invariant(areDebugging)
optDebugger.get
}
+ @deprecated("2020-03-26", "Use withDebugger.")
def setDebugger(dbg: AnyRef) {
- optDebugger_ = Some(dbg.asInstanceOf[Debugger])
+ val optDbg = if (dbg eq null) None else Some(dbg.asInstanceOf[Debugger])
+ optDebugger = optDbg
}
+ def withDebugger(dbg:AnyRef) = {
+ val optDbg = if (dbg eq null) None else Some(dbg.asInstanceOf[Debugger])
+ copy(optDebugger = optDbg)
+ }
+
+ @deprecated("2020-03-26", "Use withDebugging.")
def setDebugging(flag: Boolean) {
- areDebugging_ = flag
- setTunable("allowExternalPathExpressions", flag.toString)
+ areDebugging = flag
+ tunables = tunables.setTunable("allowExternalPathExpressions",
flag.toString)
}
- def setExternalVariables(extVars: Map[String, String]): Unit = {
+ def withDebugging(flag: Boolean): DataProcessor = {
+ val newTunables = tunables.setTunable("allowExternalPathExpressions",
flag.toString)
+ copy(areDebugging = flag, tunables = newTunables)
+ }
+
+ private def newVariableMap(extVars: Map[String, String]): VariableMap = {
val bindings = ExternalVariablesLoader.getVariables(extVars)
- ExternalVariablesLoader.loadVariables(bindings, ssrd, ssrd.variables)
- ssrd.variables = ExternalVariablesLoader.loadVariables(extVars, ssrd,
ssrd.variables)
+ val newVariableMap = ExternalVariablesLoader.loadVariables(bindings,
ssrd, variableMap)
+ newVariableMap
}
+
+ private def newVariableMap(extVars: File): VariableMap = {
+ ExternalVariablesLoader.loadVariables(extVars, ssrd, variableMap,
getTunables)
+ }
+
+ private def newVariableMap(extVars: File, tunable: DaffodilTunables):
VariableMap = {
+ ExternalVariablesLoader.loadVariables(extVars, ssrd, variableMap,
getTunables)
+ }
+
+ private def newVariableMap(extVars: Seq[Binding]): VariableMap = {
+ ExternalVariablesLoader.loadVariables(extVars, ssrd, variableMap)
+ }
+
+// private def getVariables(vars: Map[String, String], scope:
scala.xml.NamespaceBinding, externalVRDs: Seq[VariableRuntimeData]):
Seq[Binding] = {
Review comment:
Remove.
----------------------------------------------------------------
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