FileDocCategorySizeDatePackage
CloneUtils.javaAPI DocAndroid 1.5 API2670Wed May 06 22:41:10 BST 2009org.apache.http.client.utils

CloneUtils

public class CloneUtils extends Object
A collection of utilities to workaround limitations of Java clone framework.

Fields Summary
Constructors Summary
private CloneUtils()
This class should not be instantiated.

    
Methods Summary
public static java.lang.Objectclone(java.lang.Object obj)

        if (obj == null) {
            return null;
        }
        if (obj instanceof Cloneable) {
            Class<?> clazz = obj.getClass ();
            Method m;
            try {
                m = clazz.getMethod("clone", (Class[]) null);
            } catch (NoSuchMethodException ex) {
                throw new NoSuchMethodError(ex.getMessage());
            }
            try {
                return m.invoke(obj, (Object []) null);
            } catch (InvocationTargetException ex) {
                Throwable cause = ex.getCause();
                if (cause instanceof CloneNotSupportedException) {
                    throw ((CloneNotSupportedException) cause); 
                } else {
                    throw new Error("Unexpected exception", cause);
                }
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            }
        } else {
            throw new CloneNotSupportedException();
        }