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:nl.strohalm.cyclos.utils.Period.java

@Override
public Period clone() {
    Period newPeriod;/*from   w ww.  ja v  a2s. com*/
    try {
        newPeriod = (Period) super.clone();
    } catch (final CloneNotSupportedException e) {
        // this should never happen, since it is Cloneable
        throw new InternalError(e.getMessage());
    }
    newPeriod.begin = begin == null ? null : (Calendar) begin.clone();
    newPeriod.end = end == null ? null : (Calendar) end.clone();

    return newPeriod;
}

From source file:nl.toolforge.karma.core.vc.cvsimpl.CVSModuleStatus.java

/**
 * Returns a Version instance representing the next possible version (major or patch) for the module.
 *
 * @return/*www. j av a 2 s. co  m*/
 */
public Version getNextVersion() {

    if (matchingList.size() == 0) {

        // If the module is in a ReleaseManifest and has a PatchLine already, we can savely
        // return the initial patch level for the module.
        //
        // todo hmm (see sourceforge issue 1019628). Not totally convinced. What if the module doesn't have a patchline ?
        // todo there is something to this logic.

        if (module.hasPatchLine()) {
            return module.getVersion().createPatch(Patch.INITIAL_PATCH);
        }

        return null;
    }

    Version nextVersion = null;

    try {
        nextVersion = (Version) ((Version) matchingList.get(matchingList.size() - 1)).clone();
    } catch (CloneNotSupportedException e) {
        throw new KarmaRuntimeException(e.getMessage(), e);
    }

    nextVersion.increase();

    return nextVersion;
}

From source file:nl.toolforge.karma.core.vc.cvsimpl.CVSModuleStatus.java

public Version getNextMajorVersion() {
    if (matchingList.size() == 0) {
        return null;
    }//  ww  w  . ja v a  2s . c o  m

    Version nextVersion = null;

    try {
        nextVersion = (Version) ((Version) matchingList.get(matchingList.size() - 1)).clone();
    } catch (CloneNotSupportedException e) {
        throw new KarmaRuntimeException(e.getMessage(), e);
    }

    nextVersion.increaseMajor();

    return nextVersion;
}

From source file:org.apache.felix.sigil.common.runtime.cli.Option.java

/**
 * A rather odd clone method - due to incorrect code in 1.0 it is public 
 * and in 1.1 rather than throwing a CloneNotSupportedException it throws 
 * a RuntimeException so as to maintain backwards compat at the API level. 
 *
 * After calling this method, it is very likely you will want to call 
 * clearValues(). //from   ww w . j  a v  a 2  s . c om
 *
 * @throws RuntimeException
 */
public Object clone() {
    try {
        Option option = (Option) super.clone();
        option.values = new ArrayList(values);
        return option;
    } catch (CloneNotSupportedException cnse) {
        throw new RuntimeException("A CloneNotSupportedException was thrown: " + cnse.getMessage());
    }
}

From source file:org.apache.maven.plugins.linkcheck.SiteInvoker.java

/**
 * Invoke Maven for the <code>site</code> phase for a temporary Maven project using
 * <code>tmpReportingOutputDirectory</code> as <code>${project.reporting.outputDirectory}</code>.
 * This is a workaround to be sure that all site files have been correctly generated.
 * <br/>//from   w  w w  .j a  va2  s .c  o  m
 * <b>Note 1</b>: the Maven Home should be defined in the <code>maven.home</code> Java system property
 * or defined in <code>M2_HOME</code> system env variables.
 * <b>Note 2</be>: we can't use <code>siteOutputDirectory</code> param from site plugin because some plugins
 * <code>${project.reporting.outputDirectory}</code> in their conf.
 *
 * @param project the MavenProject to invoke the site on. Not null.
 * @param tmpReportingOutputDirectory not null
 * @throws IOException if any
 */
public void invokeSite(MavenProject project, File tmpReportingOutputDirectory) throws IOException {
    String mavenHome = getMavenHome();
    if (StringUtils.isEmpty(mavenHome)) {
        getLog().error("Could NOT invoke Maven because no Maven Home is defined. "
                + "You need to set the M2_HOME system env variable or a 'maven.home' Java system property.");
        return;
    }

    // invoker site parameters
    List goals = Collections.singletonList("site");
    Properties properties = new Properties();
    properties.put("linkcheck.skip", "true"); // to stop recursion

    File invokerLog = FileUtils.createTempFile("invoker-site-plugin", ".txt",
            new File(project.getBuild().getDirectory()));

    // clone project and set a new reporting output dir
    MavenProject clone;
    try {
        clone = (MavenProject) project.clone();
    } catch (CloneNotSupportedException e) {
        IOException ioe = new IOException("CloneNotSupportedException: " + e.getMessage());
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
    }

    // MLINKCHECK-1
    if (clone.getOriginalModel().getReporting() == null) {
        clone.getOriginalModel().setReporting(new Reporting());
    }

    clone.getOriginalModel().getReporting().setOutputDirectory(tmpReportingOutputDirectory.getAbsolutePath());
    List profileIds = getActiveProfileIds(clone);

    // create the original model as tmp pom file for the invoker
    File tmpProjectFile = FileUtils.createTempFile("pom", ".xml", project.getBasedir());
    Writer writer = null;
    try {
        writer = WriterFactory.newXmlWriter(tmpProjectFile);
        clone.writeOriginalModel(writer);
    } finally {
        IOUtil.close(writer);
    }

    // invoke it
    try {
        invoke(tmpProjectFile, invokerLog, mavenHome, goals, profileIds, properties);
    } finally {
        if (!getLog().isDebugEnabled()) {
            tmpProjectFile.delete();
        }
    }
}

From source file:org.apache.tajo.engine.eval.ExprTestBase.java

/**
 * verify query syntax and get raw targets.
 *
 * @param context QueryContext//from  ww w.  ja  va2 s  .  c o m
 * @param query a query for execution
 * @param condition this parameter means whether it is for success case or is not for failure case.
 * @return
 */
private static List<Target> getRawTargets(QueryContext context, String query, boolean condition)
        throws TajoException, InvalidStatementException {

    List<ParsedResult> parsedResults = SimpleParser.parseScript(query);
    if (parsedResults.size() > 1) {
        throw new RuntimeException("this query includes two or more statements.");
    }
    Expr expr = analyzer.parse(parsedResults.get(0).getHistoryStatement());
    VerificationState state = new VerificationState();
    preLogicalPlanVerifier.verify(context, state, expr);
    if (state.getErrors().size() > 0) {
        if (!condition && state.getErrors().size() > 0) {
            throw new RuntimeException(state.getErrors().get(0));
        }
        assertFalse(state.getErrors().get(0).getMessage(), true);
    }
    LogicalPlan plan = planner.createPlan(context, expr, true);
    optimizer.optimize(context, plan);
    annotatedPlanVerifier.verify(state, plan);

    if (state.getErrors().size() > 0) {
        assertFalse(state.getErrors().get(0).getMessage(), true);
    }

    List<Target> targets = plan.getRootBlock().getRawTargets();
    if (targets == null) {
        throw new RuntimeException(
                "Wrong query statement or query plan: " + parsedResults.get(0).getHistoryStatement());
    }

    // Trying regression test for cloning, (de)serialization for json and protocol buffer
    for (Target t : targets) {
        try {
            assertEquals(t.getEvalTree(), t.getEvalTree().clone());
        } catch (CloneNotSupportedException e) {
            fail(e.getMessage());
        }
    }
    for (Target t : targets) {
        assertEvalTreeProtoSerDer(context, t.getEvalTree());
    }
    return targets;
}

From source file:org.apache.tajo.storage.sequencefile.SequenceFileScanner.java

@Override
public void init() throws IOException {
    // FileFragment information
    if (fs == null) {
        fs = FileScanner.getFileSystem((TajoConf) conf, fragment.getPath());
    }/* www. ja va 2  s.  c o m*/

    reader = new SequenceFile.Reader(fs, fragment.getPath(), conf);

    // Set value of non-deprecated key for backward compatibility.
    TableMeta tableMeta;
    try {
        tableMeta = (TableMeta) meta.clone();

        if (!tableMeta.containsProperty(StorageConstants.TEXT_DELIMITER)) {
            tableMeta.putProperty(StorageConstants.TEXT_DELIMITER,
                    tableMeta.getProperty(StorageConstants.SEQUENCEFILE_DELIMITER));
        }

        if (!tableMeta.containsProperty(StorageConstants.TEXT_NULL)
                && tableMeta.containsProperty(StorageConstants.SEQUENCEFILE_NULL)) {
            tableMeta.putProperty(StorageConstants.TEXT_NULL,
                    tableMeta.getProperty(StorageConstants.SEQUENCEFILE_NULL));
        }
    } catch (CloneNotSupportedException e) {
        throw new TajoInternalError(e);
    }

    String delim = tableMeta.getProperty(StorageConstants.TEXT_DELIMITER,
            StorageConstants.DEFAULT_FIELD_DELIMITER);
    this.delimiter = StringEscapeUtils.unescapeJava(delim).charAt(0);

    String nullCharacters = StringEscapeUtils
            .unescapeJava(tableMeta.getProperty(StorageConstants.TEXT_NULL, NullDatum.DEFAULT_TEXT));
    if (StringUtils.isEmpty(nullCharacters)) {
        nullChars = NullDatum.get().asTextBytes();
    } else {
        nullChars = nullCharacters.getBytes();
    }

    this.start = fragment.getStartKey();
    this.end = start + fragment.getLength();

    if (fragment.getStartKey() > reader.getPosition())
        reader.sync(this.start);

    more = start < end;

    if (targets == null) {
        targets = schema.toArray();
    }

    outTuple = new VTuple(targets.length);
    fieldIsNull = new boolean[schema.getRootColumns().size()];
    fieldStart = new int[schema.getRootColumns().size()];
    fieldLength = new int[schema.getRootColumns().size()];

    prepareProjection(targets);

    try {
        String serdeClass = tableMeta.getProperty(StorageConstants.SEQUENCEFILE_SERDE,
                TextSerializerDeserializer.class.getName());
        serde = (SerializerDeserializer) Class.forName(serdeClass).newInstance();
        serde.init(schema);

        if (serde instanceof BinarySerializerDeserializer) {
            hasBinarySerDe = true;
        } else {
            deserializer = DelimitedTextFile.getLineSerde(tableMeta).createDeserializer(schema, tableMeta,
                    targets);
            deserializer.init();
        }

        Class<? extends Writable> keyClass = (Class<? extends Writable>) Class
                .forName(reader.getKeyClassName());
        EMPTY_KEY = keyClass.newInstance();

    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new IOException(e);
    }
    super.init();
}

From source file:org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram.java

@Override
public PageRankVertexProgram clone() {
    try {/*from  w  w  w .j av a  2s  .  c  o m*/
        final PageRankVertexProgram clone = (PageRankVertexProgram) super.clone();
        if (null != this.initialRankTraversal)
            clone.initialRankTraversal = this.initialRankTraversal.clone();
        return clone;
    } catch (final CloneNotSupportedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:org.apache.tinkerpop.gremlin.process.computer.traversal.step.sideEffect.mapreduce.ComputerToStandardMapReduce.java

@Override
public ComputerToStandardMapReduce clone() {
    try {//w ww  . jav a 2s.c  o m
        final ComputerToStandardMapReduce clone = (ComputerToStandardMapReduce) super.clone();
        clone.traversal = this.traversal.clone();
        return clone;
    } catch (final CloneNotSupportedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram.java

@Override
public TraversalVertexProgram clone() {
    try {/*from  w w w  . java  2 s .  c om*/
        final TraversalVertexProgram clone = (TraversalVertexProgram) super.clone();
        clone.traversal = this.traversal.clone();
        if (!clone.traversal.get().isLocked())
            clone.traversal.get().applyStrategies();
        clone.traversalMatrix = new TraversalMatrix<>(clone.traversal.get());
        return clone;
    } catch (final CloneNotSupportedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}