Example usage for java.lang UnsupportedOperationException getMessage

List of usage examples for java.lang UnsupportedOperationException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.fop.render.pcl.PCLImageHandlerGraphics2D.java

/** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException {
    PCLRenderingContext pclContext = (PCLRenderingContext) context;
    ImageGraphics2D imageG2D = (ImageGraphics2D) image;
    Dimension imageDim = imageG2D.getSize().getDimensionMpt();
    PCLGenerator gen = pclContext.getPCLGenerator();

    Point2D transPoint = pclContext.transformedPoint(pos.x, pos.y);
    gen.setCursorPos(transPoint.getX(), transPoint.getY());

    boolean painted = false;
    ByteArrayOutputStream baout = new ByteArrayOutputStream();
    PCLGenerator tempGen = new PCLGenerator(baout, gen.getMaximumBitmapResolution());
    tempGen.setDitheringQuality(gen.getDitheringQuality());
    try {/* w ww  . j  av  a2  s  .  c  o  m*/
        GraphicContext ctx = (GraphicContext) pclContext.getGraphicContext().clone();

        AffineTransform prepareHPGL2 = new AffineTransform();
        prepareHPGL2.scale(0.001, 0.001);
        ctx.setTransform(prepareHPGL2);

        PCLGraphics2D graphics = new PCLGraphics2D(tempGen);
        graphics.setGraphicContext(ctx);
        graphics.setClippingDisabled(false /*pclContext.isClippingDisabled()*/);
        Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imageDim.getWidth(), imageDim.getHeight());
        imageG2D.getGraphics2DImagePainter().paint(graphics, area);

        //If we arrive here, the graphic is natively paintable, so write the graphic
        gen.writeCommand(
                "*c" + gen.formatDouble4(pos.width / 100f) + "x" + gen.formatDouble4(pos.height / 100f) + "Y");
        gen.writeCommand("*c0T");
        gen.enterHPGL2Mode(false);
        gen.writeText("\nIN;");
        gen.writeText("SP1;");
        //One Plotter unit is 0.025mm!
        double scale = imageDim.getWidth() / UnitConv.mm2pt(imageDim.getWidth() * 0.025);
        gen.writeText("SC0," + gen.formatDouble4(scale) + ",0,-" + gen.formatDouble4(scale) + ",2;");
        gen.writeText("IR0,100,0,100;");
        gen.writeText("PU;PA0,0;\n");
        baout.writeTo(gen.getOutputStream()); //Buffer is written to output stream
        gen.writeText("\n");

        gen.enterPCLMode(false);
        painted = true;
    } catch (UnsupportedOperationException uoe) {
        log.debug(
                "Cannot paint graphic natively. Falling back to bitmap painting. Reason: " + uoe.getMessage());
    }

    if (!painted) {
        //Fallback solution: Paint to a BufferedImage
        FOUserAgent ua = context.getUserAgent();
        ImageManager imageManager = ua.getFactory().getImageManager();
        ImageRendered imgRend;
        try {
            imgRend = (ImageRendered) imageManager.convertImage(imageG2D,
                    new ImageFlavor[] { ImageFlavor.RENDERED_IMAGE }/*, hints*/);
        } catch (ImageException e) {
            throw new IOException("Image conversion error while converting the image to a bitmap"
                    + " as a fallback measure: " + e.getMessage());
        }

        gen.paintBitmap(imgRend.getRenderedImage(), new Dimension(pos.width, pos.height),
                pclContext.isSourceTransparencyEnabled());
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactory.java

private CswRecordMapperFilterVisitor buildFilter(QueryConstraintType constraint) throws CswException {
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor();
    Filter filter = null;/*from w  w  w.ja v a2  s  .c om*/
    if (constraint != null) {
        if (constraint.isSetCqlText()) {
            try {
                filter = CQL.toFilter(constraint.getCqlText());
            } catch (CQLException e) {
                throw new CswException("Unable to parse CQL Constraint: " + e.getMessage(), e);
            }
        } else if (constraint.isSetFilter()) {
            FilterType constraintFilter = constraint.getFilter();
            filter = parseFilter(constraintFilter);
        }
    } else {
        // not supported by catalog:
        //filter = Filter.INCLUDE;
        filter = builder.attribute(Metacard.ID).is().like().text(FilterDelegate.WILDCARD_CHAR);
    }

    if (filter == null) {
        throw new CswException("Invalid Filter Expression", CswConstants.NO_APPLICABLE_CODE, null);
    }

    try {
        visitor.setVisitedFilter((Filter) filter.accept(visitor, null));
    } catch (UnsupportedOperationException ose) {
        throw new CswException(ose.getMessage(), CswConstants.INVALID_PARAMETER_VALUE, null);
    }

    return visitor;
}

From source file:jenkins.plugins.office365connector.Office365ConnectorWebhookNotifier.java

private Collection<? extends ChangeLogSet.AffectedFile> getAffectedFiles(ChangeLogSet.Entry entry) {
    try {//from  w ww.j a v  a  2s  .  c  o m
        return entry.getAffectedFiles();
    } catch (UnsupportedOperationException e) {
        log(e.getMessage());
        return Collections.emptyList();
    }
}

From source file:org.eclipse.mdht.uml.cda.operations.CDAValidationTest.java

static protected String createUnsupportedOperationFailureMessage(final String testTargetDescription,
        final UnsupportedOperationException uoe) {
    return "The test \"" + testTargetDescription + "\" failed because of \"" + uoe.getMessage()
            + "\".  This is likely due to errors in the OCL.";
}

From source file:gaffer.gafferpop.GafferPopGraphTest.java

@Test
public void shouldThrowUnsupportedExceptionForCompute() {
    // Given/*from  w w  w  .j av a  2s.  c o m*/
    final Graph gafferGraph = getGafferGraph();
    final GafferPopGraph graph = GafferPopGraph.open(TEST_CONFIGURATION, gafferGraph);

    // When / Then
    try {
        graph.compute();
        fail("Exception expected");
    } catch (final UnsupportedOperationException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:gaffer.gafferpop.GafferPopGraphTest.java

@Test
public void shouldThrowUnsupportedExceptionForComputeWithClass() {
    // Given/*from   w w  w . j a va2  s  .  c  o  m*/
    final Graph gafferGraph = getGafferGraph();
    final GafferPopGraph graph = GafferPopGraph.open(TEST_CONFIGURATION, gafferGraph);

    // When / Then
    try {
        graph.compute(GraphComputer.class);
        fail("Exception expected");
    } catch (final UnsupportedOperationException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:gaffer.gafferpop.GafferPopGraphTest.java

@Test
public void shouldThrowUnsupportedExceptionForTx() {
    // Given//ww w  .  ja  v  a2 s .  c o  m
    final Graph gafferGraph = getGafferGraph();
    final GafferPopGraph graph = GafferPopGraph.open(TEST_CONFIGURATION, gafferGraph);

    // When / Then
    try {
        graph.tx();
        fail("Exception expected");
    } catch (final UnsupportedOperationException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:gaffer.gafferpop.GafferPopGraphTest.java

@Test
public void shouldThrowExceptionIfGetAdjacentVerticesWithNoSeeds() {
    // Given/*from  ww w .  java2 s .c  om*/
    final Graph gafferGraph = getGafferGraph();
    final GafferPopGraph graph = GafferPopGraph.open(TEST_CONFIGURATION, gafferGraph);

    // When / Then
    try {
        graph.adjVertices(Collections.emptyList(), Direction.BOTH);
        fail("Exception expected");
    } catch (final UnsupportedOperationException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:net.sf.ehcache.jcache.JCacheEntryTest.java

/**
 * Check the expiry time is correct.//  ww w. j a v a  2s .  c om
 */
public void testCannotSet() throws Exception {

    Cache cache = getTestCache();
    CacheEntry entry = new JCacheEntry(new Element("key1", "value1"));
    cache.put(entry.getKey(), entry.getValue());
    CacheEntry retrievedEntry = cache.getCacheEntry(entry.getKey());

    try {
        retrievedEntry.setValue("test value");
    } catch (UnsupportedOperationException e) {
        assertEquals("Ehcache does not support modification of Elements. They are immutable.", e.getMessage());
    }

}

From source file:org.apache.ddlutils.task.CreateDatabaseCommand.java

/**
 * {@inheritDoc}//from  w w w  .  j  ava2  s . com
 */
public void execute(DatabaseTaskBase task, Database model) throws BuildException {
    BasicDataSource dataSource = getDataSource();

    if (dataSource == null) {
        throw new BuildException("No database specified.");
    }

    Platform platform = getPlatform();

    try {
        platform.createDatabase(dataSource.getDriverClassName(), dataSource.getUrl(), dataSource.getUsername(),
                dataSource.getPassword(), getFilteredParameters(platform.getName()));

        _log.info("Created database");
    } catch (UnsupportedOperationException ex) {
        _log.error("Database platform " + platform.getName() + " does not support database creation "
                + "via JDBC or there was an error while creating it.", ex);
    } catch (Exception ex) {
        handleException(ex, ex.getMessage());
    }
}