-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDCObject.java
More file actions
55 lines (49 loc) · 878 Bytes
/
DCObject.java
File metadata and controls
55 lines (49 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
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
package net.dmcloud.util;
import java.util.HashMap;
import java.util.Map;
public class DCObject extends HashMap
{
static public DCObject create()
{
return new DCObject();
}
static public DCObject create(Map map)
{
DCObject obj = create();
obj.putAll(map);
return obj;
}
public DCObject push(Object s, Object ss)
{
this.put(s, ss);
return this;
}
public String pull(String path)
{
try
{
if (!path.contains("."))
{
return this.get(path).toString();
}
String[] tokens = path.split("\\.");
Map map = (Map)this.get(tokens[0]);
for(int i=1; i<tokens.length; i++)
{
if (map.get(tokens[i]) instanceof Map)
{
map = (Map)map.get(tokens[i]);
}
else
{
return map.get(tokens[i]).toString();
}
}
return "null";
}
catch (java.lang.NullPointerException e)
{
return "null";
}
}
}