Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.espertech.esper.epl.annotation.AnnotationUtil.java

/**
 * Compile annotation objects from descriptors.
 * @param annotationSpec spec for annotations
 * @param engineImportService engine imports
 * @param eplStatement statement expression
 * @return annotations/*from   ww w  .  ja  v  a  2s. c om*/
 */
public static Annotation[] compileAnnotations(List<AnnotationDesc> annotationSpec,
        EngineImportService engineImportService, String eplStatement) {
    Annotation[] annotations;
    try {
        annotations = AnnotationUtil.compileAnnotations(annotationSpec, engineImportService);
    } catch (AnnotationException e) {
        throw new EPStatementException("Failed to process statement annotations: " + e.getMessage(), e,
                eplStatement);
    } catch (RuntimeException ex) {
        String message = "Unexpected exception compiling annotations in statement, please consult the log file and report the exception: "
                + ex.getMessage();
        log.error(message, ex);
        throw new EPStatementException(message, ex, eplStatement);
    }
    return annotations;
}

From source file:es.tena.foundation.util.POIUtil.java

/**
 * Corrige algunos problemas con los caracteres invlidos al generar
 * ficheros grandes con el SpreadSheetWriter de POI
 *
 * @param valor/* w w w . j a  va 2  s . co  m*/
 * @return la ristra corregida escapando carateres no validos para un xml
 * asi como eliminando aquellos que no estn en el juego de caracteres
 */
public static String fixPOICellValue(String valor, String encoding) {
    try {
        //Poi para los ficheros xml se hace un lio con los &
        // y los considera entidades, para escaparlos deberia bastar con && pero no es asi

        byte[] bs = valor.getBytes(encoding);

        StringBuilder buff = new StringBuilder();
        if (contieneCaracteresNoPermitidos(bs)) {
            for (int i = 0; i < bs.length; i++) {
                byte c = bs[i];
                //                    Logger.getLogger(Utils.class.getName()).log(Level.INFO, "\t\t byte: [{0}]-{1}-{2}-\n", new Object[]{i, (char)c , c});
                // substituyo caracteres extraos
                if (c == 24 || c == 127) {
                    c = 32;// los espacios extraos por el nbsp
                }
                // si no es un caracter no permitido lo aadimos
                if (!ArrayUtils.contains(bytesNotAllowed, c)) {
                    buff.append((char) c);
                } else {
                    Logger.getLogger(POIUtil.class.getName()).log(Level.INFO,
                            "\t\t ESCAPADO de ''{3}'' byte : [{0}]-{1}-''{2}''\n",
                            new Object[] { i, c, (char) c, valor });
                }
            }
            valor = buff.toString();
        } else {
            try {
                StringValidator.checkInString(valor, StringUtil.notNumbers + StringUtil.numbers + " " + "@"
                        + "\"" + "" + "\r" + "\n" + "\t");
            } catch (RuntimeException e) {
                Logger.getLogger(POIUtil.class.getName()).log(Level.FINE, "\t\t SOSPECHOSO [{0}]:{1}\n",
                        new Object[] { valor, e.getMessage() });
            }
        }
        // Escapamos los caracteres conflictivos para que sean validos para el xml
        valor = StringEscapeUtils.escapeXml(valor);
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(POIUtil.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NullPointerException e) {
    }
    return valor;
}

From source file:com.aliyun.odps.io.TupleReaderWriter.java

@SuppressWarnings("unchecked")
private static Writable readDatum(DataInput in, byte type) throws IOException {
    switch (type) {
    case TUPLE:/*from   w  w  w. jav  a 2 s . c o m*/
        int sz = in.readInt();
        // if sz == 0, we construct an "empty" tuple -
        // presumably the writer wrote an empty tuple!
        if (sz < 0) {
            throw new IOException("Invalid size " + sz + " for a tuple");
        }
        Tuple tp = new Tuple(sz);
        for (int i = 0; i < sz; i++) {
            byte b = in.readByte();
            tp.set(i, readDatum(in, b));
        }

        return tp;

    case NULL:
        return null;

    case INTWRITABLE:
        IntWritable iw = new IntWritable();
        iw.readFields(in);
        return iw;

    case LONGWRITABLE:
        LongWritable lw = new LongWritable();
        lw.readFields(in);
        return lw;

    case DATETIMEWRITABLE:
        DatetimeWritable dtw = new DatetimeWritable();
        dtw.readFields(in);
        return dtw;

    case DOUBLEWRITABLE:
        DoubleWritable dw = new DoubleWritable();
        dw.readFields(in);
        return dw;

    case BOOLEANWRITABLE:
        BooleanWritable bw = new BooleanWritable();
        bw.readFields(in);
        return bw;

    case BYTESWRITABLE:
        BytesWritable bsw = new BytesWritable();
        bsw.readFields(in);
        return bsw;

    case TEXT:
        Text t = new Text();
        t.readFields(in);
        return t;

    case NULLWRITABLE:
        NullWritable nw = NullWritable.get();
        nw.readFields(in);
        return nw;

    case UNKNOWN:
        String clsName = in.readUTF();
        try {
            Class<? extends Writable> cls = (Class<? extends Writable>) Class.forName(clsName);
            Writable w = (Writable) ReflectionUtils.newInstance(cls, null);
            w.readFields(in);
            return w;
        } catch (RuntimeException re) {
            LOG.info(re.getMessage());
            throw new IOException(re);
        } catch (ClassNotFoundException cnfe) {
            throw new IOException(cnfe);
        }

    default:
        throw new RuntimeException("Unexpected data type " + type + " found in stream.");
    }
}

From source file:br.upf.contatos.tcp.Client.java

public static boolean comando(String line, ClientConnector tcpService) {

    if (line.equals("help")) {
        System.out.println("op=[ listar, incluir, editar, deletar, parar, cidade ], label = valor");
        System.out.println("Para sair digite: parar");

        return true;

    } else {//w w w  . j  a v a 2  s .  co m

        tcpService.connect();
        String[] chamadas = line.split(",");
        String[] op = chamadas[0].split("=");

        switch (op[1]) {
        case "listar":

            for (ContatoBean cb : tcpService.getAll()) {
                //System.out.println(new JSONObject(cb));
                System.out.println("ID:" + cb.getId());
                System.out.println("Nome:" + cb.getNome());
                System.out.println("Email:" + cb.getEmail());
                System.out.println("Endereco:" + cb.getEndereco());
                System.out.println("Comp:" + cb.getComplemento());
                System.out.println("CEP:" + cb.getCep());
                System.out.println("Cidade:" + cb.getCidade());
                System.out.println("Estado:" + cb.getEstado());
                System.out.println("Email Alt.:" + cb.getEmailAlternativo());
                System.out.println("------------");
            }

            break;

        case "id":
            String idList;
            Scanner scan2 = new Scanner(System.in);
            System.out.println("Informe o id do contato  listar:");
            idList = scan2.nextLine();
            int numIdList = Integer.parseInt(idList);
            ContatoBean conbean = new ContatoBean();
            conbean.setId(numIdList);

            try {
                conbean = tcpService.getById(numIdList);
                System.out.println("O contato buscado : ");
                System.out.println(new JSONObject(conbean));
            } catch (RuntimeException e) {
                System.out.println(e.getMessage());
            }

            break;

        case "incluir":
            String id;
            String nome;
            String email;
            String end;
            String comp;
            String cep;
            String cid;
            String est;

            Scanner scan = new Scanner(System.in);
            //System.out.printf("Digite o id:");   
            //id = scan.nextLine();                     *** Pegar ID Informado
            System.out.printf("Digite o nome:");
            nome = scan.nextLine();
            System.out.printf("Digite o email:");
            email = scan.nextLine();
            System.out.printf("Digite o endereco:");
            end = scan.nextLine();
            System.out.printf("Digite o complemento:");
            comp = scan.nextLine();
            System.out.printf("Digite o cep:");
            cep = scan.nextLine();
            System.out.printf("Digite a cidade:");
            cid = scan.nextLine();
            System.out.printf("Digite o estado:");
            est = scan.nextLine();

            ContatoBean c = new ContatoBean();
            int numCep = Integer.parseInt(cep);
            int numId = 0; // ***  ID Sequencial automatico
            //int idsec = Integer.parseInt(id); *** Pegar ID Informado
            c.setId(numId); //  ***  ID Sequencial automatico
            //c.setId(idsec);                   *** Pegar ID Informado
            c.setNome(nome);
            c.setEmail(email);
            c.setEndereco(end);
            c.setComplemento(comp);
            c.setCep(numCep);
            c.setCidade(cid);
            c.setEstado(est);
            try {
                c = tcpService.insert(c);
                System.out.println("O contato foi adicionado com Sucesso! Segue abaixo as campos informados: ");
                System.out.println(new JSONObject(c));
            } catch (RuntimeException e) {
                System.out.println(e.getMessage());
            }

            break;

        case "editar":

            while (true) {
                String resp;
                String nummId;
                Scanner sca = new Scanner(System.in);
                System.out.println("Deseja alterar um contato? responda sim ou no");
                resp = sca.nextLine();
                if (resp.equals("sim")) {

                    System.out.println("Informe o id do contato  editar");
                    nummId = sca.nextLine();

                    ContatoBean contB = new ContatoBean();
                    int numIdEdi = Integer.parseInt(nummId);

                    do {
                        String opEditar;

                        System.out.print(
                                "Escolha os atributos  alterar (nome, email, endereco, complemento, cep, cidade, estado, parar): ");
                        opEditar = sca.nextLine();

                        if (opEditar.equals("parar")) {
                            break;
                        } else {
                            String id2 = null;
                            String nome2 = null;
                            String email2 = null;
                            String end2 = null;
                            String comp2 = null;
                            String cep2 = null;
                            String cid2 = null;
                            String est2;
                            ContatoBean contact = new ContatoBean();

                            try {
                                contact = tcpService.getById(numIdEdi);
                            } catch (RuntimeException e) {
                                System.out.println(e.getMessage());
                                break;
                            }

                            switch (opEditar) {

                            case "nome":
                                System.out.printf("Digite o nome:");
                                nome2 = sca.nextLine();
                                contact.setNome(nome2);
                                break;
                            case "email":
                                System.out.printf("Digite o email:");
                                email2 = sca.nextLine();
                                contact.setEmail(email2);
                                break;
                            case "endereco":
                                System.out.printf("Digite o endereco:");
                                end2 = sca.nextLine();
                                contact.setEndereco(end2);
                                break;
                            case "complemento":
                                System.out.printf("Digite o complemento:");
                                comp2 = sca.nextLine();
                                contact.setComplemento(comp2);
                                break;
                            case "cep":
                                System.out.printf("Digite o cep:");
                                cep2 = sca.nextLine();
                                int numCepEdit = Integer.parseInt(cep2);
                                contact.setCep(numCepEdit);
                                break;
                            case "cidade":
                                System.out.printf("Digite o cidade:");
                                cid2 = sca.nextLine();
                                contact.setCidade(cid2);
                                break;
                            case "estado":
                                System.out.printf("Digite o estado:");
                                est2 = sca.nextLine();
                                contact.setEstado(est2);
                                break;

                            }

                            try {
                                contact = tcpService.update(contact);
                                System.out.println(
                                        "O contato foi alterado! Segue abaixo suas informaes atualizadas: ");
                                System.out.println(new JSONObject(contact));
                            } catch (RuntimeException e) {
                                System.out.println(e.getMessage());
                            }
                        }
                    } while (true);

                } else {
                    break;
                }

            }
            break;
        case "cidade":
            String cidade;
            ArrayList cidade2 = new ArrayList();
            Scanner scanner = new Scanner(System.in);
            System.out.println("Informe a cidade  listar");
            cidade = scanner.nextLine();

            try {
                cidade2 = (ArrayList) tcpService.getByCidade(cidade);
                // System.out.println(new JSONObject(cidade2));
                System.out.println("Segue os contatos que moram na cidade de " + cidade + ":");
                for (Object cb : cidade2) {
                    System.out.println(new JSONObject(cb));
                }
            } catch (RuntimeException e) {
                System.out.println(e.getMessage());
            }

            break;

        case "deletar":
            String idDel;
            Scanner scann = new Scanner(System.in);
            System.out.println("Informe o id do contato  deletar");
            idDel = scann.next();
            int numIdDel = Integer.parseInt(idDel);
            ContatoBean cb = new ContatoBean();
            cb.setId(numIdDel);
            try {
                cb = tcpService.delete(numIdDel);
                System.out.println("O contato com o id" + numIdDel + " foi deletado!");
                System.out.println(new JSONObject(cb));
            } catch (RuntimeException e) {
                System.out.println(e.getMessage());
            }

            break;

        case "parar":

            System.out.println("Encerrando Aplicao...");
            return false;
        }

    }

    return true;
}

From source file:com.espertech.esper.util.PopulateUtil.java

public static Object instantiatePopulateObject(Map<String, Object> objectProperties, Class topClass,
        EngineImportService engineImportService) throws ExprValidationException {

    Class applicableClass = topClass;
    if (topClass.isInterface()) {
        applicableClass = findInterfaceImplementation(objectProperties, topClass, engineImportService);
    }//from  ww w.ja  va 2s  .c  o  m

    Object top;
    try {
        top = applicableClass.newInstance();
    } catch (RuntimeException e) {
        throw new ExprValidationException(
                "Exception instantiating class " + applicableClass.getName() + ": " + e.getMessage(), e);
    } catch (InstantiationException e) {
        throw new ExprValidationException(getMessageExceptionInstantiating(applicableClass), e);
    } catch (IllegalAccessException e) {
        throw new ExprValidationException(
                "Illegal access to construct class " + applicableClass.getName() + ": " + e.getMessage(), e);
    }

    populateObject(topClass.getSimpleName(), 0, topClass.getSimpleName(), objectProperties, top,
            engineImportService, null, null);

    return top;
}

From source file:com.espertech.esper.event.xml.XSDSchemaMapper.java

private static Integer getFractionRestriction(XSSimpleTypeDecl simpleType) {
    if ((simpleType.getDefinedFacets() & XSSimpleType.FACET_FRACTIONDIGITS) != 0) {
        XSObjectList facets = simpleType.getFacets();
        Integer digits = null;//from  www . ja v  a 2  s.  c  o  m
        for (int f = 0; f < facets.getLength(); f++) {
            XSObject item = facets.item(f);
            if (item instanceof XSFacet) {
                XSFacet facet = (XSFacet) item;
                if (facet.getFacetKind() == XSSimpleType.FACET_FRACTIONDIGITS) {
                    try {
                        digits = Integer.parseInt(facet.getLexicalFacetValue());
                    } catch (RuntimeException ex) {
                        log.warn("Error parsing fraction facet value '" + facet.getLexicalFacetValue() + "' : "
                                + ex.getMessage(), ex);
                    }
                }
            }
        }
        return digits;
    }
    return null;
}

From source file:com.espertech.esper.pattern.observer.TimerScheduleISO8601Parser.java

public static Calendar parseDate(String dateText) throws ScheduleParameterException {
    try {//ww w.ja va2s .c  om
        return javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(dateText)
                .toGregorianCalendar();
    } catch (RuntimeException e) {
        String message = "Exception parsing date '" + dateText + "', the date is not a supported ISO 8601 date";
        log.debug(message, e);
        throw new ScheduleParameterException(message);
    } catch (DatatypeConfigurationException e) {
        throw new ScheduleParameterException("Exception parsing date '" + dateText + "': " + e.getMessage(), e);
    }
}

From source file:io.cloudslang.worker.execution.services.ExecutionServiceImpl.java

private static void handleStepExecutionException(Execution execution, RuntimeException ex) {
    logger.error("Error occurred during operation execution.  Execution id: " + execution.getExecutionId(), ex);
    execution.getSystemContext().setStepErrorKey(ex.getMessage());
}

From source file:de.suse.swamp.webswamp.SwampUIManager.java

public static ArrayList getValidSkins() {
    ArrayList skins = new ArrayList();
    String resourcesDirectory = TurbinePull.getResourcesDirectory();
    File uiDir = null;/*  w ww .  j  a  v a2 s  .com*/
    try {
        uiDir = new File(resourcesDirectory);
    } catch (RuntimeException e) {
        Logger.ERROR("wskin path (" + resourcesDirectory + ") not found. " + "Error: " + e.getMessage());
    }
    if (uiDir != null) {
        String[] userSkins = uiDir.list();
        if (userSkins != null) {
            for (int i = 0; i < userSkins.length; i++) {
                skins.add(userSkins[i]);
            }
        }
    }
    return skins;
}

From source file:com.espertech.esper.core.context.util.StatementAgentInstanceUtil.java

public static void stopSafe(StopCallback stopMethod, StatementContext statementContext) {
    try {//from  w w w.  java 2 s .co  m
        stopMethod.stop();
    } catch (RuntimeException e) {
        log.warn("Failed to perform statement stop for statement '" + statementContext.getStatementName()
                + "' expression '" + statementContext.getExpression() + "' : " + e.getMessage(), e);
    }
}