Example usage for java.lang CloneNotSupportedException printStackTrace

List of usage examples for java.lang CloneNotSupportedException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.jfree.data.xy.junit.XYSeriesCollectionTests.java

/**
 * Confirm that cloning works.//from   ww  w . j a v a 2  s.  com
 */
public void testCloning() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeriesCollection c2 = null;
    try {
        c2 = (XYSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

From source file:com.supremainc.biostar2.user.UserInquriyFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (super.onOptionsItemSelected(item)) {
        return true;
    }/*from  w  ww .  ja v  a  2 s .c om*/
    switch (item.getItemId()) {
    case R.id.action_edit:
        User arg = null;
        try {
            arg = mUserInfo.clone();
        } catch (CloneNotSupportedException e) {
            Log.e(TAG, "selected user clone fail");
            e.printStackTrace();
        }
        Bundle bundle = new Bundle();
        bundle.putSerializable(User.TAG, arg);
        mScreenControl.addScreen(ScreenType.USER_MODIFY, bundle);
        return true;
    default:
        break;
    }
    return false;
}

From source file:org.eclipse.jubula.client.teststyle.checks.BaseCheck.java

/**
 * {@inheritDoc}/*from ww  w  .j av  a2 s.  c o m*/
 */
public BaseCheck clone() {
    BaseCheck tmp = null;
    try {
        tmp = (BaseCheck) super.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }

    tmp.setConf(new CheckConfMock());
    tmp.setAttributes(new HashMap<String, String>(this.getAttributes()));
    tmp.setActive(this.isActive());
    tmp.setContexts(new HashMap<BaseContext, Boolean>(this.getContexts()));
    tmp.setSeverity(this.getSeverity());
    tmp.setFulltextDescription(this.getFulltextDescription());

    return tmp;
}

From source file:edu.ku.brc.af.core.NavBoxAction.java

public void actionPerformed(ActionEvent e) {
    boolean isDataActionEvent = e instanceof DataActionEvent;

    if (cmdAction != null) {
        if (isDataActionEvent) {
            try {
                CommandAction cachedCA = (CommandAction) cmdAction.clone();
                cmdAction.setData(((DataActionEvent) e).getData());
                CommandDispatcher.dispatch(cmdAction);
                cmdAction.set(cachedCA);

            } catch (CloneNotSupportedException ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(NavBoxAction.class, ex);
                ex.printStackTrace();
            }//from   w w w. ja  v a  2 s  .  com
        } else {
            CommandDispatcher.dispatch(cmdAction);
        }

    } else {
        Object data = null;
        if (e instanceof DataActionEvent) {
            data = ((DataActionEvent) e).getData();
        }

        if (StringUtils.isNotEmpty(type) && StringUtils.isNotEmpty(action)) {
            CommandAction cmd = new CommandAction(type, action, data);
            cmd.addProperties(properties);
            CommandDispatcher.dispatch(cmd);

        } else {
            log.debug("Type and/or Action was NULL!"); //$NON-NLS-1$
        }
    }
}

From source file:com.wlami.mibox.client.application.PropertyAppSettings.java

@Override
public AppSettings clone() {
    try {//  w ww.  j  a  va  2s.c  o m
        return (AppSettings) super.clone();
    } catch (CloneNotSupportedException e) {
        // This shouldn't be possible!
        e.printStackTrace();
    }
    return null;
}

From source file:org.jfree.data.xy.junit.DefaultIntervalXYDatasetTest.java

/**
 * Confirm that cloning works./* www  .  j a  va  2s  .c o m*/
 */
public void testCloning() {
    DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset();
    DefaultIntervalXYDataset d2 = null;
    try {
        d2 = (DefaultIntervalXYDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // try a dataset with some content...
    d1 = createSampleDataset1();
    try {
        d2 = (DefaultIntervalXYDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

From source file:org.jfree.data.xy.junit.DefaultIntervalXYDatasetTest.java

/**
 * Another test for cloning.//from w  ww. j  av  a 2  s . co m
 */
public void testCloning2() {
    DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] x1Start = new double[] { 0.9, 1.9, 2.9 };
    double[] x1End = new double[] { 1.1, 2.1, 3.1 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[] y1Start = new double[] { 1.09, 2.09, 3.09 };
    double[] y1End = new double[] { 1.11, 2.11, 3.11 };
    double[][] data1 = new double[][] { x1, x1Start, x1End, y1, y1Start, y1End };
    d1.addSeries("S1", data1);
    DefaultIntervalXYDataset d2 = null;
    try {
        d2 = (DefaultIntervalXYDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // check independence
    x1[0] = 111.1;
    assertFalse(d1.equals(d2));
}

From source file:org.jfree.data.category.junit.DefaultCategoryDatasetTest.java

/**
 * Confirm that cloning works.//w ww  .  j a v  a2 s .com
 */
public void testCloning() {
    DefaultCategoryDataset d1 = new DefaultCategoryDataset();
    DefaultCategoryDataset d2 = null;
    try {
        d2 = (DefaultCategoryDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // try a dataset with some content...
    d1.addValue(1.0, "R1", "C1");
    d1.addValue(2.0, "R1", "C2");
    try {
        d2 = (DefaultCategoryDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // check that the clone doesn't share the same underlying arrays.
    d1.addValue(3.0, "R1", "C1");
    assertFalse(d1.equals(d2));
    d2.addValue(3.0, "R1", "C1");
    assertTrue(d1.equals(d2));
}

From source file:com.projity.pm.task.TaskSnapshot.java

public Object clone() {
    TaskSnapshot newOne = null;//from ww  w  . j  av a 2  s  .  c om
    try {
        newOne = (TaskSnapshot) super.clone();
        newOne.currentSchedule = (TaskSchedule) currentSchedule.clone();
        newOne.hasAssignments = (HasAssignments) ((HasAssignmentsImpl) hasAssignments)
                .cloneWithSchedule(newOne.currentSchedule);
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }

    return newOne;
}

From source file:com.projity.pm.task.TaskSnapshot.java

public Object deepCloneWithTask(Task task) {

    TaskSnapshot newOne = null;//from   w  w  w. j a v a  2 s.c o  m
    try {
        newOne = (TaskSnapshot) super.clone();
        newOne.currentSchedule = (TaskSchedule) currentSchedule.cloneWithTask(task);
        newOne.hasAssignments = (HasAssignments) ((HasAssignmentsImpl) hasAssignments).deepCloneWithTask(task);
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }

    return newOne;
}