Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.alu.e3.prov.lifecycle.IDHelper.java

/**
 * Extract datas from the given filename.
 * @param fileName/*from  w  w  w  . j  a va2 s .com*/
 * @return a String[] containing respectively: { apiIDEncoded, apiID, provID }
 */
public static String[] extractAllFromFileName(String fileName) {
    Pattern p = Pattern.compile("([a-f0-9]+)-([a-f0-9]+)\\.[a-z]{3}");
    Matcher m = p.matcher(fileName);
    if (!m.matches())
        return null;

    String apiIDEncoded = m.group(1);
    String apiID = null;
    try {
        apiID = IDHelper.decode(apiIDEncoded);
    } catch (RuntimeException e) {
        e.printStackTrace();
        if (logger.isErrorEnabled()) {
            logger.error("Undecodable apiId:{}", apiIDEncoded);
        }
    }
    String provID = m.group(2);

    String[] datas = new String[] { apiIDEncoded, apiID, provID };

    return datas;
}

From source file:org.isoron.uhabits.utils.RingtoneUtils.java

@Nullable
public static String getRingtoneName(Context context) {
    try {/*from www.j a  v  a 2s .  c  o  m*/
        Uri ringtoneUri = getRingtoneUri(context);
        String ringtoneName = context.getResources().getString(R.string.none);

        if (ringtoneUri != null) {
            Ringtone ringtone = getRingtone(context, ringtoneUri);
            if (ringtone != null) {
                ringtoneName = ringtone.getTitle(context);
                ringtone.stop();
            }
        }

        return ringtoneName;
    } catch (RuntimeException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static void unbindImageView(ImageView imageView) {
    if (imageView == null) {
        return;/*from  w  ww .  j a  v  a  2s  . c om*/
    }

    if (imageView.getBackground() != null) {
        imageView.getBackground().setCallback(null);
    }

    if (imageView.getDrawable() == null)
        return;
    if (!(imageView.getDrawable() instanceof BitmapDrawable))
        return;
    if (((BitmapDrawable) imageView.getDrawable()).getBitmap() == null)
        return;

    BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
    try {
        if (drawable != null && imageView.getTag() != null && !drawable.getBitmap().isRecycled()) {
            if (!imageView.getTag().toString().equalsIgnoreCase("resource") && !usingMemoryCache) {
                drawable.getBitmap().recycle();
            }
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    drawable.setCallback(null);
    imageView.setImageBitmap(null);
    imageView.setImageDrawable(null);
}

From source file:org.nanocontainer.Standalone.java

private static void shuttingDown(final boolean quiet,
        final ScriptedContainerBuilderFactory scriptedContainerBuilderFactory,
        final ObjectReference containerRef) {
    try {/*from   w  ww  .ja  v  a 2 s  . c o  m*/
        scriptedContainerBuilderFactory.getContainerBuilder().killContainer(containerRef);
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        if (!quiet) {
            System.out.println("Exiting Virtual Machine");
        }
    }
}

From source file:com.picocontainer.script.Standalone.java

private static void shuttingDown(final boolean quiet,
        final ScriptedContainerBuilderFactory scriptedContainerBuilderFactory, final PicoContainer container) {
    try {/*ww w .jav  a2 s .c o  m*/
        scriptedContainerBuilderFactory.getContainerBuilder().killContainer(container);
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        if (!quiet) {
            System.out.println("PicoContainer Standalone: Exiting Virtual Machine");
        }
    }
}

From source file:org.isoron.uhabits.helpers.ReminderHelper.java

@Nullable
public static String getRingtoneName(Context context) {
    try {//from   w  ww  .  j av a 2  s  . c  om
        Uri ringtoneUri = getRingtoneUri(context);
        String ringtoneName = context.getResources().getString(R.string.none);

        if (ringtoneUri != null) {
            Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
            if (ringtone != null) {
                ringtoneName = ringtone.getTitle(context);
                ringtone.stop();
            }
        }

        return ringtoneName;
    } catch (RuntimeException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static int setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera,
        int displayRotation) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int degrees = 0;
    switch (displayRotation) {
    case Surface.ROTATION_0:
        degrees = 0;// ww w  .j a v a2 s  .  co m
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int camRotationDegree = 0;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        camRotationDegree = (info.orientation + degrees) % 360;
        camRotationDegree = (360 - camRotationDegree) % 360; // compensate the mirror
    } else {
        camRotationDegree = (info.orientation - degrees + 360) % 360;
    }

    if (camera != null) {
        try {
            camera.setDisplayOrientation(camRotationDegree);
        } catch (RuntimeException e) {
            // java.lang.RuntimeException: set display orientation failed
            e.printStackTrace();
        }
    }
    return camRotationDegree;
}

From source file:org.kalypso.kalypsomodel1d2d.conv.results.differences.VeloDiff2D.java

private static void generateDifferences(final List<ResultType> parameters, final File outputDir1,
        final File outputDir2, final File templateFile, final File outputFile,
        final org.kalypso.kalypsomodel1d2d.conv.results.differences.ResultCalculatorType.TYPE resultDifferenceType)
        throws Exception {
    final InputStream is = new FileInputStream(templateFile);
    try {//from w  ww.  j  ava2 s.  com
        /* generate differences */
        final ResultType[] types = parameters.toArray(new ResultType[parameters.size()]);

        final GM_TriangulatedSurface[] minuendSurfaces = new GM_TriangulatedSurface[types.length];
        final GM_TriangulatedSurface[] subtrahentSurfaces = new GM_TriangulatedSurface[types.length];

        for (int i = 0; i < types.length; i++) {
            minuendSurfaces[i] = getSurfaces(outputDir1, types[i]);
            subtrahentSurfaces[i] = getSurfaces(outputDir2, types[i]);
        }

        final RMA10S2GmlConv converter = new RMA10S2GmlConv(null);

        final IRMA10SModelElementHandler handler = new DifferenceResultModel1d2dHandler(outputFile,
                minuendSurfaces, subtrahentSurfaces, types, resultDifferenceType);
        converter.setRMA10SModelElementHandler(handler);

        converter.parse(is);
        handler.end();
        is.close();
    } catch (final RuntimeException e) {
        e.printStackTrace();
    } finally {
        is.close();
    }
}

From source file:org.etudes.jforum.ConfigLoader.java

public static void stopCacheEngine() {
    if (logger.isInfoEnabled())
        logger.info("stopping cache engine: " + cache);
    try {//  w  w  w  .jav a 2s. c om
        if (cache != null) {
            cache.stop();
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
}

From source file:net.itransformers.topologyviewer.gui.EdgeFilterFactory.java

public static EdgePredicateFilter<String, String> createEdgeFilter(final FilterType filter,
        final Map<String, DataMatcher> matcherMap, final Map<String, GraphMLMetadata<String>> edgeMetadata) {
    return new EdgePredicateFilter<String, String>(new Predicate<String>() {
        public boolean evaluate(String edge) {
            try {
                if (filter == null)
                    return true;

                List<IncludeType> includes = filter.getInclude();
                String filterType = filter.getType();

                if (filterType == null) {
                    filterType = "or";
                }/* w  ww .  j  a  v a  2s.co  m*/
                boolean hasEdgeInlcude = false;

                for (IncludeType include : includes) {

                    if (ForType.EDGE.equals(include.getFor())) {
                        String matcher = include.getMatcher();
                        if (matcher == null) {
                            matcher = "default";
                        }
                        final String dataKey = include.getDataKey();
                        if (dataKey == null) { // lets include all edges
                            hasEdgeInlcude = true;

                            continue;
                        }

                        final GraphMLMetadata<String> stringGraphMLMetadata = edgeMetadata.get(dataKey);
                        if (stringGraphMLMetadata == null) {
                            logger.error("Can not find metadata for key: " + dataKey);
                        }
                        String value = null;
                        if (stringGraphMLMetadata != null) {
                            final Transformer<String, String> transformer = stringGraphMLMetadata.transformer;
                            value = transformer.transform(edge);

                        }
                        if (value != null) {
                            String[] dataValues = value.split(",");
                            String includeDataValue = include.getDataValue();

                            //Circle around the actual values and perform the datamatch
                            DataMatcher matcherInstance = matcherMap.get(matcher);

                            boolean hasToInclude = false;

                            if ("and".equals(filterType)) {
                                for (String dataValue : dataValues) {
                                    // boolean matchResult = ;
                                    hasEdgeInlcude = false;
                                    if (matcherInstance.compareData(dataValue, includeDataValue)) {
                                        logger.debug("Edge selected: " + edge + " by filter " + filter.getName()
                                                + " with include " + include.getDataKey() + " with value "
                                                + dataValue);
                                        hasEdgeInlcude = true;
                                    }
                                }

                                if (!hasEdgeInlcude) {
                                    return false;
                                }
                                //If we have an "or" filter

                            } else {
                                for (String dataValue : dataValues) {
                                    if (matcherInstance.compareData(dataValue, includeDataValue)) {
                                        logger.debug("Edge " + edge + " has been selected from filter "
                                                + filter.getName() + " by property " + include.getDataKey()
                                                + " with value " + dataValue);
                                        return true;

                                    }

                                }
                            }
                        }

                    }

                }
                //Finally if the has to include flag is set include
                if (!hasEdgeInlcude) {
                    System.out.println("Edge " + edge + " has not been selected");
                    return false;

                } else {
                    System.out.println("Edge " + edge + " has been selected");

                    return true;
                }
            } catch (RuntimeException rte) {
                rte.printStackTrace();
                return false;
            }
        }
    });
}