- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
/**
* all object cocomponents must be not the same objects in dump - to eliminate strange situations:
*
* @param copySet
*/
private void createAllNewComplexObjects(HashMap copySet) {
if (copySet != null) {
for (Iterator i = copySet.keySet().iterator(); i.hasNext();) {
Object key = i.next();
Object o = copySet.get(key);
Object newObject = madeNewObect(o);
copySet.put(key, newObject);
}
}
}
/**
* create new instance of the object - if it is of known type. Hashes will bethe same
*
* @param oldObject
* @return
*/
private Object madeNewObect(Object oldObject) {
if (oldObject instanceof String) {
return new String((String) oldObject);
}
if (oldObject instanceof Point) {
return new Point((Point) oldObject);
}
if (oldObject instanceof Vector2D) {
return new Vector2D((Vector2D) oldObject);
}
if (oldObject instanceof RGBA) {
RGBA c = (RGBA) oldObject;
return new RGBA(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
}
if (oldObject instanceof Integer) {
return new Integer(((Integer) oldObject).intValue());
}
if (oldObject instanceof Double) {
return new Double(((Double) oldObject).doubleValue());
}
if (oldObject instanceof Boolean) {
return new Boolean(((Boolean) oldObject).booleanValue());
}
if (oldObject instanceof Float) {
return new Float(((Float) oldObject).floatValue());
}
if (oldObject instanceof HashMap) {
createAllNewComplexObjects((HashMap) oldObject);
return oldObject;
}
return oldObject;
}
bormand 05.12.2014 15:52 # +1
Царь?
someone 05.12.2014 15:53 # 0
bormand 05.12.2014 16:05 # +1
guest 05.12.2014 17:26 # 0
someone 06.12.2014 10:19 # 0