Java Object Clone clone_obj_array(Object source)

Here you can find the source of clone_obj_array(Object source)

Description

clonobarray

License

Open Source License

Declaration

public static Object clone_obj_array(Object source) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ******************************************************************************/

public class Main {
    public static Object clone_obj_array(Object source) {
        if (source instanceof float[]) {
            return ((float[]) source).clone();
        } else {/*from w  w w .  j  a v  a  2  s.c om*/
            if (source instanceof short[]) {
                return ((short[]) source).clone();
            } else {
                if (source instanceof byte[]) {
                    return ((byte[]) source).clone();
                } else {
                    if (source instanceof short[])
                        return ((short[]) source).clone();
                    else
                        return ((int[]) source).clone();
                }
            }
        }
    }

    public static Object[] clone_obj_array(Object[] source) {
        Object[] cloned = new Object[source.length];
        for (int i = 0; i < source.length; i++)
            cloned[i] = clone_obj_array(source[i]);
        return cloned;
    }

    public static Object[][] clone_obj_array(Object[][] source) {
        Object[][] cloned = new Object[source.length][];
        for (int i = 0; i < source.length; i++)
            cloned[i] = clone_obj_array(source[i]);
        return cloned;
    }
}

Related

  1. clone(Object a)
  2. clone(Object original)
  3. clone(Object value)
  4. clone(String name, String type, int pos)
  5. clone(T array)
  6. cloneClass(Class clazz)
  7. cloneCloneNotSupportedObject(final T obj, final boolean deep)
  8. cloneShort(Short sOriginal)
  9. cloneStackTrace(Throwable aException)