1 /* Copyright 2002-2021 CS GROUP 2 * Licensed to CS GROUP (CS) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * CS licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.orekit.files.ccsds.ndm.odm; 19 20 import java.util.Collections; 21 import java.util.LinkedHashMap; 22 import java.util.Map; 23 24 import org.orekit.files.ccsds.section.CommentsContainer; 25 26 /** Container for user defined data. 27 * @author Luc Maisonobe 28 * @since 11.0 29 */ 30 public class UserDefined extends CommentsContainer { 31 32 /** Tag name for user defined parameters keys. */ 33 public static final String USER_DEFINED_XML_TAG = "USER_DEFINED"; 34 35 /** Attribute name for user defined parameters keys. */ 36 public static final String USER_DEFINED_XML_ATTRIBUTE = "parameter"; 37 38 /** Prefix for user defined parameters keys. */ 39 public static final String USER_DEFINED_PREFIX = "USER_DEFINED_"; 40 41 /** User defined parameters map. */ 42 private final Map<String, String> map; 43 44 /** Create an empty data set. 45 */ 46 public UserDefined() { 47 // we use a LinkedHashMap so we retrieve the parameters in the same order they are put in 48 map = new LinkedHashMap<>(); 49 } 50 51 /** Get all user defined parameters. 52 * <p> 53 * The {@link #USER_DEFINED_PREFIX} has been stripped away from the keys. 54 * </p> 55 * @return unmodifiable view of the map containing all user defined parameters 56 */ 57 public Map<String, String> getParameters() { 58 return Collections.unmodifiableMap(map); 59 } 60 61 /** Add a key/value entry. 62 * @param key parameter key, with the {@link #USER_DEFINED_PREFIX} stripped away 63 * @param value parameter value 64 */ 65 public void addEntry(final String key, final String value) { 66 refuseFurtherComments(); 67 map.put(key, value); 68 } 69 70 } 71