Example usage for java.lang OutOfMemoryError toString

List of usage examples for java.lang OutOfMemoryError toString

Introduction

In this page you can find the example usage for java.lang OutOfMemoryError toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:controllers.CNAController.java

public static void inputTable(String table, String notEffects) {
    CNAList notEffectsList;// w w w. j  a v  a 2  s .  c o m
    if (notEffects.length() == 0) {
        notEffectsList = null;
    } else {
        notEffects = notEffects.replaceAll(" ", "");
        notEffectsList = new CNAList(",", notEffects);
    }

    CNATable cnatable = new CNATable("\r\n", ",", table);

    if (cnatable.get(0).size() >= NUMFACTORS) {
        flash.error("Only up to " + NUMFACTORS + " factors allowed.");
        params.flash();
        setup();
    } else if (cnatable.get(0).size() < 3) {
        flash.error(
                "Violation of Minimal Diversity pre-condition: Every MT must have at least two bundles, alternate factors, or a bundle and a alternate factor.");
        params.flash();
        setup();
    }
    try {
        ArrayList<String> graphsView = new ArrayList<String>();
        timer = new Timer();
        CNAlgorithm cnaAlgorithm = new CNAlgorithm(cnatable, notEffectsList);
        for (MinimalTheorySet set : cnaAlgorithm.getSets()) {
            Graph graph = new Graph(set);
            Renderer renderer = new Renderer();
            renderer.setShowEdgeLabels(showBundleNumRenderer);
            renderer.config(graph);
            graphsView.add(renderer.getImageSource());
            graphsView.add(set.toString());
        }

        String elapsedTime = timer.timeElapsed() + " ms";
        boolean specialcase = false;
        render(elapsedTime, graphsView, specialcase, notEffects);
    } catch (OutOfMemoryError e) {
        try {
            ArrayList<String> graphsView = new ArrayList<String>();
            timer = new Timer();
            CNAlgorithm cnaAlgorithm = new CNAlgorithm(cnatable, notEffectsList);

            ArrayList<MinimalTheory> theories = cnaAlgorithm.getAllTheories();
            for (MinimalTheory theory : theories) {
                graphsView.add(theory.toString());
            }
            if (graphsView.size() < 1) {
                flash.error("It was not possible to calculate a graph.");
                params.flash();
                setup();
            }

            String elapsedTime = timer.timeElapsed() + " ms";
            boolean specialcase = true;
            render(elapsedTime, graphsView, specialcase);
        } catch (CNAException e1) {
            flash.error(e1.toString());
            params.flash();
            setup();
        } catch (InterruptedException e2) {
            try {
                SimpleEmail email = new SimpleEmail();
                email.setFrom(MAILFrom);
                email.addTo(MAILTo);
                email.setSubject("Error: InterruptedException");
                String msg = e.getStackTrace().toString();
                email.setMsg("CNA Input Table\n" + msg);
                Mail.send(email);
            } catch (EmailException e1) {
                e1.printStackTrace();
            }
            flash.error("Something went very wrong! Please try again or contact us.");
            params.flash();
            setup();
        } catch (ExecutionException e3) {
            try {
                SimpleEmail email = new SimpleEmail();
                email.setFrom(MAILFrom);
                email.addTo(MAILTo);
                email.setSubject("Error: ExecutionException");
                String msg = e.getStackTrace().toString();
                email.setMsg("CNA Input Table\n" + msg);
            } catch (EmailException e1) {
                e1.printStackTrace();
            }
        }
    } catch (CNAException e) {
        flash.error(e.toString());
        params.flash();
        setup();
    } catch (ArrayIndexOutOfBoundsException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: IndexOutOfBoundsException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
            Mail.send(email);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
        flash.error("Something went wrong. Please try again or contact us.");
        params.flash();
        setup();
    } catch (IndexOutOfBoundsException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: IndexOutOfBoundsException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
            Mail.send(email);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
        flash.error("Something went wrong. Please try again or contact us.");
        params.flash();
        setup();
    } catch (IllegalArgumentException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: IllegalArgumentException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
            Mail.send(email);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
        flash.error("Something went wrong. Please try again or contact us.");
        params.flash();
        setup();
    } catch (InterruptedException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: InterruptedException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
            Mail.send(email);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
        flash.error("Something went very wrong! Please try again or contact us.");
        params.flash();
        setup();
    } catch (ExecutionException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: ExecutionException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
    }
}

From source file:controllers.CNAController.java

public static void calcCNAGraph(String generatedGraphSource, String generatedGraphString, String coincTable) {
    try {//ww  w . j a  v  a 2s  .  co m
        timer = new Timer();
        MTSetToTable parser = new MTSetToTable(theories);
        CNATable table = parser.getCoincTable();
        CNAlgorithm cnaAlgorithm = new CNAlgorithm(table);
        ArrayList<String> graphsView = new ArrayList<String>();

        for (MinimalTheorySet set : cnaAlgorithm.getSets()) {
            Graph graph = new Graph(set);
            Renderer renderer = new Renderer();
            renderer.setShowEdgeLabels(showBundleNumRenderer);
            renderer.config(graph);
            graphsView.add(renderer.getImageSource());
            graphsView.add(set.toString());
        }

        String elapsedTime = timer.timeElapsed() + " ms";
        boolean specialcase = false;
        render(elapsedTime, graphsView, generatedGraphSource, generatedGraphString, coincTable, specialcase);
    } catch (OutOfMemoryError e) {
        try {
            ArrayList<String> graphsView = new ArrayList<String>();
            timer = new Timer();
            MTSetToTable parser = new MTSetToTable(theories);
            CNATable table = parser.getCoincTable();
            CNAlgorithm cnaAlgorithm = new CNAlgorithm(table);

            ArrayList<MinimalTheory> theories = cnaAlgorithm.getAllTheories();
            for (MinimalTheory theory : theories) {
                graphsView.add(theory.toString());
            }
            if (graphsView.size() < 1) {
                flash.error("It was not possible to calculate a graph.");
                params.flash();
                setup();
            }

            String elapsedTime = timer.timeElapsed() + " ms";
            boolean specialcase = true;

            render(elapsedTime, graphsView, generatedGraphSource, generatedGraphString, coincTable,
                    specialcase);
        } catch (CNAException e1) {
            flash.error(e1.toString());
            params.flash();
            setup();
        } catch (InterruptedException e2) {
            try {
                SimpleEmail email = new SimpleEmail();
                email.setFrom(MAILFrom);
                email.addTo(MAILTo);
                email.setSubject("Error: InterruptedException");
                String msg = e.getStackTrace().toString();
                email.setMsg("CNA Input Table\n" + msg);
                Mail.send(email);
            } catch (EmailException e1) {
                e1.printStackTrace();
            }
            flash.error("Something went very wrong! Please try again or contact us.");
            params.flash();
            setup();
        } catch (ExecutionException e3) {
            try {
                SimpleEmail email = new SimpleEmail();
                email.setFrom(MAILFrom);
                email.addTo(MAILTo);
                email.setSubject("Error: ExecutionException");
                String msg = e.getStackTrace().toString();
                email.setMsg("CNA Input Table\n" + msg);
                Mail.send(email);
            } catch (EmailException e1) {
                e1.printStackTrace();
            }
        }
    } catch (CNAException e) {
        flash.error(e.toString());
        params.flash();
        setup();
    } catch (InterruptedException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: InterruptedException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
            Mail.send(email);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
        flash.error("Something went very wrong! Please try again or contact us.");
        params.flash();
        setup();
    } catch (ExecutionException e) {
        try {
            SimpleEmail email = new SimpleEmail();
            email.setFrom(MAILFrom);
            email.addTo(MAILTo);
            email.setSubject("Error: ExecutionException");
            String msg = e.getStackTrace().toString();
            email.setMsg("CNA Input Table\n" + msg);
        } catch (EmailException e1) {
            e1.printStackTrace();
        }
    }
}