View Javadoc

1   /**
2    * Copyright 2005-2012 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      /**
39       * @return exportKey associated with this instance
40       */
41      public String getExportKey() {
42          return this.exportKey;
43      }
44  
45      /**
46       * @return unmodifiable copy of the exportData associated with this Map
47       */
48      public Map<String, Object> getExportData() {
49          return Collections.unmodifiableMap(this.exportData);
50      }
51  
52  
53      /**
54       * Adds the ExportMap's exportKey and exportData as a key,value pair to this Map
55       */
56      public void set(ExportMap map) {
57          if (map == null) {
58              throw new IllegalArgumentException("invalid (null) map");
59          }
60  
61          exportData.set(map.getExportKey(), map.getExportData());
62      }
63  
64      /**
65       * If the given map is not null, adds the ExportMap's exportKey and exportData as a key,value pair to this Map.
66       */
67      public void setOptional(ExportMap map) {
68          if (map != null) {
69              set(map);
70          }
71      }
72  
73      /**
74       * Adds the given key,value pair to this Map
75       * 
76       * @param key
77       * @param value
78       */
79      public void set(String key, String value) {
80          if (key == null) {
81              throw new IllegalArgumentException("invalid (null) key");
82          }
83          if (value == null) {
84              throw new IllegalArgumentException("invalid (null) value - key=" + key);
85          }
86  
87          exportData.set(key, value);
88      }
89  
90  
91      /**
92       * @see java.lang.Object#toString()
93       */
94      public String toString() {
95          return this.exportKey + "(" + this.exportData.size() + " children)";
96      }
97  }