📄 resultconverter.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Core License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id: ResultConverter.java,v 1.5 2002/09/18 06:54:15 per_nyfelt Exp $
package org.ozoneDB.core;
import org.ozoneDB.*;
import org.ozoneDB.core.DbRemote.ProxyObjectGate;
import java.lang.reflect.*;
/**
* The base class for the classes that convert the parameter and results
* of methods invocations that go through Database or ExternalDatabase.
*
*
* @author <a href="http://www.softwarebuero.de/">SMB</a>
* @author <a href="http://www.medium.net/">Medium.net</a>
* @version $Revision: 1.5 $Date: 2002/09/18 06:54:15 $
*/
public final class ResultConverter extends Object {
public static void updateProxyLinks( Object obj, OzoneInterface db ) throws Exception {
String name = obj != null ? obj.getClass().getName() : "(null)";
System.out.println( "*** Proxy test: " + name );
if (obj == null) {
//do nothing
} else if (obj instanceof OzoneProxy) {
((OzoneProxy)obj).link = db;
System.out.println( " *** link changed *** " + db );
} else {
Class cl = obj.getClass();
int mdf = cl.getModifiers();
if (Modifier.isTransient( mdf ) || Modifier.isStatic( mdf ) || Modifier.isFinal( mdf )) {
//do nothing
} else if (cl.isPrimitive()) {
//do nothing
} else if (cl.isArray()) {
int len = Array.getLength( obj );
for (int j = 0; j < len; j++) {
Object member = Array.get( obj, j );
updateProxyLinks( member, db );
}
} else {
Field[] fields = cl.getFields();
for (int i = 0; i < fields.length; i++) {
// System.out.println (fields[i].toString());
Object member = fields[i].get( obj );
updateProxyLinks( member, db );
}
}
}
}
/**
Substitute OzoneCompatible by a corresponding proxy. Do this recursive
for all members.
*/
public static Object substituteOzoneCompatibles(Object obj) /*throws Exception*/ {
return substituteOzoneCompatibles(obj,null);
}
/**
Substitute OzoneCompatible by a corresponding proxy. Do this recursive
for all members.
@param proxyObjectGate
the client ProxyObjectGate whose objectsReferencesByClient should be filled with all OzoneProxy-Objects
found herein or null, if no database client's ProxyObjectGate objectsReferencesByClient should be updated.
*/
public static Object substituteOzoneCompatibles(Object obj,ProxyObjectGate proxyObjectGate) /*throws Exception*/ {
// String name = obj != null ? obj.getClass().getName() : "(null)";
// System.out.println ("***OzoneCompatible test:" + name);
//FIXME: should be recursive
// if (obj != null && obj instanceof OzoneCompatible) {
if (obj instanceof OzoneCompatible) {
// System.out.println ("*** substitute ***");
OzoneProxy proxy = ((OzoneCompatible)obj).container().ozoneProxy();
if (proxyObjectGate!=null) {
proxyObjectGate.addObjectReferencedByClient(proxy);
}
return proxy;
// return (((OzoneCompatible)obj).objID()!=null) ? ((OzoneCompatible)obj).container().ozoneProxy() : obj;
}
if (proxyObjectGate!=null) { // If the object is not OzoneCompatible, it may be OzoneProxy, which should also be registered at the client.
if (obj instanceof OzoneProxy) {
proxyObjectGate.addObjectReferencedByClient((OzoneProxy) obj);
}
}
return obj;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -