Project

General

Profile

1
package eu.dnetlib.functionality.index.model;
2

    
3
import java.util.Date;
4
import java.util.Map;
5

    
6
/**
7
 * Interface for a map with Any objects.
8
 * 
9
 * <p>
10
 * AnyMap does <b>not</b> allow <code>null</code> values!
11
 * </p>
12
 * 
13
 */
14
public interface AnyMap extends Any, Map<String, Any> {
15

    
16
	/**
17
	 * Adds the given value to the mapped entry of the given key. If there's no mapping yet, the new value is added as
18
	 * Seq with one value. If the key is currently mapped to a Value/Map, the Value/Map is converted to a Seq containing
19
	 * the Value/Map and the Seq is added. If the key is currently mapped to a Seq, new value is added to that Seq.
20
	 * 
21
	 * @param key
22
	 *            The key
23
	 * @param value
24
	 *            the Any to add
25
	 */
26
	void add(String key, Any value);
27

    
28
	/**
29
	 * @param key
30
	 *            The key
31
	 * @param value
32
	 *            String value, must not be null.
33
	 * @return the previous value or null
34
	 */
35
	Any put(String key, String value);
36

    
37
	/**
38
	 * Long, Integer, Short and Byte values will be converted to Value object of type LONG, all others to Value object
39
	 * of type DOUBLE.
40
	 * 
41
	 * @param key
42
	 *            The key
43
	 * @param value
44
	 *            Number value, will be converted, must not be null.
45
	 * @return the previous value or null
46
	 */
47
	Any put(String key, Number value);
48

    
49
	/**
50
	 * @param key
51
	 *            The key
52
	 * @param value
53
	 *            Boolean value, must not be null.
54
	 * @return the previous value or null
55
	 */
56
	Any put(String key, Boolean value);
57

    
58
	/**
59
	 * @param key
60
	 *            The key
61
	 * @param value
62
	 *            Any value, must not be null.
63
	 * @return the previous value or null
64
	 */
65
	@Override
66
	Any put(String key, Any value);
67

    
68
	/**
69
	 * @param key
70
	 *            The key
71
	 * @return The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap,
72
	 *         or null
73
	 */
74
	AnyMap getMap(String key);
75

    
76
	/**
77
	 * Gets the map and optionally creates one under the given key if not present.
78
	 * 
79
	 * @param key
80
	 *            The key
81
	 * @param create
82
	 *            if true and the key is not yet used, create a new map. else just return null.
83
	 * @return The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
84
	 */
85
	AnyMap getMap(String key, boolean create);
86

    
87
	/**
88
	 * @param key
89
	 *            The key
90
	 * @return The AnySeq matching to this key, an InvalidValueTypeException is thrown if the value is not of type, or
91
	 *         null
92
	 */
93
	AnySeq getSeq(String key);
94

    
95
	/**
96
	 * Gets the seq and optionally creates one under the given key if not present.
97
	 * 
98
	 * @param key
99
	 *            The key
100
	 * @param create
101
	 *            the create
102
	 * @return The AnySeq matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
103
	 */
104
	AnySeq getSeq(String key, boolean create);
105

    
106
	/**
107
	 * @param key
108
	 *            the key
109
	 * @return The string representation of the attribute value
110
	 */
111
	String getStringValue(String key);
112

    
113
	/**
114
	 * @param key
115
	 *            the key
116
	 * @return The value matching to this key, an InvalidValueTypeException is thrown if the value is no value type
117
	 */
118
	Value getValue(String key);
119

    
120
	/**
121
	 * @param key
122
	 *            The key
123
	 * @return The double value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
124
	 *         double
125
	 */
126
	Double getDoubleValue(String key);
127

    
128
	/**
129
	 * @param key
130
	 *            The key
131
	 * @return The long value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
132
	 *         long
133
	 */
134
	Long getLongValue(String key);
135

    
136
	/**
137
	 * @param key
138
	 *            The key
139
	 * @return The boolean value matching to this key, an InvalidValueTypeException is thrown if the value is not of
140
	 *         type boolean
141
	 */
142
	Boolean getBooleanValue(String key);
143

    
144
	/**
145
	 * @param key
146
	 *            The key
147
	 * @return The date value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
148
	 *         date
149
	 */
150
	Date getDateValue(String key);
151

    
152
	/**
153
	 * @param key
154
	 *            The key
155
	 * @return The date time value matching to this key, an InvalidValueTypeException is thrown if the value is not of
156
	 *         type date time
157
	 */
158
	Date getDateTimeValue(String key);
159
}
(2-2/8)