Example usage for java.lang CloneNotSupportedException getMessage

List of usage examples for java.lang CloneNotSupportedException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.sourceforge.jabm.learning.QLearner.java

public Object protoClone() {
    try {//from   w ww  .j av  a2 s.c  o m
        QLearner cloned = (QLearner) clone();
        return cloned;
    } catch (CloneNotSupportedException e) {
        logger.error(e.getMessage());
        throw new Error(e);
    }
}

From source file:io.mindmaps.graql.internal.analytics.DegreeAndPersistVertexProgram.java

@Override
public DegreeAndPersistVertexProgram clone() {
    try {/*from  w w w  . j  av a  2s .c om*/
        final DegreeAndPersistVertexProgram clone = (DegreeAndPersistVertexProgram) super.clone();
        return clone;
    } catch (final CloneNotSupportedException e) {
        throw new IllegalStateException(
                ErrorMessage.CLONE_FAILED.getMessage(this.getClass().toString(), e.getMessage()), e);
    }
}

From source file:io.github.egonw.base.CMLEnricher.java

/**
 * Creates a deep clone of an atom container catching possible errors.
 * /*ww  w .ja  va2 s . c  om*/
 * @param container
 *            The container to be cloned.
 * @return The cloned container. Possibly null if cloning failed!
 */
private IAtomContainer checkedClone(IAtomContainer container) {
    IAtomContainer newcontainer = null;
    try {
        newcontainer = container.clone();
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(newcontainer);
        CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()).addImplicitHydrogens(newcontainer);
    } catch (CloneNotSupportedException e) {
        Logger.error("Something went wrong cloning atom container: " + e.getMessage());
    } catch (Throwable e) {
        Logger.error("Error " + e.getMessage());
    }
    return newcontainer;
}

From source file:reactor.js.core.JavaScriptObject.java

public JavaScriptObject copyOf() {
    try {//w  w w .j  av a2 s .co  m
        return (JavaScriptObject) clone();
    } catch (CloneNotSupportedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:com.mc.printer.model.panel.task.BuildGuideTask.java

@Override
public Object doBackgrounp() {
    javax.swing.JTabbedPane tabs = AutoPrinterApp.getMainView().getMainWorkPanel();
    if (tabs != null) {
        if (tabs.getSelectedIndex() >= 0) {
            Component selectedcom = tabs.getSelectedComponent();
            if (selectedcom instanceof GuideWork) {
                GuideWork selectPanel = (GuideWork) selectedcom;
                GuideBean presentBeansForm = selectPanel.getBeansForm();

                logger.debug("selected tab:" + selectPanel.getName());
                //?
                GuideBean beansForm;//from  w w w .ja  va 2  s  .c om
                try {
                    beansForm = presentBeansForm.clone();
                } catch (CloneNotSupportedException ex) {
                    logger.error(ex.getMessage());
                    beansForm = presentBeansForm;
                }

                String backGroundImg = beansForm.getBackgoundImg();

                //
                Set<String> imgArray = new HashSet();

                if (backGroundImg != null) {
                    File file = new File(backGroundImg);
                    if (file.exists() && file.isFile()) {
                        beansForm.setBackgoundImg(file.getName());
                        imgArray.add(backGroundImg);
                    } else {
                        beansForm.setBackgoundImg("");
                    }
                } else {
                    beansForm.setBackgoundImg("");
                }

                HashMap<String, GuideCompBean> parameterMap = new HashMap<String, GuideCompBean>();
                HashMap<String, GuideCompBean> parentParameterMap = selectPanel.getSavedForms();
                deepCloneMap(parameterMap, parentParameterMap);

                if (parameterMap.size() > 0) {
                    Set set = parameterMap.keySet();
                    //???
                    List<GuideCompBean> beans = new ArrayList();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        GuideCompBean com = parameterMap.get(it.next().toString());
                        beans.add(com);

                        String pressedIcon = com.getPressedIcon();
                        String icon = com.getIcon();
                        if (pressedIcon != null && !pressedIcon.equals("")) {

                            File pressfile = new File(pressedIcon);
                            if (pressfile.exists() && pressfile.isFile()) {
                                imgArray.add(pressedIcon);
                                com.setPressedIcon(pressfile.getName());
                            } else {
                                com.setPressedIcon("");
                            }

                        }
                        if (icon != null && !icon.equals("")) {
                            File iconfile = new File(icon);
                            if (iconfile.exists() && iconfile.isFile()) {
                                imgArray.add(icon);
                                com.setIcon(iconfile.getName());
                            } else {
                                com.setIcon("");
                            }
                        }
                    }
                    beansForm.setElements(beans);

                    BaseFileChoose fileChoose = new BaseFileChoose("?",
                            new String[] { Constants.MODEL_SUFFIX }, AutoPrinterApp.getMainFrame());
                    String selectedPath = fileChoose.showSaveDialog();
                    if (!selectedPath.trim().equals("")) {

                        //get formname
                        selectedPath = selectedPath + File.separator + beansForm.getGuideName();
                        //String time=DateHelper.format(new Date(), "yyyyMMddHHmmss");
                        String finalZip = selectedPath;
                        if (!selectedPath.endsWith("." + Constants.GUIDE_SUFFIX)) {
                            finalZip = selectedPath + "." + Constants.GUIDE_SUFFIX;
                        }

                        String tempDir = selectedPath + File.separator + Constants.GUIDE_TEMP_DIR;

                        String xmlPath = tempDir + File.separator + beansForm.getGuideName() + ".xml";
                        XMLHelper helper = new XMLHelper(xmlPath, beansForm);
                        try {
                            helper.write();
                        } catch (JAXBException ex) {
                            ex.printStackTrace();
                            logger.error(ex.getMessage());
                            return ex;
                        }

                        File paramFile = new File(xmlPath);
                        if (paramFile.isFile() && paramFile.exists()) {
                            try {
                                logger.info("copy file and zip temp for:" + tempDir + ",total of attached file:"
                                        + imgArray.size());
                                File _temp = new File(tempDir);
                                for (String img : imgArray) {
                                    File imgFile = new File(img);
                                    logger.debug("copy image:" + imgFile.getName());
                                    FileUtils.copyFileToDirectory(imgFile, _temp);
                                }

                                ZipHelper.createZip(tempDir, finalZip);
                                logger.info("zip file successfully.");
                                return "??.\r\n" + finalZip;
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                logger.error(ex.getMessage());
                                return ex;
                            } finally {
                                try {
                                    FileUtils.deleteDirectory(new File(selectedPath));
                                } catch (IOException ex) {
                                    ex.printStackTrace();
                                    logger.error(ex.getMessage());
                                    return ex;
                                }
                            }
                        } else {
                            logger.error("generator faild for:" + xmlPath);
                        }
                    }
                } else {
                    return "??.";
                }
            } else {
                return "??????.";
            }
        } else {
            return "?.";
        }
    } else {
        return "?.";
    }
    return null;
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseClicked(MouseEvent event) {
    super.mouseClicked(event);

    if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() == 2) {
        final JFreeChart chartToExplain = getChart();
        if (chartToExplain.getPlot() instanceof PiePlot) {
            return;
        }/* ww  w .  ja v  a2 s .co  m*/
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) chartToExplain.getXYPlot()
                .getRenderer();
        renderer.setLastSeriesAndCategory(-1, -1);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    DBSeerPlotExplainFrame newFrame = new DBSeerPlotExplainFrame(
                            (JFreeChart) chartToExplain.clone());
                    //                  newFrame.setPreferredSize(new Dimension(1280,800));
                    newFrame.pack();
                    newFrame.setLocationRelativeTo(DBSeerGUI.mainFrame);
                    newFrame.setVisible(true);
                } catch (CloneNotSupportedException e) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }
}

From source file:om.edu.squ.squportal.portlet.dps.registration.dropw.service.DropWServiceImpl.java

/**
 * /*from  ww  w  .  j ava  2 s.c o m*/
 * method name  : setDropWCourseUpdate
 * @param dropWDTO
 * @return
 * DropWDBImpl
 * return type  : int
 * 
 * purpose      : update approver's action in drop w
 *
 * Date          :   May 2, 2017 10:59:22 AM
 * @throws NotSuccessFulDBUpdate 
 */
public List<DropWDTO> setDropWCourseUpdate(DropWDTO dropWDTO, Locale locale) throws NotSuccessFulDBUpdate {
    int resultUpdate = 0;
    AcademicDetail academicDetail = new AcademicDetail();
    Student student = new Student();
    ApprovalDTO approvalDTO = null;

    DropWDTO dropWDTOTransaction = null;

    try {
        dropWDTOTransaction = (DropWDTO) dropWDTO.clone();
    } catch (CloneNotSupportedException ex) {
        logger.error("Error in Object cloning. Details {}", ex.getMessage());
    }

    academicDetail.setStudentNo(dropWDTO.getStudentNo());
    academicDetail.setStdStatCode(dropWDTO.getStudentStatCode());
    student.setAcademicDetail(academicDetail);

    resultUpdate = dropWDBDao.setDropWCourseUpdate(dropWDTO);

    if (resultUpdate > 0) {
        approvalDTO = setRoleTransaction(dropWDTOTransaction, locale);
        return getDropWCourses(student, locale);
    } else {
        return null;
    }
}

From source file:com.jaspersoft.jasperserver.search.service.impl.RepositorySearchServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public RepositorySearchResult<ResourceLookup> getLookupsForFullPage(ExecutionContext context,
        RepositorySearchCriteria clientCriteria) {
    RepositorySearchAccumulator<ResourceLookup> result = null;

    RepositorySearchCriteria criteria;/*from   w w  w . j a  v  a 2s. c o m*/
    try {
        criteria = clientCriteria.clone();
    } catch (CloneNotSupportedException e) {
        throw new JSException(e.getMessage());
    }

    if (criteria != null) {

        context = putCriteriaToContext(context, criteria);
        final SearchCriteriaFactory criteriaFactory = obtainFactory(criteria);
        final RepositorySearchConfiguration conf = getConfiguration(
                criteria.getSearchMode() != null ? criteria.getSearchMode() : SearchMode.SEARCH);

        final List<SearchFilter> filters = createAllFiltersList(conf, criteria);
        final SearchSorter sorter = getSorter(conf, criteria.getSortBy());

        int startIndex = criteria.getStartIndex();
        int itemsPerPage = criteria.getMaxCount();
        int currentLimit = itemsPerPage;

        int totalCount = getResultsCount(null, criteria);
        if (startIndex > totalCount) {
            return RepositorySearchAccumulator.EMPTY_RESULT;
        }

        result = new RepositorySearchAccumulator<ResourceLookup>(startIndex, itemsPerPage, totalCount);

        do {
            criteria.setStartIndex(startIndex);
            criteria.setMaxCount(currentLimit);

            List<ResourceLookup> currentLookups = repositoryService.getResources(context, criteriaFactory,
                    filters, sorter, transformerFactory, criteria.getStartIndex(), criteria.getMaxCount());

            debug(criteria, currentLookups, result);
            if (itemsPerPage == 0) {
                result.fill(criteria, currentLookups);
                break;
            } else if ((currentLookups.size() + result.size()) > itemsPerPage) {
                currentLimit = itemsPerPage - result.size();
            } else {
                result.fill(criteria, currentLookups);
                startIndex = result.getNextOffset();
                int nexLimit = currentLimit + (currentLimit - currentLookups.size());
                currentLimit = (conf.getMaxItemsPerQuery() > 0 && conf.getMaxItemsPerQuery() < nexLimit)
                        ? conf.getMaxItemsPerQuery()
                        : nexLimit;
            }
        } while (criteria.isForceFullPage() && startIndex < result.getTotalCount() && !result.isFull());

    }
    return result == null ? RepositorySearchAccumulator.EMPTY_RESULT : result;
}

From source file:FontChooser.java

/**
 * Return a copy of this object.// w  ww. ja  v  a  2 s . co m
 */
public Object clone() {
    try {
        return super.clone();
    } catch (CloneNotSupportedException ex) {
        throw new InternalError(ex.getMessage()); // Impossible.
    }
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.FreeFlowAnalysis.java

private void analyseFreeFlow(Collection<Track> allTracks, Track t0) {
    LOG.debug("Performing free flow analysis of " + t0.getMmsi());

    final float cog0 = t0.getCourseOverGround();
    final Position pc0 = centerOfVessel(t0.getPosition(), t0.getTrueHeading(), t0.getShipDimensionStern(),
            t0.getShipDimensionBow(), t0.getShipDimensionPort(), t0.getShipDimensionStarboard());

    Set<Track> tracksSailingSameDirection = allTracks.stream().filter(t -> t.getMmsi() != t0.getMmsi())
            .filter(t -> !isLastAisTrackingReportTooOld(t, t.getTimeOfLastPositionReport()))
            .filter(t -> absoluteDirectionalDifference(cog0, t.getCourseOverGround()) < dCog)
            .collect(Collectors.toSet());

    if (tracksSailingSameDirection.size() > 0) {
        Ellipse ellipse = createEllipse(pc0, pc0, cog0, t0.getVesselLength(), t0.getVesselBeam(),
                t0.getShipDimensionStern(), t0.getShipDimensionStarboard(), xL, xB, 1);

        LOG.debug("ellipse: " + ellipse);

        List<Track> tracksSailingSameDirectionAndContainedInEllipse = tracksSailingSameDirection.stream()
                .filter(t -> ellipse.contains(centerOfVessel(t.getPosition(), t.getTrueHeading(),
                        t.getShipDimensionStern(), t.getShipDimensionBow(), t.getShipDimensionPort(),
                        t.getShipDimensionStarboard())))
                .collect(Collectors.toList());

        if (tracksSailingSameDirectionAndContainedInEllipse.size() > 0) {
            LOG.debug("There are " + tracksSailingSameDirectionAndContainedInEllipse.size()
                    + " tracks inside ellipse of " + t0.getMmsi() + " " + t0.getShipName());
            LOG.debug(new DateTime(t0.getTimeOfLastPositionReport()) + " " + "MMSI " + t0.getMmsi() + " "
                    + t0.getShipName() + " " + t0.getShipType());
            List<FreeFlowData.TrackInsideEllipse> tracksInsideEllipse = Lists.newArrayList();
            for (Track t1 : tracksSailingSameDirectionAndContainedInEllipse) {
                if (!reportedRecently(t0, t1, t0.getTimeOfLastPositionReport())) {
                    final Position pc1 = centerOfVessel(t1.getPosition(), t1.getTrueHeading(),
                            t1.getShipDimensionStern(), t1.getShipDimensionBow(), t1.getShipDimensionPort(),
                            t1.getShipDimensionStarboard());
                    try {
                        tracksInsideEllipse.add(new FreeFlowData.TrackInsideEllipse(t1.clone(), pc1));
                        markReported(t0, t1, t0.getTimeOfLastPositionReport());
                    } catch (CloneNotSupportedException e) {
                        LOG.error(e.getMessage(), e);
                    }/*from  w w  w .j  a v  a 2s.  c  om*/
                }
            }
            if (tracksInsideEllipse.size() > 0) {
                try {
                    writeToCSVFile(new FreeFlowData(t0.clone(), pc0, tracksInsideEllipse));
                } catch (CloneNotSupportedException e) {
                    LOG.error(e.getMessage(), e);
                }
            } else {
                LOG.debug("Nothing new to report.");
            }
        }
    }
}