1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.config;
20 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
21 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConversionException;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.Section;
24 public class BaseSubConfig {
26 private final Section subconfig;
27 private final ISubConfigHandler configHandler;
28 private final IniConfigurationFile config;
30 protected Section getSubConfig() {
31 return this.subconfig;
33 protected ISubConfigHandler getConfigHandler() {
34 return this.configHandler;
36 protected IniConfigurationFile getConfig() {
39 public BaseSubConfig()
43 this.configHandler=null;
45 public BaseSubConfig(IniConfigurationFile config, ISubConfigHandler configHandler,String section) {
47 this.subconfig = config.subset(section);
48 this.configHandler = configHandler;
50 protected boolean hasKey(String key)
52 if(this.subconfig==null) {
55 return this.subconfig.hasKey(key);
57 protected String getString(String key,String def)
59 if(this.subconfig==null) {
65 s=this.subconfig.getString(key, def);
70 /*catch(ConversionException e)
77 protected boolean getBoolean(String key, boolean def) {
78 if(this.subconfig==null) {
83 s=this.subconfig.getBoolean(key, def);
85 catch(ConversionException e)
91 protected int getInt(String key, int def) {
92 if(this.subconfig==null) {
97 s=this.subconfig.getInt(key, def);
99 catch(ConversionException e)
105 protected long getLong(String key, long def) {
106 if(this.subconfig==null) {
111 s=this.subconfig.getLong(key, def);
113 catch(ConversionException e)
119 protected void save()
121 if(this.configHandler!=null) {
122 this.configHandler.save();