Repository navigation
Expand file tree
/
Copy pathdClass.java
More file actions
165 lines (140 loc) · 3.44 KB
/
Copy pathdClass.java
File metadata and controls
165 lines (140 loc) · 3.44 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package dclass;
import java.util.Map;
import java.util.HashMap;
public class dClass
{
private String path;
private long dclass_index;
private int patterns;
static
{
dClassLoader.load("dclassjava");
}
private native int init(String file);
private native int write(long index,String file);
private native long walk(long index);
private native static String statversion();
private native static String stataddressing();
private native static long statnodesize();
private native long statnodes(long index);
private native long statmemory(long index);
private native String comment(long index);
private native void free(long index);
private native long classify(long index,String s);
private native long get(long index,String s);
private native int kvlength(long kv);
private native String kvgetid(long kv);
private native String kvgetkey(long kv,int pos);
private native String kvgetvalue(long kv,int pos);
public static String getVersion()
{
return statversion();
}
public static String getAddressing()
{
return stataddressing();
}
public static long getNodeSize()
{
return statnodesize();
}
public dClass(String s)
{
path=s;
dclass_index=0;
patterns=0;
}
public synchronized int init()
{
if(dclass_index==0)
{
patterns=init(path);
return patterns;
}
else
return -1;
}
public int getPatterns()
{
return patterns;
}
public long getNodes()
{
if(dclass_index!=0)
return statnodes(dclass_index);
else
return -1;
}
public long getMemory()
{
if(dclass_index!=0)
return statmemory(dclass_index);
else
return -1;
}
public String getComment()
{
if(dclass_index!=0)
return comment(dclass_index);
else
return "";
}
public int write(String opath)
{
if(dclass_index!=0)
return write(dclass_index,opath);
else
return -1;
}
public long walk()
{
if(dclass_index!=0)
return walk(dclass_index);
else
return -1;
}
public Map<String,String> classify(String s)
{
return classify(s,true);
}
public Map<String,String> get(String s)
{
return classify(s,false);
}
private Map<String,String> classify(String s,boolean classify)
{
Map<String,String> ret=new HashMap<String,String>();
if(dclass_index!=0 && s!=null)
{
long kv;
if(classify)
kv=classify(dclass_index,s);
else
kv=get(dclass_index,s);
if(kv!=0)
{
int len=kvlength(kv);
String id=kvgetid(kv);
for(int i=0;i<len;i++)
{
String key=kvgetkey(kv,i);
String value=kvgetvalue(kv,i);
ret.put(key,value);
}
ret.put("id",id);
}
}
return ret;
}
public synchronized void free()
{
if(dclass_index!=0)
free(dclass_index);
}
@Override
protected void finalize() throws Throwable
{
free();
super.finalize();
}
}