Example usage for java.lang Character isLetter

List of usage examples for java.lang Character isLetter

Introduction

In this page you can find the example usage for java.lang Character isLetter.

Prototype

public static boolean isLetter(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a letter.

Usage

From source file:com.rickendirk.rsgwijzigingen.ZoekService.java

private ArrayList<String> checkerKlas() {
    ArrayList<String> tempList = new ArrayList<>();
    //String halen uit SP
    String klasTextS = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getString("pref_klas", "");
    //Checken of klas niet leeg is
    if (klasTextS.equals("")) {
        tempList.add("geenKlas");
        return tempList;
    }/*from  w  w w  .j  a  va 2  s  .c o m*/
    //Eerste teken klas mag geen letter zijn
    if (Character.isLetter(klasTextS.charAt(0))) {
        tempList.add("EersteTekenLetter");
        return tempList;
    }
    //String opsplitsen in 2 delen, om naar hoofdletters te converteren
    char charcijfer = klasTextS.charAt(0);
    String klascijfer = String.valueOf(charcijfer);
    char charafdeling = klasTextS.charAt(1);
    String klasafdelingBig = String.valueOf(charafdeling).toUpperCase();
    //Onderstaand voor hoofdlettercorrectie
    String klasCorrect; //KlasCorrect is klas na hoofdlettercorrectie
    switch (klasTextS.length()) {
    case 2:
        klasCorrect = klascijfer + klasafdelingBig;
        break;
    case 3:
        char klasabc = klasTextS.charAt(2);
        String klasabcSmall = String.valueOf(klasabc).toLowerCase();
        klasCorrect = klascijfer + klasafdelingBig + klasabcSmall;
        break;
    case 4:
        char klasafdeling2 = klasTextS.charAt(2);
        String klasafdeling2Big = String.valueOf(klasafdeling2).toUpperCase();
        klasabc = klasTextS.charAt(3);
        klasabcSmall = String.valueOf(klasabc).toLowerCase();

        klasCorrect = klascijfer + klasafdelingBig + klasafdeling2Big + klasabcSmall;
        break;
    default:
        tempList.add("klasMeerDan4Tekens");
        return tempList;
    }

    //Try en catch in het geval dat de internetverbinding mist
    try {
        String url = "http://www.rsgtrompmeesters.nl/roosters/roosterwijzigingen/Lijsterbesstraat/subst_001.htm";
        Document doc = Jsoup.connect(url).get();
        Elements tables = doc.select("table");
        if (tables.size() < 2) {
            //Geen geschikte tabel aanwezig
            tempList.add("geenTabel");
            return tempList;
        }
        Element table = tables.get(1);
        Elements rows = table.select("tr");
        //Loop genereren, voor elke row kijken of het de goede tekst bevat
        //Beginnen bij 4e, bovenstaande is niet belangrijk
        for (int i = 2; i < rows.size(); i++) {
            Element row = rows.get(i);
            Elements cols = row.select("td");

            if (cols.get(0).text().contains(klasCorrect)) {
                String vakOud = Jsoup.parse(cols.get(2).toString()).text();
                String docentOud = Jsoup.parse(cols.get(3).toString()).text();
                String vakNieuw = Jsoup.parse(cols.get(4).toString()).text();
                String docentNieuw = Jsoup.parse(cols.get(5).toString()).text();
                //If in geval van uitval, else ingeval van wijziging
                if (Jsoup.parse(cols.get(6).toString()).text().contains("--")) {
                    //2 opties: wordt verplaatst of valt uit
                    if (Jsoup.parse(cols.get(8).toString()).text().contains("Uitval")) {
                        String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur "
                                + Jsoup.parse(cols.get(2).toString()).text() + " valt uit";
                        tempList.add(wijziging);
                    } else {
                        //Uur wordt verplaatst
                        String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur "
                                + "wordt verplaatst naar " + Jsoup.parse(cols.get(8).toString()).text();
                        tempList.add(wijziging);
                    }
                } else if (vakOud.equals(vakNieuw) && docentOud.equals(docentNieuw)) {
                    String wijziging = Jsoup.parse(cols.get(1).toString()).text() + "e uur " + vakOud
                            + " wordt verplaatst naar " + Jsoup.parse(cols.get(6).toString()).text();
                    tempList.add(wijziging);
                } else {
                    String wijzigingKaal;
                    if (vakOud.equals(vakNieuw) && !docentOud.equals(docentNieuw)) {
                        // Opvang door andere docent: dit staat alleen bij klas omdat
                        // dit amper gebeurt bij clusters
                        wijzigingKaal = Jsoup.parse(cols.get(1).toString()).text() + "e uur " + docentOud
                                + " wordt opgevangen door " + docentNieuw;
                    } else { //Geen opvang door andere docent, lokaalwijziging oid
                        wijzigingKaal =
                                // Voegt alle kolommen samen tot 1 string
                                // .text() zorgt voor leesbare text
                                // Spaties voor leesbaarheid
                                Jsoup.parse(cols.get(1).toString()).text() + "e uur "
                                        + Jsoup.parse(cols.get(2).toString()).text() + " "
                                        + Jsoup.parse(cols.get(3).toString()).text() + " wordt "
                                        + Jsoup.parse(cols.get(4).toString()).text() + " "
                                        + Jsoup.parse(cols.get(5).toString()).text() + " in "
                                        + Jsoup.parse(cols.get(6).toString()).text();
                    }
                    //ipv en naar bevatten een "/" ivm uren (ma 12-04 / 4)
                    String ipv = "";
                    if (Jsoup.parse(cols.get(7).toString()).text().contains("/")) {
                        ipv = "ipv " + Jsoup.parse(cols.get(7).toString()).text();
                    }
                    String naar = "";
                    if (Jsoup.parse(cols.get(8).toString()).text().contains("/")) {
                        naar = "naar " + Jsoup.parse(cols.get(8).toString()).text() + " ";
                    }
                    String vervangingsTekst = "";
                    //&nbsp; staat in lege cell, encoding enz, zie volgende link:
                    // http://stackoverflow.com/questions/26837034/how-to-tell-if-a-html-table-has-an-empty-cell-nbsp-using-jsoup
                    //Soms veregeten ze de opmerkingen, dan krijg je size = 9 en error
                    if (cols.size() > 9) {
                        if (!Jsoup.parse(cols.get(9).toString()).text().equals("\u00a0")) {
                            vervangingsTekst = "(" + Jsoup.parse(cols.get(9).toString()).text() + ")";
                        }
                    }
                    String wijziging = wijzigingKaal + " " + ipv + " " + naar + " " + vervangingsTekst;
                    tempList.add(wijziging);

                }

            }
            //Geen wijzigingen pas bij laatste rij
            if (i == rows.size() - 1) {
                //Checken of tempList leeg is, zo ja 1 ding toevoegen
                if (tempList.isEmpty()) {
                    tempList.add("Er zijn geen wijzigingen");
                }
                //Dag waarvoor wijzigingen zijn ophalen
                Element dag = doc.select("body > div > div:nth-child(2) > p > b > span").first();
                //Compatibiliteit met andere opmaak, om NPE te voorkomen
                if (dag == null) {
                    dag = doc.select("body > center:nth-child(2) > div").first();
                }
                String dagStr = dag.text().toLowerCase();
                // Woorden staan verkeerd om: omwisselen
                int indexVanSpatie = dagStr.indexOf(" ");
                String datum = dagStr.substring(0, indexVanSpatie);
                String rest = dagStr.substring(indexVanSpatie + 1);
                String dagGoed = rest + " " + datum;
                tempList.add(dagGoed);

                //Stand ophalen: staat in 1e tabel van HTML
                Element tableDate = doc.select("table").get(0);
                String dateFullText = tableDate.getElementsContainingOwnText("Stand:").text();
                //Deel achter "Stand:" pakken
                String FullTextSplit[] = dateFullText.split("Stand:");
                tempList.add(FullTextSplit[1]);
                return tempList;
            }
        }
    } catch (java.io.IOException e) {
        //Error toevoegen aan tempList, dat wordt weergegeven in messagebox
        tempList.clear();
        tempList.add("verbindFout");
        return tempList;
    }
    //Zover hoort de method NOOIT te komen
    tempList.add("andereFout");
    return tempList;
}

From source file:reportsas.com.formulapp.Formulario.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (data != null) {
            if (data.hasExtra("data")) {

                Bitmap photobmp = (Bitmap) data.getParcelableExtra("data");

                // iv.setImageBitmap(photobmp);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                photobmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                byte[] imageBytes = baos.toByteArray();
                String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);

                if (parametroCam == null) {
                    parametroCam = new ParametrosRespuesta(2);
                }// www .  j  a  v a  2s.  c  om

                parametroCam.setValor(encodedImage);

                // prueba.setText(encodedImage);
                //    new MyAsyncTask(Formulario.this)
                //          .execute("POST",encodedImage, HTTP_EVENT);
            }

        }
    }

    if (requestCode == MY_REQUEST_CODE && resultCode == Pdf417ScanActivity.RESULT_OK) {
        // First, obtain scan results array. If scan was successful, array will contain at least one element.
        // Multiple element may be in array if multiple scan results from single image were allowed in settings.

        Parcelable[] resultArray = data
                .getParcelableArrayExtra(Pdf417ScanActivity.EXTRAS_RECOGNITION_RESULT_LIST);

        StringBuilder sb = new StringBuilder();

        for (Parcelable p : resultArray) {
            if (p instanceof Pdf417ScanResult) { // check if scan result is result of Pdf417 recognizer
                Pdf417ScanResult result = (Pdf417ScanResult) p;
                // getStringData getter will return the string version of barcode contents
                String barcodeData = result.getStringData();

                // isUncertain getter will tell you if scanned barcode contains some uncertainties
                boolean uncertainData = result.isUncertain();
                // getRawData getter will return the raw data information object of barcode contents
                BarcodeDetailedData rawData = result.getRawData();
                // BarcodeDetailedData contains information about barcode's binary layout, if you
                // are only interested in raw bytes, you can obtain them with getAllData getter
                byte[] rawDataBuffer = rawData.getAllData();
                DataR = rawData.toString();

                String[] arrayElements = DataR.split("Element #");
                String Nombre = "", Apellido = "", cedula = "", fecha = "", dia, mes, ano;
                if (arrayElements.length >= 7) {
                    String[] auxliarArray = arrayElements[7].split("decoded\\):");

                    String strDatos = auxliarArray[1];
                    char[] ca = strDatos.toCharArray();
                    for (int i = 0; i < strDatos.length(); i++) {
                        if (Character.isLetter(ca[i])) //Si es letra
                            Apellido += ca[i]; //Salto de lnea e imprimimos el carcter
                        else //Si no es letra
                            cedula += ca[i]; //Imprimimos el carcter
                    }
                    Apellido = Apellido.trim();
                    cedula = (cedula.replaceAll("\n", "")).trim();
                    if (cedula.length() == 0) {
                        auxliarArray = arrayElements[5].split("decoded\\):");
                        strDatos = auxliarArray[1];
                        ca = strDatos.toCharArray();
                        Apellido = "";
                        for (int i = 0; i < strDatos.length(); i++) {
                            if (Character.isLetter(ca[i])) //Si es letra
                                Apellido += ca[i]; //Salto de lnea e imprimimos el carcter
                            else //Si no es letra
                                cedula += ca[i]; //Imprimimos el carcter
                        }
                        Apellido = Apellido.trim();
                        cedula = (cedula.replaceAll("\n", "")).trim();
                        cedula = cedula.substring(cedula.length() - 10, cedula.length());
                        cedula = eliminarceros(cedula);
                        auxliarArray = arrayElements[9].split("decoded\\):");
                        Nombre = (auxliarArray[1].replaceAll("\n", "")).trim();

                    } else {

                        cedula = eliminarceros(cedula);
                        auxliarArray = arrayElements[11].split("decoded\\):");
                        Nombre = (auxliarArray[1].replaceAll("\n", "")).trim();
                    }

                    auxliarArray = result.getStringData().toString().split(Nombre);
                    strDatos = auxliarArray[1];
                    ca = strDatos.toCharArray();
                    Boolean result_ciclo = true;
                    int i = 0;
                    while (result_ciclo) {
                        if (Character.isDigit(ca[i])) {
                            fecha += ca[i];
                        }
                        if (fecha.length() >= 9) {
                            result_ciclo = false;
                        }
                        i++;
                    }
                    fecha = fecha.substring(1, fecha.length());
                } else {
                    int puntoI = 0;
                    if (barcodeData.indexOf("1F") > 0) {
                        puntoI = barcodeData.indexOf("1F");
                    } else if (barcodeData.indexOf("0M") > 0) {
                        puntoI = barcodeData.indexOf("0M");
                    } else if (barcodeData.indexOf("0F") > 0) {
                        puntoI = barcodeData.indexOf("0F");
                    } else if (barcodeData.indexOf("1M") > 0) {
                        puntoI = barcodeData.indexOf("1M");
                    } else {

                    }
                    if (puntoI > 0) {
                        String seb = barcodeData.substring(1, puntoI);
                        fecha = barcodeData.substring(puntoI + 2, puntoI + 10);

                        int posL = 0, posE;
                        char[] ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isLetter(ca[w])) {
                                posL = w;
                                break;
                            }
                        }
                        seb = seb.substring(1, posL + 1);
                        ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isLetter(ca[w])) {
                                Nombre = ca[w] + Nombre;
                                posL = w;
                            } else {
                                break;
                            }
                        }
                        seb = seb.substring(1, posL);
                        ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isDigit(ca[w])) {
                                posL = w;
                                break;
                            }
                        }

                        for (int w = posL + 1; w <= seb.length(); w++) {
                            if (Character.isLetter(ca[w])) {
                                Apellido += ca[w];
                            } else {
                                break;
                            }
                        }

                        cedula = seb.substring(posL - 9, posL + 1);
                        cedula = eliminarceros(cedula);
                    } else {
                        fecha = "";
                    }
                }
                if (fecha.length() == 0) {
                    parametroScan = null;

                    Toast toast1 = Toast.makeText(this, "Los datos de codigo no pudieron ser interpretados!",
                            Toast.LENGTH_SHORT);

                    toast1.show();

                } else {
                    dia = fecha.substring(6, 8);
                    mes = fecha.substring(4, 6);
                    ano = fecha.substring(0, 4);
                    fecha = dia + "/" + mes + "/" + ano;

                    Infocadena = "Nombre: \n" + Nombre + ".\nApellido: \n" + Apellido + ". \nCedula: \n"
                            + cedula + ". \nFecha de Nacimiento: \n" + fecha + ".";
                    if (parametroScan == null) {
                        parametroScan = new ParametrosRespuesta(3);

                    }
                    parametroScan.setValor(Infocadena);

                }

                //  new MyAsyncTask(Formulario.this)
                //        .execute("POST",Infocadena, HTTP_EVENT);

            } else if (p instanceof BarDecoderScanResult) { // check if scan result is result of BarDecoder recognizer
                /* BarDecoderScanResult result = (BarDecoderScanResult) p;
                 // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode
                 BarcodeType type = result.getBarcodeType();
                 // as with PDF417, getStringData will return the string contents of barcode
                 String barcodeData = result.getStringData();
                 if(checkIfDataIsUrlAndCreateIntent(barcodeData)) {
                return;
                 } else {
                sb.append(type.name());
                sb.append(" string data:\n");
                sb.append(barcodeData);
                sb.append("\n\n\n");=
                 }*/
            } else if (p instanceof ZXingScanResult) { // check if scan result is result of ZXing recognizer
                /* ZXingScanResult result= (ZXingScanResult) p;
                 // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode
                 BarcodeType type = result.getBarcodeType();
                 // as with PDF417, getStringData will return the string contents of barcode
                 String barcodeData = result.getStringData();
                 if(checkIfDataIsUrlAndCreateIntent(barcodeData)) {
                return;
                 } else {
                sb.append(type.name());
                sb.append(" string data:\n");
                sb.append(barcodeData);
                sb.append("\n\n\n");
                 }*/
            } else if (p instanceof USDLScanResult) { // check if scan result is result of US Driver's Licence recognizer
                USDLScanResult result = (USDLScanResult) p;

                // USDLScanResult can contain lots of information extracted from driver's licence
                // you can obtain information using the getField method with keys defined in
                // USDLScanResult class

                String name = result.getField(USDLScanResult.kCustomerFullName);

                sb.append(result.getTitle());
                sb.append("\n\n");
                sb.append(result.toString());
            }
        }

    }
}

From source file:CharUtils.java

/**
 * True if string is all lower case.//from   ww  w .  j  av  a  2  s  .  c  om
 * 
 * @param s
 *            String to check for being all lower case.
 * 
 * @return True if string is all lower case.
 */

public static boolean isAllLowerCase(String s) {
    boolean result = true;

    for (int i = 0; i < s.length(); i++) {
        char ch = s.charAt(i);

        if (Character.isLetter(ch)) {
            result = result && Character.isLowerCase(ch);
            if (!result)
                break;
        }
    }

    return result;
}

From source file:edu.umich.robot.GuiApplication.java

/**
 * <p>/*from w ww. ja  va  2s  .  c  o  m*/
 * Pops up a window to create a new splinter robot to add to the simulation.
 */
public void createSplinterRobotDialog() {
    final Pose pose = new Pose();

    FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu",
            "pref, 2dlu, pref, 2dlu, pref");

    layout.setRowGroups(new int[][] { { 1, 3 } });

    final JDialog dialog = new JDialog(frame, "Create Splinter Robot", true);
    dialog.setLayout(layout);
    final JTextField name = new JTextField();
    final JTextField x = new JTextField(Double.toString((pose.getX())));
    final JTextField y = new JTextField(Double.toString((pose.getY())));
    final JButton cancel = new JButton("Cancel");
    final JButton ok = new JButton("OK");

    CellConstraints cc = new CellConstraints();
    dialog.add(new JLabel("Name"), cc.xy(1, 1));
    dialog.add(name, cc.xyw(3, 1, 5));
    dialog.add(new JLabel("x"), cc.xy(1, 3));
    dialog.add(x, cc.xy(3, 3));
    dialog.add(new JLabel("y"), cc.xy(5, 3));
    dialog.add(y, cc.xy(7, 3));
    dialog.add(cancel, cc.xyw(1, 5, 3));
    dialog.add(ok, cc.xyw(5, 5, 3));

    x.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            try {
                pose.setX(Double.parseDouble(x.getText()));
            } catch (NumberFormatException ex) {
                x.setText(Double.toString(pose.getX()));
            }
        }
    });

    y.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            try {
                pose.setY(Double.parseDouble(y.getText()));
            } catch (NumberFormatException ex) {
                y.setText(Double.toString(pose.getX()));
            }
        }
    });

    final ActionListener okListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String robotName = name.getText().trim();
            if (robotName.isEmpty()) {
                logger.error("Create splinter: robot name empty");
                return;
            }
            for (char c : robotName.toCharArray())
                if (!Character.isDigit(c) && !Character.isLetter(c)) {
                    logger.error("Create splinter: illegal robot name");
                    return;
                }

            controller.createSplinterRobot(robotName, pose, true);
            controller.createSimSplinter(robotName);
            controller.createSimLaser(robotName);
            dialog.dispose();
        }
    };
    name.addActionListener(okListener);
    x.addActionListener(okListener);
    y.addActionListener(okListener);
    ok.addActionListener(okListener);

    ActionListener cancelAction = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };
    cancel.addActionListener(cancelAction);
    dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    dialog.setLocationRelativeTo(frame);
    dialog.pack();
    dialog.setVisible(true);
}

From source file:com.prowidesoftware.swift.io.parser.SwiftParser.java

private static final boolean tagStarts(final String str) {
    final int l = str.length();

    if (l > 0 && !Character.isDigit(str.charAt(0))) {
        return false;
    }/*w w  w .  j av  a2 s  .  c  o  m*/

    // OK el primero es digito, el segundo puede ser dos cosas: letra o numero o :final
    if (l > 1) {
        char c2 = str.charAt(1);
        if (c2 == ':') {
            /*
             * 2015.10 miguel
             * aceptamos :1: por compatibilidad, pero no es un proper tagname
             */
            return true;
        }

        /*
         * 2015.10 miguel
         * idem antes, aceptamos :1A: por compatibilidad, pero no es un proper tagname
         */
        if (Character.isLetter(c2) && l > 2) {
            if (':' == str.charAt(2)) {
                return true;
            }
        }

        //  el segundo char debe ser un numero
        // Cubre caso 11: y 11a:
        if (Character.isDigit(c2) && l > 2) {
            if (':' == str.charAt(2)) {
                return true;
            }
            if (l > 3 && ':' == str.charAt(3) && Character.isLetter(str.charAt(2))) {
                return true;
            }
        }

    }
    return false;
}

From source file:org.wso2.carbon.governance.generic.ui.utils.GenericUtil.java

public static String getDataElementName(String widgetName) {
    if (widgetName == null || widgetName.length() == 0) {
        return null;
    }//from   w ww  .j  a  va 2s.c  om
    String[] nameParts = widgetName.split("_");
    String convertedName = null;
    //  making widget name camel case
    for (String namePart : nameParts) {
        int i;
        for (i = 0; i < namePart.length(); i++) {
            char c = namePart.charAt(i);
            if (!Character.isLetter(c) || Character.isLowerCase(c)) {
                break;
            }
        }
        namePart = namePart.substring(0, i).toLowerCase() + namePart.substring(i);
        if (convertedName == null) {
            convertedName = namePart;
        } else {
            convertedName += "_" + namePart;
        }
    }
    if (convertedName == null) {
        return null;
    }

    return convertedName.replaceAll(" ", "").replaceAll("-", "");
}

From source file:CharUtils.java

/**
 * True if string contains at least one capital letter.
 * /*  ww  w  . j a va  2s . com*/
 * @param s
 *            String to check for having a capital letter.
 * 
 * @return True if string has a capital letter.
 */

public static boolean hasCapitalLetter(String s) {
    boolean result = false;

    for (int i = 0; i < s.length(); i++) {
        char ch = s.charAt(i);

        result = result || Character.isLetter(ch) && Character.isUpperCase(ch);

        if (result)
            break;
    }

    return result;
}

From source file:org.novoj.utils.datePattern.DatePatternConverter.java

/**
 * Converts Java DateFormat pattern to the jQueryUI DatePicker TimePicker addon Javascript format (or throws
 * PatternNotConvertableException)./* w w  w .  j  av  a  2  s . c om*/
 * @param patternDecomposition
 * @param patternsA
 * @param patternsB
 * @param escapeInsideAllowed
 * @return
 * @throws PatternNotConvertableException
 */
@SuppressWarnings({ "ImplicitNumericConversion", "OverlyLongMethod", "OverlyComplexMethod" })
private String conversion(List<String> patternDecomposition, Map<String, String> patternsA,
        Map<String, String> patternsB, boolean escapeInsideAllowed) throws PatternNotConvertableException {
    boolean firstUsablePatternRecognized = false;
    boolean otherPatternRecognized = false;

    StringBuffer unknownPatterns = new StringBuffer();
    StringBuilder result = new StringBuilder();
    StringBuffer conditionalResult = new StringBuffer();
    for (String patternPart : patternDecomposition) {
        char leadLetter = patternPart.charAt(0);
        if (leadLetter == '\'') {
            if (firstUsablePatternRecognized && !escapeInsideAllowed) {
                throw new PatternNotConvertableException(
                        "Escaped parts in pattern are not allowed: " + patternPart);
            }
            //add escaped part without further analyzing it
            conditionalResult.append(patternPart);
        } else if (Character.isLetter(leadLetter)) {
            if (patternsA.containsKey(patternPart)) {
                firstUsablePatternRecognized = true;
                if (conditionalResult.length() > 0) {
                    if (otherPatternRecognized) {
                        conditionalResult = new StringBuffer();
                    } else {
                        result.append(conditionalResult);
                        conditionalResult = new StringBuffer();
                    }
                }
                result.append(patternsA.get(patternPart));
            } else if (patternsB.containsKey(patternPart)) {
                otherPatternRecognized = true;
                conditionalResult = new StringBuffer();
                if (firstUsablePatternRecognized) {
                    break;
                }
            } else {
                if (unknownPatterns.length() > 0) {
                    unknownPatterns.append(", ");
                }
                unknownPatterns.append(patternPart);
            }
        } else if (specialCharacters.contains(new Character(patternPart.charAt(0)))) {
            if (firstUsablePatternRecognized) {
                result.append(patternPart);
            }
        } else {
            conditionalResult.append(patternPart);
        }
    }

    if (unknownPatterns.length() > 0) {
        throw new PatternNotConvertableException(
                "Java pattern contains unconvertable chunks, that are not accepted by jQuery UI DatePicker: "
                        + unknownPatterns);
    }

    return result.toString();
}

From source file:immf.MyHtmlEmail.java

private static String random(int count, int start, int end, boolean letters, boolean numbers, char chars[],
        Random random) {//from ww  w.j a va  2s  .c  om
    if (count == 0)
        return "";
    if (count < 0)
        throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
    if (start == 0 && end == 0) {
        end = 123;
        start = 32;
        if (!letters && !numbers) {
            start = 0;
            end = 2147483647;
        }
    }
    StringBuffer buffer = new StringBuffer();
    int gap = end - start;
    while (count-- != 0) {
        char ch;
        if (chars == null)
            ch = (char) (random.nextInt(gap) + start);
        else
            ch = chars[random.nextInt(gap) + start];
        if (letters && numbers && Character.isLetterOrDigit(ch) || letters && Character.isLetter(ch)
                || numbers && Character.isDigit(ch) || !letters && !numbers)
            buffer.append(ch);
        else
            count++;
    }
    return buffer.toString();
}

From source file:CharUtils.java

/**
 * True if string contains internal capital letters.
 * //w ww.j a  v  a  2s.c om
 * @param s
 *            String to check for having internal capitals.
 * 
 * @return True if string has internal capitals.
 */

public static boolean hasInternalCaps(String s) {
    boolean result = false;

    for (int i = 1; i < s.length(); i++) {
        char ch = s.charAt(i);

        result = result || Character.isLetter(ch) && Character.isUpperCase(ch);

        if (result)
            break;
    }

    return result;
}