Project

General

Profile

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

    
3
import java.util.Date;
4

    
5
import eu.dnetlib.functionality.index.model.Any.ValueType;
6

    
7
/**
8
 * Interface for creation of data objects.
9
 */
10
public interface DataFactory {
11

    
12
	/** default instance. */
13
	DataFactory DEFAULT = DataFactoryCreator.newInstance();
14

    
15
	/**
16
	 * @return The created AnyMap object
17
	 */
18
	AnyMap createAnyMap();
19

    
20
	/**
21
	 * @return The created AnySeq object
22
	 */
23
	AnySeq createAnySeq();
24

    
25
	/**
26
	 * @param value
27
	 *            the String to create the Value from.
28
	 * @return The created Value object.
29
	 */
30
	Value createStringValue(String value);
31

    
32
	/**
33
	 * @param value
34
	 *            the Boolean to create the Value from.
35
	 * @return The created Value object.
36
	 */
37
	Value createBooleanValue(Boolean value);
38

    
39
	/**
40
	 * @param value
41
	 *            the Long to create the Value from.
42
	 * @return The created Value object.
43
	 */
44
	Value createLongValue(Long value);
45

    
46
	/**
47
	 * @param value
48
	 *            the int to create the Value from.
49
	 * @return The created Value object.
50
	 */
51
	Value createLongValue(int value);
52

    
53
	/**
54
	 * @param value
55
	 *            the Double to create the Value from.
56
	 * @return The created Value object.
57
	 */
58
	Value createDoubleValue(Double value);
59

    
60
	/**
61
	 * @param value
62
	 *            the float to create the Value from.
63
	 * @return The created Value object.
64
	 */
65
	Value createDoubleValue(float value);
66

    
67
	/**
68
	 * @param value
69
	 *            the Date to create the Value from.
70
	 * @return The created Value object.
71
	 */
72
	Value createDateValue(Date value);
73

    
74
	/**
75
	 * @param value
76
	 *            the DateTime to create the Value from.
77
	 * @return The created Value object.
78
	 */
79
	Value createDateTimeValue(Date value);
80

    
81
	/**
82
	 * @param value
83
	 *            The value
84
	 * @param type
85
	 *            The type
86
	 * @return The Value object with correct type, InvalidvalueTypeException else.
87
	 */
88
	Value parseFromString(String value, String type);
89

    
90
	/**
91
	 * @param value
92
	 *            The value
93
	 * @param valueType
94
	 *            The value's type
95
	 * @return The Value object with correct type, InvalidvalueTypeException else.
96
	 */
97
	Value parseFromString(final String value, final ValueType valueType);
98

    
99
	/**
100
	 * Tries to convert the String to a Date or Timestamp Value, if not possible return a String Value.
101
	 * 
102
	 * @param value
103
	 *            The value to check for Date/Timestamp
104
	 * @return The Value object with guessed type, InvalidvalueTypeException if value is null.
105
	 */
106
	Value tryDateTimestampParsingFromString(String value);
107

    
108
	/**
109
	 * @param object
110
	 *            The object
111
	 * @return The value matching the class of given object, InvalidValueTypeException otherwise.
112
	 * @deprecated Use {@link #autoConvertValue(Object)} instead
113
	 */
114
	@Deprecated
115
	Value parseFromObject(final Object object);
116

    
117
	/**
118
	 * auto converts the given object into the object's corresponding Value.
119
	 * 
120
	 * @param object
121
	 *            The object, must be one of the simple types
122
	 * @return The value matching the class of given object, InvalidValueTypeException otherwise.
123
	 * 
124
	 */
125
	Value autoConvertValue(final Object object);
126

    
127
	/**
128
	 * Clone Any object.
129
	 * 
130
	 * @param source
131
	 *            the source
132
	 * 
133
	 * @return the attribute
134
	 */
135
	Any cloneAny(final Any source);
136

    
137
	/**
138
	 * Clone AnyMap object.
139
	 * 
140
	 * @param source
141
	 *            the source
142
	 * 
143
	 * @return the attribute
144
	 */
145
	AnyMap cloneAnyMap(final AnyMap source);
146

    
147
	/**
148
	 * Clone AnySeq object.
149
	 * 
150
	 * @param source
151
	 *            the source
152
	 * 
153
	 * @return the attribute
154
	 */
155
	AnySeq cloneAnySeq(final AnySeq source);
156

    
157
}
(4-4/8)