mbeckerle commented on code in PR #1170: URL: https://github.com/apache/daffodil/pull/1170#discussion_r1508300878
########## daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/layers/api/LayerCompileInfo.java: ########## @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.daffodil.runtime1.layers.api; + +import org.apache.daffodil.lib.exceptions.SchemaFileLocation; + +/** + * Provides contextual information for the layer's own static checking. + * + * This mostly is about getting access to DFDL variables. I + * It also allows reporting schema definition errors for any + * reason. + */ +public interface LayerCompileInfo { + + String layerName(); + + SchemaFileLocation schemaFileLocation(); + + /** + * Obtains the LayerVariable object that can be used to access the variable at runtime. + * Review Comment: @stevedlawrence - Trying to simplify this idea slightly. What do you think of this. Each layer has a target namespace. All variables in that namespace must either be parameters to, or return results from, the layer. The layer class must have a default constructor so SPI can load it. It also must have a constructor with an arg for each parameter variable - name of which matches the variable name, type of which is the Java/Scala type corresponding to the mapping from DFDLPrimType. (ex: xs:date becomes icu.Calendar, unsignedShort becomes JInt, etc. runtime1.api.InfosetSimpleElement defines this corresondence all in one place.) It also must have a getter for each result variable, the name of which is "get_" appended to the variable name (or maybe it is just exactly the variable name). The return type is determined the same way as the arg types to the constructor. At layer schema compile time each variable in the layer namespace must have a corresponding constructor arg, or a corresponding getter, and the types have to match up or it's an SDE. At runtime the layer is constructed using the variable values, when layer processing completes the framework will call the getters for each result variable and populate those variables. This is not too bad. The inputter and ouputter streams can share any variable logic via methods on the layer class itself. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
