Example usage for java.lang CloneNotSupportedException CloneNotSupportedException

List of usage examples for java.lang CloneNotSupportedException CloneNotSupportedException

Introduction

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

Prototype

public CloneNotSupportedException(String s) 

Source Link

Document

Constructs a CloneNotSupportedException with the specified detail message.

Usage

From source file:org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.ExpressionOperator.java

/**
 * Make a deep copy of this operator.  This is declared here to make it
 * possible to call clone on ExpressionOperators.
 * @throws CloneNotSupportedException// w  ww .  j av a 2 s  .  c  om
 */
@Override
public ExpressionOperator clone() throws CloneNotSupportedException {
    String s = "This expression operator does not implement clone.";
    log.error(s);
    throw new CloneNotSupportedException(s);
}

From source file:com.laxser.blitz.lama.core.LamaDaoInvocationHandler.java

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

    if (logger.isDebugEnabled()) {
        logger.debug("invoking  " + definition.getDAOClazz().getName() + "#" + method.getName());
    }// w  ww.  j  a  v  a 2s .c o  m

    if (Object.class == method.getDeclaringClass()) {
        String methodName = method.getName();
        if (methodName.equals("toString")) {
            return LamaDaoInvocationHandler.this.toString();
        }
        if (methodName.equals("hashCode")) {
            return definition.getDAOClazz().hashCode() * 13 + this.hashCode();
        }
        if (methodName.equals("equals")) {
            return args[0] == proxy;
        }
        if (methodName.equals("clone")) {
            throw new CloneNotSupportedException("clone is not supported for jade dao.");
        }
        throw new UnsupportedOperationException(definition.getDAOClazz().getName() + "#" + method.getName());
    }

    LamaOperation operation = jdbcOperations.get(method);
    if (operation == null) {
        synchronized (jdbcOperations) {
            operation = jdbcOperations.get(method);
            if (operation == null) {
                Modifier modifier = new Modifier(definition, method);
                operation = jdbcOperationFactory.getOperation(dataAccess, modifier);
                jdbcOperations.put(method, operation);
            }
        }
    }
    //
    // ?  Map
    Map<String, Object> parameters;
    if (args == null || args.length == 0) {
        parameters = new HashMap<String, Object>(4);
    } else {
        parameters = new HashMap<String, Object>(args.length * 2 + 4);
        SQLParam[] sqlParams = operation.getModifier().getParameterAnnotations(SQLParam.class);
        for (int i = 0; i < args.length; i++) {
            parameters.put(":" + (i + 1), args[i]);
            SQLParam sqlParam = sqlParams[i];
            if (sqlParam != null) {
                parameters.put(sqlParam.value(), args[i]);
            }
        }
    }
    //
    if (logger.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("invoking ").append(definition.getDAOClazz().getName()).append("#").append(method.getName())
                .append("\n");
        sb.append("\toperation: ").append(operation.getClass().getSimpleName()).append("\n");
        sb.append("\tsql: ").append(operation.getModifier().getAnnotation(SQL.class).value()).append("\n");
        sb.append("\tparams: ");
        ArrayList<String> keys = new ArrayList<String>(parameters.keySet());
        Collections.sort(keys);
        for (String key : keys) {
            sb.append(key).append("='").append(parameters.get(key)).append("'  ");
        }
        logger.debug(sb.toString());
    }

    return operation.execute(parameters);
}

From source file:org.eclipse.ecr.runtime.deploy.ExtensibleContribution.java

/**
 * perform a deep clone to void sharing collection elements between clones
 *///www  .j av  a2  s . co m
@Override
public ExtensibleContribution clone() throws CloneNotSupportedException {
    try {
        ExtensibleContribution clone = getClass().newInstance();
        copyOver(clone);
        clone.contributionId = contributionId;
        clone.baseContributionId = baseContributionId;
        return clone;
    } catch (Exception e) {
        log.error(e);
        throw new CloneNotSupportedException(
                "Failed to instantiate the contribution class. Contribution classes must have a trivial constructor");
    }
}

From source file:org.aprilis.jrest.compile.Compile.java

/**
 * Clones are not supported for this class so this prevents the users from
 * doing so./* w w w.jav  a 2  s . co m*/
 */
public Object clone() throws CloneNotSupportedException {
    throw new CloneNotSupportedException("This is a Singleton Ojbect; Buzz off");
}

From source file:org.sparkcommerce.openadmin.server.security.domain.AdminPermissionQualifiedEntityImpl.java

public void checkCloneable(AdminPermissionQualifiedEntity qualifiedEntity)
        throws CloneNotSupportedException, SecurityException, NoSuchMethodException {
    Method cloneMethod = qualifiedEntity.getClass().getMethod("clone", new Class[] {});
    if (cloneMethod.getDeclaringClass().getName().startsWith("org.sparkcommerce")
            && !qualifiedEntity.getClass().getName().startsWith("org.sparkcommerce")) {
        //subclass is not implementing the clone method
        throw new CloneNotSupportedException("Custom extensions and implementations should implement clone.");
    }// w  w  w .  j  a v  a 2s. c  o m
}

From source file:org.broadleafcommerce.openadmin.server.security.domain.AdminPermissionQualifiedEntityImpl.java

public void checkCloneable(AdminPermissionQualifiedEntity qualifiedEntity)
        throws CloneNotSupportedException, SecurityException, NoSuchMethodException {
    Method cloneMethod = qualifiedEntity.getClass().getMethod("clone", new Class[] {});
    if (cloneMethod.getDeclaringClass().getName().startsWith("org.broadleafcommerce")
            && !qualifiedEntity.getClass().getName().startsWith("org.broadleafcommerce")) {
        //subclass is not implementing the clone method
        throw new CloneNotSupportedException("Custom extensions and implementations should implement clone.");
    }//from   w  w  w .  j  a  va  2s . co m
}

From source file:org.broadleafcommerce.core.order.domain.OrderItemAttributeImpl.java

public void checkCloneable(OrderItemAttribute itemAttribute)
        throws CloneNotSupportedException, SecurityException, NoSuchMethodException {
    Method cloneMethod = itemAttribute.getClass().getMethod("clone", new Class[] {});
    if (cloneMethod.getDeclaringClass().getName().startsWith("org.broadleafcommerce")
            && !itemAttribute.getClass().getName().startsWith("org.broadleafcommerce")) {
        //subclass is not implementing the clone method
        throw new CloneNotSupportedException(
                "Custom extensions and implementations should implement clone in order to guarantee split and merge operations are performed accurately");
    }//ww w  .  j av a 2 s  .  c  o m
}

From source file:com.wantscart.jade.core.JadeDaoInvocationHandler.java

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (args != null) {
        for (int i = 0; i < args.length; i++) {
            Object arg = args[i];
            if (arg == null) {
                continue;
            }//from  w  ww . j  a  va2  s .  co m
            Class<?> argType = arg.getClass();
            if (!TypeUtils.isBaseType(argType) && !(arg instanceof Collection)) {
                TableSchema schema = TableSchema.getSchema(argType);
                if (schema != null) {
                    Map mapArg = new HashMap();
                    for (TableSchema.Column column : schema.getColumns()) {
                        Object field = column.getGetter().invoke(arg);
                        if (column.isSerializable()) {
                            if (column.getSerializer() instanceof NullSerializer
                                    && field instanceof Serializable) {
                                field = ((Serializable) field).serialize();
                            } else {
                                field = column.getSerializer().serialize(field);
                            }
                        }
                        mapArg.put(column.getOriginName(), field);
                    }
                    args[i] = mapArg;
                }
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("invoking  " + definition.getDAOClazz().getName() + "#" + method.getName());
    }

    if (Object.class == method.getDeclaringClass()) {
        String methodName = method.getName();
        if (methodName.equals("toString")) {
            return JadeDaoInvocationHandler.this.toString();
        }
        if (methodName.equals("hashCode")) {
            return definition.getDAOClazz().hashCode() * 13 + this.hashCode();
        }
        if (methodName.equals("equals")) {
            return args[0] == proxy;
        }
        if (methodName.equals("clone")) {
            throw new CloneNotSupportedException("clone is not supported for jade dao.");
        }
        throw new UnsupportedOperationException(definition.getDAOClazz().getName() + "#" + method.getName());
    }

    JadeOperation operation = jdbcOperations.get(method);
    if (operation == null) {
        synchronized (jdbcOperations) {
            operation = jdbcOperations.get(method);
            if (operation == null) {
                Modifier modifier = new Modifier(definition, method);
                operation = jdbcOperationFactory.getOperation(dataAccess, modifier);
                jdbcOperations.put(method, operation);
            }
        }
    }
    //
    // ?  Map
    Map<String, Object> parameters;
    if (args == null || args.length == 0) {
        parameters = new HashMap<String, Object>(4);
    } else {
        parameters = new HashMap<String, Object>(args.length * 2 + 4);
        SQLParam[] sqlParams = operation.getModifier().getParameterAnnotations(SQLParam.class);
        for (int i = 0; i < args.length; i++) {
            parameters.put(":" + (i + 1), args[i]);
            SQLParam sqlParam = sqlParams[i];
            if (sqlParam != null) {
                parameters.put(sqlParam.value(), args[i]);
            }
        }
    }
    //
    if (logger.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("invoking ").append(definition.getDAOClazz().getName()).append("#").append(method.getName())
                .append("\n");
        sb.append("\toperation: ").append(operation.getClass().getSimpleName()).append("\n");
        sb.append("\tsql: ").append(operation.getModifier().getAnnotation(SQL.class).value()).append("\n");
        sb.append("\tparams: ");
        ArrayList<String> keys = new ArrayList<String>(parameters.keySet());
        Collections.sort(keys);
        for (String key : keys) {
            sb.append(key).append("='").append(parameters.get(key)).append("'  ");
        }
        logger.debug(sb.toString());
    }

    return operation.execute(parameters);
}

From source file:org.broadleafcommerce.core.offer.domain.CandidateItemOfferImpl.java

public void checkCloneable(CandidateItemOffer itemOffer)
        throws CloneNotSupportedException, SecurityException, NoSuchMethodException {
    Method cloneMethod = itemOffer.getClass().getMethod("clone", new Class[] {});
    if (cloneMethod.getDeclaringClass().getName().startsWith("org.broadleafcommerce")
            && !itemOffer.getClass().getName().startsWith("org.broadleafcommerce")) {
        //subclass is not implementing the clone method
        throw new CloneNotSupportedException(
                "Custom extensions and implementations should implement clone in order to guarantee split and merge operations are performed accurately");
    }//from www .  j  a v a  2s . c o  m
}

From source file:org.sparkcommerce.core.order.domain.OrderItemAttributeImpl.java

public void checkCloneable(OrderItemAttribute itemAttribute)
        throws CloneNotSupportedException, SecurityException, NoSuchMethodException {
    Method cloneMethod = itemAttribute.getClass().getMethod("clone", new Class[] {});
    if (cloneMethod.getDeclaringClass().getName().startsWith("org.sparkcommerce")
            && !itemAttribute.getClass().getName().startsWith("org.sparkcommerce")) {
        //subclass is not implementing the clone method
        throw new CloneNotSupportedException(
                "Custom extensions and implementations should implement clone in order to guarantee split and merge operations are performed accurately");
    }/*from w  w  w  . j av a  2s.  co  m*/
}