diff options
Diffstat (limited to 'restconf-client/provider/src')
25 files changed, 1113 insertions, 81 deletions
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java index 7271c3d71..185f70ba0 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java @@ -25,7 +25,14 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; */ public class Annotation { + /** + * Name of the annotation. + */ private String name; + + /** + * Value of the annotation. + */ private String value; /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java index 6fb11e70f..c692f1dd2 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java @@ -24,6 +24,14 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; * Representation of data format. */ public enum DataFormat { + + /** + * XML data format. + */ XML, + + /** + * JSON data format. + */ JSON } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java index e703b1732..57280e2e9 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java @@ -29,19 +29,26 @@ import java.util.Map; */ public abstract class DataFormatSerializer { + /** + * Data format type of the serializer. + */ private DataFormat dataFormat; + + /** + * Data format serializer context. + */ private DataFormatSerializerContext serializerContext; /** * Creates an instance of data format serializer. * - * @param dataFormat type of data format - * @param serializerContext data format serializer context + * @param d type of data format + * @param s data format serializer context */ - protected DataFormatSerializer(DataFormat dataFormat, - DataFormatSerializerContext serializerContext) { - this.dataFormat = dataFormat; - this.serializerContext = serializerContext; + protected DataFormatSerializer(DataFormat d, + DataFormatSerializerContext s) { + this.dataFormat = d; + this.serializerContext = s; } /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java index e2ead53fb..919e82af3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeSerializer; + import java.util.Map; /** @@ -27,26 +29,45 @@ import java.util.Map; */ public class DataFormatSerializerContext { + /** + * Data format listener. + */ private Listener listener; + + /** + * URI corresponding to the instance identifier. + */ private String uri; + + /** + * Protocol annotation. + */ private Map<String, String> protocolAnnotation; /** + * Properties node serializer. + */ + private PropertiesNodeSerializer propNodeSerializer; + + /** * Creates an instance of data format serializer context. * - * @param listener data format listener - * @param uri URI corresponding to instance identifier - * @param protocolAnnotation protocol annotations + * @param l data format listener + * @param u URI corresponding to instance identifier + * @param p protocol annotations + * @param s properties node serializer */ - public DataFormatSerializerContext(Listener listener, String uri, - Map<String, String> protocolAnnotation) { - this.listener = listener; - this.uri = uri; - this.protocolAnnotation = protocolAnnotation; + public DataFormatSerializerContext(Listener l, String u, + Map<String, String> p, + PropertiesNodeSerializer s) { + listener = l; + uri = u; + protocolAnnotation = p; + propNodeSerializer = s; } /** - * Retruns data format listener. + * Returns the data format listener. * * @return data format listener */ @@ -55,7 +76,7 @@ public class DataFormatSerializerContext { } /** - * Returns URI. + * Returns the URI. * * @return URI */ @@ -64,11 +85,20 @@ public class DataFormatSerializerContext { } /** - * Returns protocol annotations. + * Returns the protocol annotations. * * @return protocol annotations */ public Map<String, String> getProtocolAnnotation() { return protocolAnnotation; } + + /** + * Returns the properties node serializer. + * + * @return properties node serializer + */ + public PropertiesNodeSerializer getPropNodeSerializer() { + return propNodeSerializer; + } }
\ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java new file mode 100644 index 000000000..5e71eea3b --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; + + +/** + * Representation of default implementation of JSON listener. + */ +public class DefaultJsonListener implements JsonListener { + + /** + * Serializer helper to convert to properties node. + */ + private SerializerHelper serializerHelper; + + /** + * Name of the current JSON node. + */ + private String name; + + /** + * Module name of the current JSON node. + */ + private String modName; + + /** + * Creates an instance of default json listener with its serializer helper. + * + * @param serializerHelper serializer helper + */ + public DefaultJsonListener(SerializerHelper serializerHelper) { + this.serializerHelper = serializerHelper; + } + + @Override + public void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType) { + //TODO: Implementation code. + } + + @Override + public void exitJsonNode(JsonNode node) { + //TODO: Implementation code. + } + + @Override + public SerializerHelper serializerHelper() { + return serializerHelper; + } + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java new file mode 100644 index 000000000..20d4fa772 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Implementation of JSON walker to walk through the nodes and process it. + */ +public class DefaultJsonWalker implements JsonWalker { + + @Override + public void walk(JsonListener listener, JsonNode jsonNode) { + //TODO: Implementation code. + } + + /** + * Processes single instance node or leaf, by adding the node to from + * JSON and walking through all its children recursively. + * + * @param key JSON name + * @param value JSON node + * @param listener JSON listener + */ + private void processSingleNode(String key, JsonNode value, + JsonListener listener) { + //TODO: Implementation code. + } + + /** + * Processes multi instance node or leaf, by adding the node to from JSON + * and walking through all its instance recursively. + * + * @param key JSON name + * @param value JSON node + * @param listener JSON listener + */ + private void processMultiNodes(String key, JsonNode value, + JsonListener listener) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java new file mode 100644 index 000000000..7946d8d0d --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Representation of default implementation of XML listener. + */ +public class DefaultXmlListener implements XmlListener { + + /** + * Serializer helper to convert to properties node. + */ + private SerializerHelper serializerHelper; + + /** + * Creates an instance of default XML listener with its serializer helper. + * + * @param serializerHelper serializer helper + */ + public DefaultXmlListener(SerializerHelper serializerHelper) { + this.serializerHelper = serializerHelper; + } + + @Override + public void enterXmlElement(Element element, XmlNodeType nodeType) { + //TODO: Implementation code. + } + + @Override + public void exitXmlElement(Element element) { + //TODO: Implementation code. + } + + @Override + public SerializerHelper serializerHelper() { + return serializerHelper; + } + } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java new file mode 100644 index 000000000..cd2a3d494 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Implementation of XML walker to walk through the nodes and process it. + */ +public class DefaultXmlWalker implements XmlWalker { + + @Override + public void walk(XmlListener listener, Element xmlElement) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java new file mode 100644 index 000000000..851f1b488 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +/** + * Represents the data format listener factory which will return JSON or XML + * listener according to the serializer helper. + */ +public final class DfListenerFactory { + + /** + * Returns the instance of the data format listener factory. + * + * @return instance of the data format listener factory + */ + public static DfListenerFactory instance() { + return DfListenerFactory.LazyHolder.INSTANCE; + } + + /** + * Bill pugh singleton pattern. Instance will not be instantiated until + * the lazy holder class is loaded via a call to the instance of method + * below. + */ + private static class LazyHolder { + private static final DfListenerFactory INSTANCE = + new DfListenerFactory(); + } + + /** + * Returns the data format listener by deciding it based on the format of + * the parameter. + * + * @param serHelper serializer helper + * @param params parameters + * @return data format listener + */ + public Listener getListener(SerializerHelper serHelper, + YangParameters params) { + Listener listener; + switch (params.format) { + case JSON: + listener = new DefaultJsonListener(serHelper); + break; + + case XML: + listener = new DefaultXmlListener(serHelper); + break; + + //TODO: DataFormat Exception code to be added. + default: + throw new IllegalArgumentException("In correct format"); + } + return listener; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java new file mode 100644 index 000000000..25b23fe26 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +/** + * Represents the data format serializer factory which will return JSON or XML + * serializer according to the serializer context. + */ +public final class DfSerializerFactory { + + /** + * Returns the instance of the data format serializer factory. + * + * @return instance of the data format serializer factory + */ + public static DfSerializerFactory instance() { + return DfSerializerFactory.LazyHolder.INSTANCE; + } + + /** + * Bill pugh singleton pattern. Instance will not be instantiated until + * the lazy holder class is loaded via a call to the instance of method + * below. + */ + private static class LazyHolder { + private static final DfSerializerFactory INSTANCE = + new DfSerializerFactory(); + } + + /** + * Returns the data format serializer by deciding it based on the format of + * the parameter. + * + * @param serCtx serializer context + * @param params parameters + * @return data format serializer + */ + public DataFormatSerializer getSerializer(DataFormatSerializerContext + serCtx, + YangParameters params) { + DataFormatSerializer serializer; + switch (params.format) { + case JSON: + serializer = new JsonSerializer(serCtx); + break; + + case XML: + serializer = new XmlSerializer(serCtx); + break; + + //TODO: DataFormat Exception code to be added. + default: + throw new IllegalArgumentException("In correct format"); + } + return serializer; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java new file mode 100644 index 000000000..2a9220ac1 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; + +/** + * Abstraction of an entity which provides call back methods, which in turn + * are called by JSON walker while walking the JSON tree. This interface + * needs to be implemented by protocol, implementing listener based call + * while doing JSON walk. + */ +public interface JsonListener extends Listener { + + /** + * Call back invoked during JSON node entry. All other related + * information can be obtained from the JSON node. + * + * @param nodeName JSON node name + * @param node JSON node + * @param nodeType JSON node type + */ + void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType); + + /** + * Call back invoked during JSON node exit. All the related information + * can be obtained from the JSON node. + * + * @param node JSON node + */ + void exitJsonNode(JsonNode node); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java index 6013664cb..b562e71db 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java @@ -23,8 +23,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import java.util.List; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.JSON; + /** - * Representation of JSON serializer. + * Representation of JSON serializer which encodes properties to JSON and + * decodes properties from JSON with the data format serializer. */ public class JsonSerializer extends DataFormatSerializer { @@ -34,16 +37,19 @@ public class JsonSerializer extends DataFormatSerializer { * @param serializerContext data format serializer context */ protected JsonSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.JSON, serializerContext); + super(JSON, serializerContext); } @Override - public String encode(Map<String, String> param, Map<String, List<Annotation>> annotations) { + public String encode(Map<String, String> param, + Map<String, List<Annotation>> annotations) { + //TODO: Implementation code. return null; } @Override public Map<String, String> decode(String dataFormatBody) { + //TODO: Implementation code. return null; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java new file mode 100644 index 000000000..e3fb4d513 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Abstraction of an entity which provides interface for JSON walk. This + * interface serves as a common tool for anyone who needs to parse the JSON + * node with depth-first algorithm. + */ +public interface JsonWalker { + + /** + * Walks the JSON data tree. Protocols implement JSON listener service + * and walks the JSON tree with input as implemented object. JSON walker + * provides call back to the implemented methods. + * + * @param listener JSON listener implemented by the protocol + * @param jsonNode root node of the JSON data tree + */ + void walk(JsonListener listener, JsonNode jsonNode); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index 311fc2d6b..1f8195e2d 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -20,48 +20,70 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; /** - * Representation of MDSAL based schema helper. + * Representation of MDSAL based serializer helper, which adds properties + * node to the properties tree based on its types. */ -public class MdsalSerializerHelper extends SerializerHelper<SchemaNode> { +public class MdsalSerializerHelper extends SerializerHelper<SchemaNode, SchemaContext> { - protected MdsalSerializerHelper(SchemaNode node, String uri) { - super(node, uri); - } + /** + * Current properties node. + */ + private PropertiesNode propNode; - @Override - public SchemaNode getRootContext() { - return null; + /** + * Current schema node. + */ + private SchemaNode curSchemaNode; + + + /** + * Creates MDSAL serializer helper with root schema node, schema context + * and URI. + * + * @param n schema node of the URI's last node + * @param c schema context + * @param u URI of the request + */ + protected MdsalSerializerHelper(SchemaNode n, SchemaContext c, + String u) { + super(n, c, u); } @Override - public SchemaNode getCurContext() { - return null; + protected SchemaNode getSchemaNode() { + return schemaNode; } @Override - public SchemaNode getChildContext(SchemaNode schemaNode, String name, String namespace) { - return null; + protected SchemaContext getSchemaCtx() { + return schemaCtx; } @Override - public NodeType getNodeType(SchemaNode schemaNode) { - return null; + protected SchemaNode getCurSchema() { + return curSchemaNode; } @Override - public void addNode(String name, String namespace, String value, String valNamespace, NodeType type) { + protected void addNode(String name, String nameSpace, String value, + String valNameSpace, NodeType type) { + //TODO: Implementation code. } @Override - public void exitNode() { + protected void exitNode() { + //TODO: Implementation code. } @Override - public Map<String, String> getProperties() { + protected PropertiesNode getPropertiesNode() { + //TODO: Implementation code. return null; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java new file mode 100644 index 000000000..ec1306731 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import com.google.gson.stream.JsonWriter; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; + +import java.io.Writer; + +/** + * Representation of JSON implementation of properties node listener. + */ +public class PropertiesNodeJsonListener implements PropertiesNodeListener{ + + /** + * JSON writer to write the JSON data format. + */ + private JsonWriter jsonWriter; + + /** + * Writer to write the JSON. + */ + private Writer writer; + + /** + * Creates the properties node JSON listener by instantiating and + * indenting the writer. + */ + public PropertiesNodeJsonListener() { + } + + @Override + public void start(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void end(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void enterPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void exitPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java new file mode 100644 index 000000000..cfc59ca10 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.dom4j.Element; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; + +import java.io.Writer; +import java.util.Stack; + +/** + * Representation of XML implementation of properties node listener. + */ +public class PropertiesNodeXmlListener implements PropertiesNodeListener { + + /** + * XML data from the element. + */ + private String xmlData; + + /** + * Root element of the XML document. + */ + private Element rootElement; + + /** + * Writer to write the XML. + */ + private Writer writer; + + /** + * XML element stack to store the elements. + */ + private final Stack<Element> elementStack = new Stack<>(); + + /** + * Creates the properties node XML listener. + */ + public PropertiesNodeXmlListener() { + } + + @Override + public void start(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void end(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void enterPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void exitPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java index 4e6d2944d..2466023fa 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java @@ -20,74 +20,92 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; /** * Abstraction of an entity which helps the data format serializers to obtain * schema context details and to build properties from data. * * @param <T> type of schema node + * @param <P> type of schema context */ -public abstract class SerializerHelper<T> { +public abstract class SerializerHelper<T, P> { - private T rootSchema; - private String rootURI; + /** + * Schema node of the last element in the URI. + */ + protected T schemaNode; - protected SerializerHelper(T t, String uri) { - rootSchema = t; - } + /** + * Root schema context. + */ + protected P schemaCtx; + + /** + * Root URI. + */ + protected String rootUri; /** - * Returns root schema context node. + * Creates an instance of the serializer helper with the schema node, + * schema context and the URI. * - * @return root schema context node + * @param t schema node + * @param p schema context + * @param u root URI */ - protected abstract T getRootContext(); + protected SerializerHelper(T t, P p, String u) { + schemaNode = t; + schemaCtx = p; + rootUri = u; + } /** - * Returns current schema context node. + * Returns schema node of the last element in the URI. * - * @return current schema context node + * @return schema node */ - protected abstract T getCurContext(); + protected abstract T getSchemaNode(); /** - * Returns child schema context node. + * Returns the root schema context. * - * @return child schema context node + * @return schema context */ - protected abstract T getChildContext(T t, String name, String namespace); + protected abstract P getSchemaCtx(); /** - * Returns type of node - * @param t node - * @return node type + * Returns the current schema context node. + * + * @return current schema context node */ - protected abstract NodeType getNodeType(T t); + protected abstract T getCurSchema(); /** - * Adds a node to current tree. + * Adds a node to the properties node tree. * - * @param name name of node - * @param namespace namespace of node, it can be either module name or - * namespace, null indicates parent namespace - * @param value value of node, in case it's leaf/leaf-list node - * @param valNamespace value namespace for identityref, could be module - * name or namespace - * @param type type of node if known like in case of JSON + * @param name name of the node + * @param nameSpace name space of the node, it can be either module + * name or namespace; null indicates parent namespace + * @param value value of the node; applicable for leaf/leaf-list node + * @param valNameSpace value namespace for identityref, could be module + * name or namespace + * @param type type of node if known like in case of JSON */ - protected abstract void addNode(String name, String namespace, String value, - String valNamespace, NodeType type); + protected abstract void addNode(String name, String nameSpace, String value, + String valNameSpace, NodeType type); /** - * Exits the node, in case if it's leaf node add to properties map. + * Exits the node, in case if it's leaf node then it adds to the properties + * map. */ protected abstract void exitNode(); /** - * Returns the properties built corresponding to data. + * Returns the built properties corresponding to the data. * - * @return properties map + * @return properties node. */ - protected abstract Map<String, String> getProperties(); + protected abstract PropertiesNode getPropertiesNode(); } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java new file mode 100644 index 000000000..0fbf4c338 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Abstraction of an entity which provides call back methods, which in turn + * are called by XML walker while walking the XML tree. This interface needs + * to be implemented by protocol implementing listener based call while doing + * XML walk. + */ +public interface XmlListener extends Listener { + + /** + * Callback invoked during a node entry. All the related information + * about the node can be obtained from the element. + * + * @param element current XML element + * @param nodeType node type of the element + */ + void enterXmlElement(Element element, XmlNodeType nodeType); + + /** + * Callback invoked during a node exit. All the related information about + * the node can be obtained from the element. + * + * @param element current xml element. + */ + void exitXmlElement(Element element); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java index ffa35e2b6..7a6db3c86 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java @@ -21,11 +21,17 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; /** - * Representation of type of data node. + * Represents the XML node type. */ -public enum NodeType { - SINGLE_INSTANCE, - MULTI_INSTANCE, - SINGLE_INSTANCE_LEAF, - MULTI_INSTANCE_LEAF +public enum XmlNodeType { + + /** + * Object XML node type. + */ + OBJECT_NODE, + + /** + * Text XML node type. + */ + TEXT_NODE } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java index 0cfb4d17f..516470059 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java @@ -23,8 +23,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import java.util.List; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.XML; + /** - * Representation of XML serializer. + * Representation of XML serializer which encodes properties to XML and + * decodes properties from XML with the data format serializer. */ public class XmlSerializer extends DataFormatSerializer { @@ -34,16 +37,19 @@ public class XmlSerializer extends DataFormatSerializer { * @param serializerContext data format serializer context */ protected XmlSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.XML, serializerContext); + super(XML, serializerContext); } @Override - public String encode(Map<String, String> param, Map<String, List<Annotation>> annotations) { + public String encode(Map<String, String> param, + Map<String, List<Annotation>> annotations) { + //TODO: Implementation code. return null; } @Override public Map<String, String> decode(String dataFormatBody) { + //TODO: Implementation code. return null; } }
\ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java new file mode 100644 index 000000000..6fed510a3 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Abstraction of an entity which provides interface for XML walk. This + * interface serves as a common tool for anyone who needs to parse the XML + * node with depth-first algorithm. + */ +public interface XmlWalker { + + /** + * Walks the XML data tree. Protocols implement XML listener service and + * walks the XML tree with input as implemented object. XML walker + * provides call back to the implemented methods. + * + * @param listener XML listener implemented by the protocol + * @param xmlElement root element of the XML data tree + */ + void walk(XmlListener listener, Element xmlElement); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java new file mode 100644 index 000000000..c94a22975 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; + +import org.onap.ccsdk.sli.plugins.restapicall.Parameters; + +/** + * Representation of the YANG parameters for the restconf api call node. + */ +public class YangParameters extends Parameters { + + /** + * Creates an instance of the YANG parameters. + */ + public YangParameters() { + super(); + } + + /** + * Directory path of the YANG file. + */ + public String dirPath; +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java new file mode 100644 index 000000000..041210f22 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; + +import java.util.Map; + +/** + * Implementation of properties node walker which helps in forming a new tree from properties node. + * + * @param <T> node child of properties node. + */ +public class DefaultPropertiesNodeWalker<T extends NodeChild> implements PropertiesNodeWalker { + + @Override + public void walk(PropertiesNodeListener listener, + PropertiesNode propertiesNode) { + listener.start(propertiesNode); + walkChildNode(listener, propertiesNode); + listener.end(propertiesNode); + } + + /** + * Walks the children node from the parent node. + * + * @param listener properties node listener + * @param propertiesNode properties node + */ + public void walkChildNode(PropertiesNodeListener listener, + PropertiesNode propertiesNode) { + Map<String, T> children = getChildren(propertiesNode); + if (children != null) { + for (Map.Entry<String, T> entry : children.entrySet()) { + PropertiesNode node = ((PropertiesNode) entry.getValue()); + listener.enterPropertiesNode(node); + walkChildNode(listener, node); + listener.exitPropertiesNode(node); + } + } + } + + /** + * Returns the children node according to the property node type. + * + * @param value property node + * @return property node children + */ + private Map<String,T> getChildren(PropertiesNode value) { + if (value instanceof RootNode) { + return ((RootNode) value).children(); + } + switch (value.nodeType()) { + case SINGLE_INSTANCE_NODE: + return ((InnerNode) value).children(); + case MULTI_INSTANCE_HOLDER_NODE: + return ((Map<String, T>) ((ListHolderNode) value).children()); + case MULTI_INSTANCE_NODE: + return ((Map<String, T>) ((MultiInstanceNode) value) + .children()); + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + return ((Map<String, T>) ((LeafListHolderNode) value) + .children()); + case SINGLE_INSTANCE_LEAF_NODE: + case MULTI_INSTANCE_LEAF_NODE: + return null; + default: + throw new IllegalArgumentException("No more types allowed"); + } + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java new file mode 100644 index 000000000..5bf7fe9dc --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; + +/** + * Abstraction of properties node listener. + */ +public interface PropertiesNodeListener { + + /** + * Pre-configurations required before starting the walking. + * + * @param node properties node + */ + void start(PropertiesNode node); + + /** + * Post-configurations required after starting the walking. + * + * @param node properties node + */ + void end(PropertiesNode node); + + /** + * Enters the properties node. + * + * @param node properties node + */ + void enterPropertiesNode(PropertiesNode node); + + /** + * Enters the properties node. + * + * @param node properties node + */ + void exitPropertiesNode(PropertiesNode node); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java new file mode 100644 index 000000000..48433e2b2 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; + +/** + * Abstraction of properties node walker + */ +public interface PropertiesNodeWalker { + + /** + * Walks the properties node with the listener. + * + * @param listener properties node listener. + * @param propertiesNode properties node + */ + void walk(PropertiesNodeListener listener, PropertiesNode propertiesNode); +} |