summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-24 14:55:47 (EDT)
committerEike Stepper2007-07-24 14:55:47 (EDT)
commit2f9202af2534071b5d46bfef933268b0d828a683 (patch)
tree33d8ffb70f91ff0ff1cf1dfc3a1a42ad528254e3
parent1dc36a799ded0baf523c4feeb76a583683d8bf4b (diff)
downloadcdo-2f9202af2534071b5d46bfef933268b0d828a683.zip
cdo-2f9202af2534071b5d46bfef933268b0d828a683.tar.gz
cdo-2f9202af2534071b5d46bfef933268b0d828a683.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java68
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java38
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java60
5 files changed, 105 insertions, 66 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
index c74910f..39634e6 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
@@ -13,7 +13,8 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
-import org.eclipse.emf.cdo.protocol.util.ImplementationError;
+
+import org.eclipse.net4j.util.ImplementationError;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
index 8ace90b..d5cae2d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
@@ -13,8 +13,8 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.server.RepositoryPackageManager;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.util.ImplementationError;
+import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
index 054b45a..bb5a7aa 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
@@ -21,9 +21,10 @@ import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
@@ -54,7 +55,6 @@ import org.eclipse.emf.internal.cdo.util.GenUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
@@ -489,7 +489,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
Class<?> targetClass = target.getClass();
String featureName = feature.getName();
String fieldName = featureName;// XXX safeName()
- Field field = getField(targetClass, fieldName);
+ Field field = ReflectUtil.getField(targetClass, fieldName);
if (field == null && feature.getType() == CDOType.BOOLEAN)
{
if (targetClass.isAssignableFrom(EAttributeImpl.class) || targetClass.isAssignableFrom(EClassImpl.class)
@@ -521,7 +521,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
String flagName = GenUtil.getFeatureUpperName(featureName) + "_EFLAG";
int flagsMask = getEFlagMask(targetClass, flagName);
- field = getField(targetClass, "eFlags");
+ field = ReflectUtil.getField(targetClass, "eFlags");
int flags = (Integer)getFiedValue(target, field);
boolean on = (Boolean)value;
if (on)
@@ -587,7 +587,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
private static int getEFlagMask(Class<?> targetClass, String flagName)
{
- Field field = getField(targetClass, flagName);
+ Field field = ReflectUtil.getField(targetClass, flagName);
if (!field.isAccessible())
{
field.setAccessible(true);
@@ -603,64 +603,6 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
}
}
- private static Field getField(Class<?> c, String fieldName)
- {
- try
- {
- try
- {
- return c.getDeclaredField(fieldName);
- }
- catch (NoSuchFieldException ex)
- {
- Class<?> superclass = c.getSuperclass();
- if (superclass != null)
- {
- return getField(superclass, fieldName);
- }
-
- return null;
- }
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new ImplementationError(ex);
- }
- }
-
- private static Method getMethod(Class<?> c, String methodName, Class... parameterTypes)
- {
- try
- {
- try
- {
- return c.getDeclaredMethod(methodName, parameterTypes);
- }
- catch (NoSuchMethodException ex)
- {
- Class<?> superclass = c.getSuperclass();
- if (superclass != null)
- {
- return getMethod(superclass, methodName, parameterTypes);
- }
-
- return null;
- }
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new ImplementationError(ex);
- }
- }
-
public EList<Adapter> eAdapters()
{
return getTarget().eAdapters();
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java
new file mode 100644
index 0000000..5aa2fc4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util;
+
+/**
+ * @author Eike Stepper
+ */
+public class ImplementationError extends Error
+{
+ private static final long serialVersionUID = 1L;
+
+ public ImplementationError()
+ {
+ }
+
+ public ImplementationError(String message)
+ {
+ super(message);
+ }
+
+ public ImplementationError(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ImplementationError(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
index e4a52f8..c9e478c 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
@@ -56,6 +56,64 @@ public final class ReflectUtil
{
}
+ public static Field getField(Class<?> c, String fieldName)
+ {
+ try
+ {
+ try
+ {
+ return c.getDeclaredField(fieldName);
+ }
+ catch (NoSuchFieldException ex)
+ {
+ Class<?> superclass = c.getSuperclass();
+ if (superclass != null)
+ {
+ return getField(superclass, fieldName);
+ }
+
+ return null;
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new ImplementationError(ex);
+ }
+ }
+
+ public static Method getMethod(Class<?> c, String methodName, Class... parameterTypes)
+ {
+ try
+ {
+ try
+ {
+ return c.getDeclaredMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ex)
+ {
+ Class<?> superclass = c.getSuperclass();
+ if (superclass != null)
+ {
+ return getMethod(superclass, methodName, parameterTypes);
+ }
+
+ return null;
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new ImplementationError(ex);
+ }
+ }
+
public static void printStackTrace(PrintStream out, StackTraceElement[] stackTrace)
{
for (int i = 2; i < stackTrace.length; i++)
@@ -364,7 +422,7 @@ public final class ReflectUtil
// Recurse
toString(segment.getSuperclass(), object, prefix, builder);
- String segmentPrefix = segment == object.getClass() ? "" : getSimpleName(segment) + NAMESPACE_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
+ String segmentPrefix = segment == object.getClass() ? "" : getSimpleName(segment) + NAMESPACE_SEPARATOR; //$NON-NLS-1$
Field[] fields = segment.getDeclaredFields();
for (Field field : fields)
{