Example usage for java.lang CloneNotSupportedException toString

List of usage examples for java.lang CloneNotSupportedException toString

Introduction

In this page you can find the example usage for java.lang CloneNotSupportedException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Imports external properties into {@link PropertyPackage} called <code>packageName</code> .
 * The actual import is handled by {@link PropertyPackage#importProperties(Properties, boolean)}.
 * //from   ww w  .ja v  a  2s .c  om
 * @param packageName the name of the package. Can not be <code>null</code> or empty.
 * @param externalProperties the properties to import. This can not be <code>null</code>
 * @param overwrite boolean flag indicates whether to override existing properties
 * @return a new clone of the {@link PropertyPackage} made after the properties are imported
 * @throws PropertiesException if there is no package called <code>packageName</code>
 * @throws IllegalArgumentException if any of the arguments is <code>null</code>
 */
public static synchronized PropertyPackage importProperties(String packageName, Properties externalProperties,
        boolean overwrite) throws PropertiesException {
    if (StringUtils.isBlank(packageName))
        throw new IllegalArgumentException("package name can not be null nor empty string");
    if (!allPackages.containsKey(packageName))
        throw new PropertiesException("No package called " + packageName + " found ");
    PropertyPackage propertyPackage = allPackages.get(packageName);
    try {
        propertyPackage.importProperties(externalProperties, overwrite);
        save();
        return (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Adds new {@link Property} in {@link PropertyPackage} called <code>packageName</code> by
 * calling {@link PropertyPackage#addProperty(Property)}.
 * /*from   w  ww  .  j  a v a  2  s.c om*/
 * @param packageName the name of the package. Can not be <code>null</code> or empty.
 * @param property the {@link Property} to add. Can not be <code>null</code>
 * @return a new clone of the {@link PropertyPackage} made after the property is added
 * @throws PropertiesException if no package called <code>packageName</code> found or if such
 *         {@link Property} already exists in this package
 * @throws IllegalArgumentException if any of the arguments is <code>null</code>
 */
public static synchronized PropertyPackage addProperty(String packageName, Property property)
        throws PropertiesException {
    if (StringUtils.isBlank(packageName))
        throw new IllegalArgumentException("package name can not be null nor empty string");
    if (property == null)
        throw new IllegalArgumentException("property can not be null");
    if (!allPackages.containsKey(packageName))
        throw new PropertiesException("No package called " + packageName + " found ");
    PropertyPackage propertyPackage = allPackages.get(packageName);
    try {
        propertyPackage.addProperty((Property) property.clone());
        save();
        return (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Updates {@link Property} in {@link PropertyPackage} called <code>packageName</code>. The
 * actual update is handled by {@link PropertyPackage#updateProperty(Property)}
 * //w ww .j a v a  2 s .  c  o m
 * @param packageName the name of the package. Can not be <code>null</code> or empty.
 * @param property the {@link Property} to be updated. Can not be <code>null</code>
 * @return a new clone of the {@link PropertyPackage} made after the property is updated
 * @throws PropertiesException if no package called <code>packageName</code> found or if no
 *         such {@link Property} exists in this package
 * @throws IllegalArgumentException if any of the arguments is <code>null</code>
 */
public static synchronized PropertyPackage updateProperty(String packageName, Property property)
        throws PropertiesException {
    if (StringUtils.isBlank(packageName))
        throw new IllegalArgumentException("package name can not be null nor empty string");
    if (property == null)
        throw new IllegalArgumentException("property can not be null");
    if (!allPackages.containsKey(packageName))
        throw new PropertiesException("No package called " + packageName + " found ");
    PropertyPackage propertyPackage = allPackages.get(packageName);
    try {
        propertyPackage.updateProperty((Property) property.clone());
        save();
        return (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Updates existing {@link Property} called <code>oldPropertyName</code> in
 * {@link PropertyPackage} called <code>packageName</code> with values from
 * <code>property</code>. The actual update is handled by
 * {@link PropertyPackage#updateProperty(Property)}.
 * //ww w .j  a  v a 2 s.  c om
 * @param packageName the name of the package. Can not be <code>null</code> or empty.
 * @param oldPropertyName the name of the property to be updated
 * @param property the {@link Property} object to get the values from. Can not be
 *        <code>null</code>
 * @return a new clone of the {@link PropertyPackage} made after the property is updated
 * @throws PropertiesException if no package called <code>packageName</code> found or if no
 *         such {@link Property} exists in this package
 * @throws IllegalArgumentException if any of the arguments is <code>null</code>
 */
public static synchronized PropertyPackage updateProperty(String packageName, String oldPropertyName,
        Property property) throws PropertiesException {
    if (StringUtils.isBlank(packageName))
        throw new IllegalArgumentException("package name can not be null nor empty string");
    if (property == null)
        throw new IllegalArgumentException("property can not be null");
    if (!allPackages.containsKey(packageName))
        throw new PropertiesException("No package called " + packageName + " found ");
    PropertyPackage propertyPackage = allPackages.get(packageName);
    try {
        propertyPackage.updateProperty(oldPropertyName, (Property) property.clone());
        save();
        return (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Deletes {@link Property} called <code>propertyName</code> from {@link PropertyPackage}
 * called <code>packageName</code>. The actual deletion is handled by
 * {@link PropertyPackage#removeProperty(String)}.
 * //from  w ww .  jav a  2  s .  c o m
 * @param packageName the name of the package. Can not be <code>null</code> or empty.
 * @param propertyName the name of the property to be updated
 * @return a new clone of the {@link PropertyPackage} made after the property is deleted
 * @throws PropertiesException if there is no package called <code>packageName</code> or no
 *         property called <code>propertyName</code>
 * @throws IllegalArgumentException if any of the arguments is <code>null</code>
 */
public static synchronized PropertyPackage deleteProperty(String packageName, String propertyName)
        throws PropertiesException {
    if (StringUtils.isBlank(packageName))
        throw new IllegalArgumentException("package name can not be null nor empty string");
    if (StringUtils.isBlank(propertyName))
        throw new IllegalArgumentException("property can not be null nor empty string");
    if (!allPackages.containsKey(packageName))
        throw new PropertiesException("No package called " + packageName + " found ");
    PropertyPackage propertyPackage = allPackages.get(packageName);
    propertyPackage.removeProperty(propertyName);
    save();
    try {
        return (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:com.commsen.apropos.core.PropertiesManager.java

/**
 * Adds new {@link PropertyPackage}. NOTE: The object passed is cloned internally.
 * //  www. j a  va 2 s . co m
 * @param propertyPackage the {@link PropertyPackage} to be added. Can not be null.
 * @throws PropertiesException if package with that name already exists or if circular
 *         parent/child relation is detected.
 * @throws IllegalArgumentException if <code>propertyPackage</code> is null
 */
public static synchronized void addPropertyPackage(PropertyPackage propertyPackage) throws PropertiesException {
    if (propertyPackage == null)
        throw new IllegalArgumentException("propertySet can not be null");
    String key = propertyPackage.getName();
    if (allPackages.containsKey(key))
        throw new PropertiesException("Configuration called " + key + " already exists");

    String parentPackageName = null;
    if (propertyPackage.getParent() != null) {
        parentPackageName = propertyPackage.getParent().getName();
        propertyPackage.setParent(null);
    }

    PropertyPackage clonedPackage = null;
    try {
        clonedPackage = (PropertyPackage) propertyPackage.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }

    clonedPackage.setParent(allPackages.get(parentPackageName));
    allPackages.put(key, clonedPackage);
    if (clonedPackage.getParent() == null) {
        instance.rootPackages.add(clonedPackage);
    }
    // packages.add(propertyPackage);
    save();
}

From source file:ml.shifu.shifu.container.meta.MetaGroup.java

@Override
public MetaGroup clone() {
    MetaGroup metaGroup = null;/*w w  w  .ja  v  a2s. c o  m*/
    try {
        metaGroup = (MetaGroup) super.clone();
    } catch (CloneNotSupportedException e) {
        // This should never happen
        throw new InternalError(e.toString());
    }

    // copy group
    metaGroup.setGroup(group);

    // copy meta list, if not null
    if (CollectionUtils.isNotEmpty(metaList)) {
        List<MetaItem> metas = new ArrayList<MetaItem>();
        for (MetaItem metaItem : metaList) {
            metas.add(metaItem.clone());
        }
        metaGroup.setMetaList(metas);
    }

    return metaGroup;
}

From source file:IntVector.java

/**
 * Performs deep copy./*www.j a  va 2  s . com*/
 */
public Object clone() {
    try {
        final IntVector _clone = (IntVector) super.clone();

        // deep clone:
        if (m_size < COPY_THRESHOLD) {
            _clone.m_values = new int[m_values.length];
            final int[] _clone_values = _clone.m_values;
            for (int i = 0; i < m_size; ++i)
                _clone_values[i] = m_values[i];
        } else {
            _clone.m_values = (int[]) m_values.clone();
        }

        return _clone;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString());
    }
}

From source file:ml.shifu.shifu.container.meta.MetaItem.java

@Override
public MetaItem clone() {
    MetaItem copy = null;//from   ww w. j  a v  a 2 s  .c o  m
    try {
        copy = (MetaItem) super.clone();
    } catch (CloneNotSupportedException e) {
        // This should never happen
        throw new InternalError(e.toString());
    }

    copy.setName(name);
    copy.setType(type);
    copy.setDefval(defval);
    copy.setMaxLength(maxLength);
    copy.setMinLength(minLength);
    copy.setOptions(options);
    copy.setElementType(elementType);

    if (CollectionUtils.isNotEmpty(element)) {
        List<MetaItem> elementList = new ArrayList<MetaItem>();
        for (MetaItem meta : element) {
            elementList.add(meta.clone());
        }

        copy.setElement(elementList);
    }

    return copy;
}

From source file:eu.planets_project.tb.impl.model.eval.EvaluationExecutableImpl.java

public EvaluationExecutableImpl clone() {
    EvaluationExecutableImpl executable = null;
    try {//from w  w  w .j ava2s .c  o  m
        executable = (EvaluationExecutableImpl) super.clone();
    } catch (CloneNotSupportedException e) {
        //TODO add logging statement
        System.out.println("EvaluationExecutableImpl problems cloning " + e.toString());
    }

    return executable;
}