Fixed some warnings and added toString function in JSONObjectStream
This commit is contained in:
parent
5c9a064eca
commit
89076bfa54
4 changed files with 20 additions and 4 deletions
0
src/zutil/db/bean/DBBean.java
Normal file → Executable file
0
src/zutil/db/bean/DBBean.java
Normal file → Executable file
|
|
@ -45,7 +45,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
|
||||||
public static final long CACHE_DATA_TTL = 1000*60*5; // 5 min in ms
|
public static final long CACHE_DATA_TTL = 1000*60*5; // 5 min in ms
|
||||||
/** A cache for detecting recursion **/
|
/** A cache for detecting recursion **/
|
||||||
protected static Map<Class<?>, Map<Long,DBBeanCache>> cache =
|
protected static Map<Class<?>, Map<Long,DBBeanCache>> cache =
|
||||||
new ConcurrentHashMap<Class<?>, Map<Long,DBBeanCache>>();
|
new ConcurrentHashMap<>();
|
||||||
private static Timer timer;
|
private static Timer timer;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
@ -283,7 +283,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
|
||||||
} finally{
|
} finally{
|
||||||
obj.processing_update = false;
|
obj.processing_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.postUpdateAction();
|
obj.postUpdateAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
package zutil.parser.json;
|
package zutil.parser.json;
|
||||||
|
|
||||||
import zutil.ClassUtil;
|
import zutil.ClassUtil;
|
||||||
|
import zutil.io.StringOutputStream;
|
||||||
import zutil.parser.Base64Encoder;
|
import zutil.parser.Base64Encoder;
|
||||||
import zutil.parser.DataNode;
|
import zutil.parser.DataNode;
|
||||||
import zutil.parser.DataNode.DataType;
|
import zutil.parser.DataNode.DataType;
|
||||||
|
|
@ -52,7 +53,7 @@ public class JSONObjectOutputStream extends OutputStream implements ObjectOutput
|
||||||
private JSONWriter out;
|
private JSONWriter out;
|
||||||
|
|
||||||
private JSONObjectOutputStream() {
|
private JSONObjectOutputStream() {
|
||||||
this.objectCache = new HashMap<Object, Integer>();
|
this.objectCache = new HashMap<>();
|
||||||
}
|
}
|
||||||
public JSONObjectOutputStream(OutputStream out) {
|
public JSONObjectOutputStream(OutputStream out) {
|
||||||
this();
|
this();
|
||||||
|
|
@ -64,6 +65,21 @@ public class JSONObjectOutputStream extends OutputStream implements ObjectOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a String containing the JSON representation of the Object
|
||||||
|
*/
|
||||||
|
public static String toString(Object obj){
|
||||||
|
try {
|
||||||
|
StringOutputStream out = new StringOutputStream();
|
||||||
|
JSONObjectOutputStream writer = new JSONObjectOutputStream(out);
|
||||||
|
writer.writeObject(obj);
|
||||||
|
writer.close();
|
||||||
|
return out.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void writeObject(Object obj) throws IOException{
|
public synchronized void writeObject(Object obj) throws IOException{
|
||||||
try{
|
try{
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class JSONWriter{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return JSON String that is generated from the input DataNode graph
|
* @return a String containing the JSON representation of the input DataNode graph
|
||||||
*/
|
*/
|
||||||
public static String toString(DataNode root){
|
public static String toString(DataNode root){
|
||||||
StringOutputStream out = new StringOutputStream();
|
StringOutputStream out = new StringOutputStream();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue