View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.datadictionary.exporter;
17  
18  import java.util.Collections;
19  import java.util.Map;
20  
21  /*
22   * An ExportMap represents an entry or definition from the dataDictionary as a Map of the contents of that entry or definintion, and
23   * the key by which that entry or definition will be stored in the parent Map.
24   * 
25   * 
26   */
27  @Deprecated
28  public class ExportMap {
29      private final String exportKey;
30      private final StringMap exportData;
31  
32      public ExportMap(String exportKey) {
33          this.exportKey = exportKey;
34          this.exportData = new StringMap();
35      }
36  
37      /**
38       * @return exportKey associated with this instance
39       */
40      public String getExportKey() {
41          return this.exportKey;
42      }
43  
44      /**
45       * @return unmodifiable copy of the exportData associated with this Map
46       */
47      public Map<String, Object> getExportData() {
48          return Collections.unmodifiableMap(this.exportData);
49      }
50  
51      /**
52       * Adds the ExportMap's exportKey and exportData as a key,value pair to this Map
53       */
54      public void set(ExportMap map) {
55          if (map == null) {
56              throw new IllegalArgumentException("invalid (null) map");
57          }
58  
59          exportData.set(map.getExportKey(), map.getExportData());
60      }
61  
62      /**
63       * If the given map is not null, adds the ExportMap's exportKey and exportData as a key,value pair to this Map.
64       */
65      public void setOptional(ExportMap map) {
66          if (map != null) {
67              set(map);
68          }
69      }
70  
71      /**
72       * Adds the given key,value pair to this Map
73       *
74       * @param key
75       * @param value
76       */
77      public void set(String key, String value) {
78          if (key == null) {
79              throw new IllegalArgumentException("invalid (null) key");
80          }
81          if (value == null) {
82              throw new IllegalArgumentException("invalid (null) value - key=" + key);
83          }
84  
85          exportData.set(key, value);
86      }
87  
88      /**
89       * @see java.lang.Object#toString()
90       */
91      public String toString() {
92          return this.exportKey + "(" + this.exportData.size() + " children)";
93      }
94  }