Example usage for java.lang CloneNotSupportedException initCause

List of usage examples for java.lang CloneNotSupportedException initCause

Introduction

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

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

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

@Override
public POCast clone() throws CloneNotSupportedException {
    POCast clone = new POCast(
            new OperatorKey(mKey.scope, NodeIdGenerator.getGenerator().getNextNodeId(mKey.scope)));
    clone.cloneHelper(this);
    clone.funcSpec = funcSpec;/*from   w  ww.ja va2  s  .co  m*/
    clone.fieldSchema = fieldSchema;
    try {
        clone.instantiateFunc();
    } catch (IOException e) {
        CloneNotSupportedException cnse = new CloneNotSupportedException();
        cnse.initCause(e);
        throw cnse;
    }
    return clone;
}

From source file:org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POFRJoin.java

@Override
public POFRJoin clone() throws CloneNotSupportedException {
    POFRJoin clone = (POFRJoin) super.clone();
    // Not doing deep copy of nullBag, nullBag, inputSchemas, keySchemas
    // as they are read only
    clone.phyPlanLists = new ArrayList<List<PhysicalPlan>>(phyPlanLists.size());
    for (List<PhysicalPlan> ppLst : phyPlanLists) {
        clone.phyPlanLists.add(clonePlans(ppLst));
    }//  w  ww . j a v a  2s. c  o m

    clone.LRs = new POLocalRearrange[phyPlanLists.size()];
    clone.constExps = new ConstantExpression[phyPlanLists.size()];
    try {
        clone.createJoinPlans(getOperatorKey());
    } catch (ExecException e) {
        CloneNotSupportedException cnse = new CloneNotSupportedException(
                "Problem with setting plans of " + this.getClass().getSimpleName());
        cnse.initCause(e);
        throw cnse;
    }
    return clone;
}

From source file:org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POLocalRearrange.java

/**
 * Make a deep copy of this operator.// w ww  . j a v a  2s .com
 * @throws CloneNotSupportedException
 */
@Override
public POLocalRearrange clone() throws CloneNotSupportedException {
    POLocalRearrange clone = (POLocalRearrange) super.clone();
    // Constructor
    clone.leafOps = new ArrayList<ExpressionOperator>();
    clone.secondaryLeafOps = new ArrayList<ExpressionOperator>();
    // Needs to be called as setDistinct so that the fake index tuple gets
    // created.
    clone.setDistinct(mIsDistinct);
    // Set the keyType to mainKeyType. setSecondaryPlans will calculate
    // based on that and set keyType to the final value
    if (useSecondaryKey) {
        clone.keyType = mainKeyType;
    }
    try {
        clone.setPlans(clonePlans(plans));
        if (secondaryPlans != null) {
            clone.setSecondaryPlans(clonePlans(secondaryPlans));
        }
    } catch (PlanException pe) {
        CloneNotSupportedException cnse = new CloneNotSupportedException(
                "Problem with setting plans of " + this.getClass().getSimpleName());
        cnse.initCause(pe);
        throw cnse;
    }
    return clone;
}

From source file:org.kalypsodeegree_impl.model.feature.FeatureHelper.java

/**
 * @throws CloneNotSupportedException/*from ww w  .  j ava  2s  .  c  o m*/
 * @throws UnsupportedOperationException
 *           If type of object is not supported for clone <br/>
 *           FIXME: get gml version from source feature type
 */
public static Object cloneData(final Feature sourceFeature, final Feature targetFeature, final IPropertyType pt,
        final Object object) throws Exception {
    if (object == null)
        return null;

    if (pt instanceof IRelationType) {
        final IRelationType rt = (IRelationType) pt;

        if (object instanceof String) {
            // its an internal link: change to external if we change the workspace
            if (sourceFeature.getWorkspace().equals(targetFeature.getWorkspace()))
                return object;
            else
                // TODO: not yet supported; internal links will be broken after clone
                return null;
        } else if (object instanceof IXLinkedFeature) {
            final IXLinkedFeature xlink = (IXLinkedFeature) object;
            // retarget xlink
            return new XLinkedFeature_Impl(targetFeature, rt, xlink.getFeatureType(), xlink.getHref());
        } else if (object instanceof Feature)
            return FeatureHelper.cloneFeature(targetFeature, rt, (Feature) object);

        return null;
    }

    // its an geometry? -> clone geometry
    if (object instanceof GM_Object) {
        final GM_Object gmo = (GM_Object) object;

        return gmo.clone();
    }

    // if we have an IMarshallingTypeHandler, it will do the clone for us.
    final ITypeRegistry<IMarshallingTypeHandler> typeRegistry = MarshallingTypeRegistrySingleton
            .getTypeRegistry();
    final IMarshallingTypeHandler typeHandler = typeRegistry.getTypeHandlerFor(pt);

    if (typeHandler != null) {
        try {
            final String gmlVersion = sourceFeature.getFeatureType().getGMLSchema().getGMLVersion();
            return typeHandler.cloneObject(object, gmlVersion);
        } catch (final Exception e) {
            final CloneNotSupportedException cnse = new CloneNotSupportedException(
                    "Kann Datenobjekt vom Typ '" + pt.getQName() + "' nicht kopieren.");
            cnse.initCause(e);
            throw cnse;
        }
    }
    throw new CloneNotSupportedException("Kann Datenobjekt vom Typ '" + pt.getQName() + "' nicht kopieren.");
}