Example usage for java.lang StringBuffer reverse

List of usage examples for java.lang StringBuffer reverse

Introduction

In this page you can find the example usage for java.lang StringBuffer reverse.

Prototype

@Override
public synchronized StringBuffer reverse() 

Source Link

Usage

From source file:org.fao.geonet.services.dataprep.geocoding.GeoCoding.java

private HashMap<String, String> extractAddressField(String ezi_address, String suburb) throws Exception {
    HashMap<String, String> addrMap = new HashMap<String, String>();
    addrMap.put("original_ezi_address", ezi_address);
    addrMap.put("suburb", suburb);
    String ezi_address_without_comma = ezi_address;
    if (ezi_address.indexOf(",") != -1) {
        StringTokenizer str_comma = new StringTokenizer(ezi_address, ",");
        ezi_address_without_comma = str_comma.nextToken();
    }//from w  ww  .  j  a  v a  2 s.  co m

    StringTokenizer str = new StringTokenizer(ezi_address_without_comma, " ");
    Boolean plaqNumberFound = false;
    if (str.hasMoreTokens()) {
        String token = str.nextToken();
        if (StringUtils.isBlank(token))
            return null;
        if (token.indexOf("Unit") == 0 || token.indexOf("unit") == 0)
            token = str.nextToken();
        if (token.indexOf("Lot") == 0 || token.indexOf("lot") == 0)
            token = str.nextToken();

        if (token.indexOf("/") != -1) {
            token = token.substring(token.indexOf("/") + 1);
        }
        if (token.indexOf("\\") != -1) {
            token = token.substring(token.indexOf("\\") + 1);
        }
        while (token.length() > 0
                && !StringUtils.isNumeric(token.substring(token.length() - 1, token.length()))) {
            token = token.substring(0, token.length() - 1);
        }
        if (token.indexOf("-") != -1) {
            addrMap.put("plaqNumber", token.substring(0, token.indexOf("-")));
            addrMap.put("plaqNumber2", token.substring(token.indexOf("-") + 1, token.length()));
            plaqNumberFound = true;

        }
        if (!plaqNumberFound) {

            if (!StringUtils.isNumeric(token)) {
                if (!StringUtils.isNumeric(token.substring(0, token.length() - 1))) {
                    throw new Exception("plaque number is mandatory, ezi_address=" + ezi_address);
                } else {
                    String trimmed_token = token.substring(0, token.length() - 1);
                    addrMap.put("plaqNumber", trimmed_token);
                }

            } else {
                addrMap.put("plaqNumber", token);
            }
        }

    }
    //
    StringBuffer strBuff = new StringBuffer(ezi_address_without_comma);
    String ezi_address_without_comma_reverse = strBuff.reverse().toString();
    StringTokenizer str_reverse = new StringTokenizer(ezi_address_without_comma_reverse, " ");
    String orig_roadType = null;
    if (str_reverse.hasMoreTokens()) {
        String token = str_reverse.nextToken();
        StringBuffer strBuff2 = new StringBuffer(token);
        //
        String roadType = strBuff2.reverse().toString();
        orig_roadType = roadType;
        if ("rd".equalsIgnoreCase(roadType))
            roadType = "ROAD";
        else if ("st".equalsIgnoreCase(roadType))
            roadType = "STREET";
        else if ("ave".equalsIgnoreCase(roadType))
            roadType = "AVENUE";
        else if ("cl".equalsIgnoreCase(roadType))
            roadType = "CLOSE";
        else if ("dr".equalsIgnoreCase(roadType))
            roadType = "DRIVE";
        else if ("bvd".equalsIgnoreCase(roadType))
            roadType = "BOULEVARD";
        else if ("hwy".equalsIgnoreCase(roadType))
            roadType = "HIGHWA";
        else if ("pl".equalsIgnoreCase(roadType))
            roadType = "PLACE";
        else if ("pkwy".equalsIgnoreCase(roadType))
            roadType = "PARKWAY";
        else if ("cres".equalsIgnoreCase(roadType))
            roadType = "CRESCENT";
        else if ("hwy".equalsIgnoreCase(roadType))
            roadType = "HIGHWAY";
        else if ("cct".equalsIgnoreCase(roadType))
            roadType = "CIRCUIT";
        else if ("pde".equalsIgnoreCase(roadType))
            roadType = "PARADE";
        else if ("ct".equalsIgnoreCase(roadType))
            roadType = "COURT";
        else if ("sq".equalsIgnoreCase(roadType))
            roadType = "SQUARE";
        //
        addrMap.put("roadType", roadType);
    }
    String roadName = "";
    while (str.hasMoreTokens()) {
        String token = str.nextToken();
        if (token.equals(orig_roadType))
            break;
        if (StringUtils.isBlank(roadName))
            roadName = token;
        else
            roadName += " " + token;

    }

    addrMap.put("roadName", roadName);

    if (addrMap != null) {
        Iterator<Entry<String, String>> iter = addrMap.entrySet().iterator();
        while (iter.hasNext()) {
            Entry<String, String> entry = iter.next();
            String value = entry.getValue();
            value = value.toUpperCase();
            value = value.replaceAll("'", "\\\\'");
            addrMap.put(entry.getKey(), value);
        }
    }
    if (addrMap.containsKey("plaqNumber2")) {
        if (addrMap.get("plaqNumber2") == null)
            addrMap.put("plaqNumber2", "0");

    } else
        addrMap.put("plaqNumber2", "0");
    return addrMap;
}

From source file:com.tacitknowledge.util.migration.jdbc.SqlScriptMigrationTask.java

/**
 * Parses the SQL/DDL to execute and returns a list of individual statements.  For database
 * types that support mulitple statements in a single <code>Statement.execute</code> call,
 * this method will return a one-element <code>List</code> containing the entire SQL
 * file./*from  ww  w .  jav a2  s  . com*/
 *
 * @param context the MigrationContext, to figure out db type and if it
 *                can handle multiple statements at once
 * @return a list of SQL and DDL statements to execute
 */
public List getSqlStatements(JdbcMigrationContext context, String sqlStatements) {
    List statements = new ArrayList();
    if (context.getDatabaseType().isMultipleStatementsSupported()) {
        statements.add(sqlStatements);
        return statements;
    }

    StringBuffer currentStatement = new StringBuffer();
    boolean inQuotedString = false;
    boolean inComment = false;
    char[] sqlChars = sqlStatements.toCharArray();
    for (int i = 0; i < sqlChars.length; i++) {
        if (sqlChars[i] == '\n') {
            inComment = false;
        }

        if (!inComment) {
            switch (sqlChars[i]) {
            case '-':
            case '/':
                if (!inQuotedString && i + 1 < sqlChars.length && sqlChars[i + 1] == sqlChars[i]) {
                    inComment = true;
                } else {
                    currentStatement.append(sqlChars[i]);
                }
                break;
            case '\'':
                inQuotedString = !inQuotedString;
                currentStatement.append(sqlChars[i]);
                break;
            case ';':
                if (!inQuotedString) {
                    // If we're in a stored procedure, just keep rolling
                    if (isStoredProcedure(context.getDatabaseType().getDatabaseType(),
                            currentStatement.toString())) {
                        currentStatement.append(sqlChars[i]);
                    } else {
                        statements.add(currentStatement.toString().trim());
                        currentStatement = new StringBuffer();
                    }
                } else {
                    currentStatement.append(sqlChars[i]);
                }
                break;
            /* sybase uses 'GO' as it's statement delimiter */
            case 'g':
            case 'G':
                /*
                 * Build up a string, reading backwards from the current index to
                 * the previous newline (or beginning of sequence) and from the
                 * current index up to the next newline.  If it matches the regex
                 * for the GO delimiter, then add the statement otherwise
                 * just append the current index's character to currentStatement
                 */
                if (context.getDatabaseType().getDatabaseType().equals("sybase")) {
                    // read from current index to previous line terminator 
                    // or start of sequence
                    StringBuffer previous = new StringBuffer();
                    for (int j = i - 1; j >= 0; j--) {
                        char c = sqlChars[j];
                        previous.append(c);
                        if (isLineTerminator(c)) {
                            break;
                        }
                    }

                    // reverse previous, since we've been walking backwards, but appending
                    previous = previous.reverse();

                    // read from current index to upcoming line terminator 
                    // or end of sequence.  If it is the GO delimiter, 
                    // we skip up to line terminator
                    StringBuffer after = new StringBuffer();
                    int newIndex = 0;
                    for (int k = i + 1; k < sqlChars.length; k++) {
                        char c = sqlChars[k];
                        after.append(c);
                        newIndex = k;
                        if (isLineTerminator(c)) {
                            break;
                        }
                    }

                    // check against the pattern if its a GO delimiter
                    String possibleDelimiter = previous.append(sqlChars[i]).append(after).toString();
                    final String delimiterPattern = "^\\s*[Gg][Oo]\\s*$";

                    if (Pattern.matches(delimiterPattern, possibleDelimiter)) {
                        // if it's blank, don't bother adding it since Sybase
                        // will complain about empty queries.
                        // This happens if there are two GO's with no
                        // actual SQL to run between them.
                        if (!StringUtils.isBlank(currentStatement.toString().trim())) {
                            statements.add(currentStatement.toString().trim());
                        }
                        currentStatement = new StringBuffer();
                        // skip up to next line terminator
                        i = newIndex;
                    } else // not a delimiter, so just append
                    {
                        currentStatement.append(sqlChars[i]);
                    }
                } else // not a sybase db, so just append
                {
                    currentStatement.append(sqlChars[i]);
                }
                break;
            default:
                currentStatement.append(sqlChars[i]);
                break;
            }
        }
    }
    if (currentStatement.toString().trim().length() > 0) {
        statements.add(currentStatement.toString().trim());
    }

    return statements;
}

From source file:cx.fbn.nevernote.threads.IndexRunner.java

private void addToIndex(String guid, String word, String type) {
    if (foundWords.contains(word))
        return;//from   w  ww.j  a  va  2s. co m
    StringBuffer buffer = new StringBuffer(word.toLowerCase());
    for (int i = buffer.length() - 1; i >= 0; i--) {
        if (!Character.isLetterOrDigit(buffer.charAt(i))
                && specialIndexCharacters.indexOf(buffer.charAt(i)) == -1)
            buffer.deleteCharAt(i);
        else
            break;
    }
    buffer = buffer.reverse();
    for (int i = buffer.length() - 1; i >= 0; i--) {
        if (!Character.isLetterOrDigit(buffer.charAt(i)))
            buffer.deleteCharAt(i);
        else
            break;
    }
    buffer = buffer.reverse();
    if (buffer.length() > 0) {
        // We have a good word, now let's trim off junk at the beginning or end
        if (!foundWords.contains(buffer.toString())) {
            foundWords.add(buffer.toString());
            foundWords.add(word);
            conn.getWordsTable().addWordToNoteIndex(guid, buffer.toString(), type, 100);
            uncommittedCount++;
            if (uncommittedCount > 100) {
                conn.commitTransaction();
                uncommittedCount = 0;
            }
        }
    }
    return;
}

From source file:gate.util.reporting.PRTimeReporter.java

/**
 * Ensures that the required line is read from the given file part.
 *
 * @param bytearray/*w  w w  .  ja va2 s.  c  o m*/
 *          A part of a file being read upside down.
 * @param lastNlines
 *          A vector containing the lines extracted from file part.
 * @return true if marker indicating the logical start of run is found; false
 *         otherwise.
 */
private boolean parseLinesFromLast(byte[] bytearray, Vector<String> lastNlines) {
    String lastNChars = new String(bytearray);
    StringBuffer sb = new StringBuffer(lastNChars);
    lastNChars = sb.reverse().toString();
    StringTokenizer tokens = new StringTokenizer(lastNChars, NL);
    while (tokens.hasMoreTokens()) {
        StringBuffer sbLine = new StringBuffer(tokens.nextToken());
        lastNlines.add(sbLine.reverse().toString());
        if ((lastNlines.get(lastNlines.size() - 1)).trim().endsWith(getLogicalStart())) {
            return true;
        }
    }
    return false; // indicates didn't read 'lineCount' lines
}

From source file:org.jivesoftware.community.util.StringUtils.java

public static String encodeAlphaNumeric(long toEncode) {
    if (toEncode < 0L)
        throw new UnsupportedOperationException("Encoding of negative numbers is not supported");
    if (toEncode == 0L)
        return "0";
    StringBuffer buff = new StringBuffer();
    for (; toEncode != 0L; toEncode /= base.length)
        buff.append(base[(int) (toEncode % (long) base.length)]);

    return buff.reverse().toString();
}

From source file:gate.util.reporting.DocTimeReporter.java

/**
 * A method to ensure that the required line is read from the given file part.
 *
 * @param bytearray/*from w  w w  .jav a2s. c  om*/
 *          A part of a file being read upside down.
 * @param lastNlines
 *          A vector containing the lines extracted from file part.
 * @param fromPos
 *          A long value indicating the start of a file part.
 *
 * @return true if marker indicating the logical start of run is found; false
 *         otherwise.
 */
private boolean parseLinesFromLast(byte[] bytearray, Vector<String> lastNlines, long fromPos) {
    String lastNChars = new String(bytearray);
    StringBuffer sb = new StringBuffer(lastNChars);
    lastNChars = sb.reverse().toString();
    StringTokenizer tokens = new StringTokenizer(lastNChars, NL);
    while (tokens.hasMoreTokens()) {
        StringBuffer sbLine = new StringBuffer(tokens.nextToken());
        lastNlines.add(sbLine.reverse().toString());
        if ((lastNlines.get(lastNlines.size() - 1)).trim().endsWith(getLogicalStart())) {
            return true;
        }
    }
    return false;
}

From source file:Unsigned.java

/**
 * Parse a binary number, skipping leading whitespace. Does not throw an
 * exception; if no object can be parsed, index is unchanged!
 * /*from ww w.  j av a  2  s. c om*/
 * @param source
 *            the string to parse
 * @param status
 *            the string index to start at
 * @return The binary number as a Long object.
 * 
 * @since 1.0
 */
public Object parseObject(String source, ParsePosition status) {
    int start = status.getIndex();
    boolean success = false;
    boolean skipWhitespace = true;
    StringBuffer buffer = new StringBuffer();

    StringCharacterIterator iter = new StringCharacterIterator(source, start);

    for (char c = iter.current(); c != CharacterIterator.DONE; c = iter.next()) {
        if (skipWhitespace && Character.isWhitespace(c)) {
            // skip whitespace
            continue;
        }
        skipWhitespace = false;

        if ((c == '1') || (c == '0')) {
            success = true;
            buffer.append(c);
        } else {
            break;
        }
    }

    if (!success) {
        return (null);
    }

    // convert binary to long
    if (buffer.length() > 64) {
        // larger than a long, error
        return (null);
    }

    long result = 0;
    buffer.reverse();
    int length = buffer.length();
    for (int i = 0; i < length; i++) {
        result += (buffer.charAt(i) == '1') ? 1 << i : 0;
    }
    status.setIndex(iter.getIndex());
    return (new Long(result));
}

From source file:edu.oregonstate.eecs.mcplan.util.Fn.java

/**
 * Convert a BitSet to a string in which each character represents
 * 'block_size' consecutive bits.//from ww  w  .j  a v  a2 s  .  co  m
 * @param bits
 * @param block_size Min 1, max 5
 * @return
 */
public static String toDigits(final BitSet bits, final int block_size) {
    assert (block_size >= 1);
    assert (block_size <= 5);
    final int radix = 1 << block_size;
    final StringBuffer sb = new StringBuffer();
    for (int i = 0; i < bits.length(); i += block_size) {
        int c = 0;
        for (int j = 0; j < block_size; ++j) {
            c |= (bits.get(i + j) ? 1 : 0) << j;
        }
        sb.append(Character.forDigit(c, radix));
    }
    return sb.reverse().toString();
}

From source file:forseti.JUtil.java

public static synchronized String CantEnLetra(float cant, String id_moneda, String moneda) {
    String MONEDA = (moneda == null) ? "" : moneda;
    String MN;/*from   w ww .  j  a v  a 2 s.  c o  m*/
    if (id_moneda == null || !id_moneda.equals("1"))
        MN = "";
    else
        MN = "m.n.";

    if (cant == 0.00)
        return "cero " + MONEDA + " 00/100 " + MN;

    StringBuffer sCant;
    String sDec = "", sCen = "", sMil = "", s10Mil = "", s100Mil = "", sMillon = "", s10Millon = "",
            s100Millon = "", s1000Millon = "";
    String str, decim;
    str = Float.toString(redondear(cant, 2));

    int index = str.indexOf('.');
    if (index == -1)
        decim = "00/100";
    else {
        decim = str.substring(index + 1);
        if (decim.length() == 1)
            decim = decim + "0/100";
        else
            decim = decim + "/100";

    }

    int cantent = (int) Math.floor((double) redondear(cant, (byte) 2));
    int dec = 0, cen = 0, mil = 0, diezmil = 0, cienmil = 0, millon = 0, diezmillon = 0, cienmillon = 0,
            milmillon = 0;

    sCant = new StringBuffer(Integer.toString(cantent));
    sCant.reverse();

    int len = sCant.length();

    if (len > 0) {
        dec = Integer.parseInt(sCant.substring(0, 1));
        switch (dec) {
        case 1:
            sDec = "un";
            break;
        case 2:
            sDec = "dos";
            break;
        case 3:
            sDec = "tres";
            break;
        case 4:
            sDec = "cuatro";
            break;
        case 5:
            sDec = "cinco";
            break;
        case 6:
            sDec = "seis";
            break;
        case 7:
            sDec = "siete";
            break;
        case 8:
            sDec = "ocho";
            break;
        case 9:
            sDec = "nueve";
            break;
        default:
            sDec = "";
            break;
        }
    }

    if (len > 1) {
        cen = Integer.parseInt(sCant.substring(1, 2));
        switch (cen) {
        case 1:
            if (dec == 0)
                sCen = "diez";
            else if (dec == 1) {
                sCen = "once";
                sDec = "";
            } else if (dec == 2) {
                sCen = "doce";
                sDec = "";
            } else if (dec == 3) {
                sCen = "trece";
                sDec = "";
            } else if (dec == 4) {
                sCen = "catorce";
                sDec = "";
            } else if (dec == 5) {
                sCen = "quince";
                sDec = "";
            } else
                sCen = "dieci";
            break;
        case 2:
            if (dec == 0)
                sCen = "veinte";
            else
                sCen = "veinti";
            break;
        case 3:
            if (dec == 0)
                sCen = "treinta";
            else
                sCen = "treinta y ";
            break;
        case 4:
            if (dec == 0)
                sCen = "cuarenta";
            else
                sCen = "cuarenta y ";
            break;
        case 5:
            if (dec == 0)
                sCen = "cincuenta";
            else
                sCen = "cincuenta y ";
            break;
        case 6:
            if (dec == 0)
                sCen = "sesenta";
            else
                sCen = "sesenta y ";
            break;
        case 7:
            if (dec == 0)
                sCen = "setenta";
            else
                sCen = "setenta y ";
            break;
        case 8:
            if (dec == 0)
                sCen = "ochenta";
            else
                sCen = "ochenta y ";
            break;
        case 9:
            if (dec == 0)
                sCen = "noventa";
            else
                sCen = "noventa y ";
            break;
        default:
            sCen = "";
            break;
        }
    }

    if (len > 2) {
        mil = Integer.parseInt(sCant.substring(2, 3));
        switch (mil) {
        case 1:
            if (dec == 0 && cen == 0)
                sMil = "cien";
            else
                sMil = "ciento ";
            break;
        case 2:
            sMil = "doscientos ";
            break;
        case 3:
            sMil = "trescientos ";
            break;
        case 4:
            sMil = "cuatrocientos ";
            break;
        case 5:
            sMil = "quinientos ";
            break;
        case 6:
            sMil = "seiscientos ";
            break;
        case 7:
            sMil = "setecientos ";
            break;
        case 8:
            sMil = "ochocientos ";
            break;
        case 9:
            sMil = "novecientos ";
            break;
        default:
            sMil = "";
            break;
        }
    }

    if (len > 3) {
        diezmil = Integer.parseInt(sCant.substring(3, 4));
        switch (diezmil) {
        case 1:
            s10Mil = "un mil ";
            break;
        case 2:
            s10Mil = "dos mil ";
            break;
        case 3:
            s10Mil = "tres mil ";
            break;
        case 4:
            s10Mil = "cuatro mil ";
            break;
        case 5:
            s10Mil = "cinco mil ";
            break;
        case 6:
            s10Mil = "seis mil ";
            break;
        case 7:
            s10Mil = "siete mil ";
            break;
        case 8:
            s10Mil = "ocho mil ";
            break;
        case 9:
            s10Mil = "nueve mil ";
            break;
        default:
            s10Mil = "";
            break;
        }
    }

    if (len > 4) {
        cienmil = Integer.parseInt(sCant.substring(4, 5));
        switch (cienmil) {
        case 1:
            if (diezmil == 0)
                s100Mil = "diez mil ";
            else if (diezmil == 1) {
                s100Mil = "once mil ";
                s10Mil = "";
            } else if (diezmil == 2) {
                s100Mil = "doce mil ";
                s10Mil = "";
            } else if (diezmil == 3) {
                s100Mil = "trece mil ";
                s10Mil = "";
            } else if (diezmil == 4) {
                s100Mil = "catorce mil ";
                s10Mil = "";
            } else if (diezmil == 5) {
                s100Mil = "quince mil ";
                s10Mil = "";
            } else
                s100Mil = "dieci";
            break;
        case 2:
            if (diezmil == 0)
                s100Mil = "veinte mil ";
            else
                s100Mil = "veinti";
            break;
        case 3:
            if (diezmil == 0)
                s100Mil = "treinta mil";
            else
                s100Mil = "treinta y ";
            break;
        case 4:
            if (diezmil == 0)
                s100Mil = "cuarenta mil ";
            else
                s100Mil = "cuarenta y ";
            break;
        case 5:
            if (diezmil == 0)
                s100Mil = "cincuenta mil ";
            else
                s100Mil = "cincuenta y ";
            break;
        case 6:
            if (diezmil == 0)
                s100Mil = "sesenta mil ";
            else
                s100Mil = "sesenta y ";
            break;
        case 7:
            if (diezmil == 0)
                s100Mil = "setenta mil ";
            else
                s100Mil = "setenta y ";
            break;
        case 8:
            if (diezmil == 0)
                s100Mil = "ochenta mil ";
            else
                s100Mil = "ochenta y ";
            break;
        case 9:
            if (diezmil == 0)
                s100Mil = "noventa mil ";
            else
                s100Mil = "noventa y ";
            break;
        default:
            s100Mil = "";
            break;
        }
    }

    if (len > 5) {
        millon = Integer.parseInt(sCant.substring(5, 6));
        switch (millon) {
        case 1:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cien mil ";
            else
                sMillon = "ciento ";
            break;
        case 2:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "doscientos mil ";
            else
                sMillon = "doscientos ";
            break;
        case 3:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "trescientos mil ";
            else
                sMillon = "trescientos ";
            break;
        case 4:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cuatrocientos mil ";
            else
                sMillon = "cuatrocientos ";
            break;
        case 5:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "quinientos mil ";
            else
                sMillon = "quinientos ";
            break;
        case 6:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "seiscientos mil ";
            else
                sMillon = "seiscientos ";
            break;
        case 7:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "setecientos mil ";
            else
                sMillon = "setecientos ";
            break;
        case 8:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "ochocientos mil ";
            else
                sMillon = "ochocientos ";
            break;
        case 9:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "novecientos mil ";
            else
                sMillon = "novecientos ";
            break;
        default:
            sMillon = "";
            break;
        }
    }

    // millones
    if (len > 6) {
        diezmillon = Integer.parseInt(sCant.substring(6, 7));
        switch (diezmillon) {
        case 1:
            s10Millon = "un millon ";
            break;
        case 2:
            s10Millon = "dos millones ";
            break;
        case 3:
            s10Millon = "tres millones ";
            break;
        case 4:
            s10Millon = "cuatro millones ";
            break;
        case 5:
            s10Millon = "cinco millones ";
            break;
        case 6:
            s10Millon = "seis millones ";
            break;
        case 7:
            s10Millon = "siete millones ";
            break;
        case 8:
            s10Millon = "ocho millones ";
            break;
        case 9:
            s10Millon = "nueve millones ";
            break;
        default:
            s10Millon = "";
            break;
        }
    }

    if (len > 7) {
        cienmillon = Integer.parseInt(sCant.substring(7, 8));
        switch (cienmillon) {
        case 1:
            if (diezmillon == 0)
                s100Millon = "diez millones ";
            else if (diezmillon == 1) {
                s100Millon = "once millones ";
                s10Millon = "";
            } else if (diezmillon == 2) {
                s100Millon = "doce millones ";
                s10Millon = "";
            } else if (diezmillon == 3) {
                s100Millon = "trece millones ";
                s10Millon = "";
            } else if (diezmillon == 4) {
                s100Millon = "catorce millones ";
                s10Millon = "";
            } else if (diezmillon == 5) {
                s100Millon = "quince millones ";
                s10Millon = "";
            } else
                s100Millon = "dieci";
            break;
        case 2:
            if (diezmillon == 0)
                s100Millon = "veinte millones ";
            else
                s100Millon = "veinti";
            break;
        case 3:
            if (diezmillon == 0)
                s100Millon = "treinta millones ";
            else
                s100Millon = "treinta y ";
            break;
        case 4:
            if (diezmillon == 0)
                s100Millon = "cuarenta millones ";
            else
                s100Millon = "cuarenta y ";
            break;
        case 5:
            if (diezmillon == 0)
                s100Millon = "cincuenta millones ";
            else
                s100Millon = "cincuenta y ";
            break;
        case 6:
            if (diezmillon == 0)
                s100Millon = "sesenta millones ";
            else
                s100Millon = "sesenta y ";
            break;
        case 7:
            if (diezmillon == 0)
                s100Millon = "setenta millones ";
            else
                s100Millon = "setenta y ";
            break;
        case 8:
            if (diezmillon == 0)
                s100Millon = "ochenta millones ";
            else
                s100Millon = "ochenta y ";
            break;
        case 9:
            if (diezmillon == 0)
                s100Millon = "noventa millones ";
            else
                s100Millon = "noventa y ";
            break;
        default:
            s100Millon = "";
            break;
        }
        if (millon == 0 && cienmil == 0 && diezmil == 0 && mil == 0 && cen == 0 && dec == 0)
            s100Millon += "de";
    }

    if (len > 8) {
        milmillon = Integer.parseInt(sCant.substring(8, 9));
        switch (milmillon) {
        case 1:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cien millones ";
            else
                s1000Millon = "ciento ";
            break;
        case 2:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "doscientos millones ";
            else
                s1000Millon = "doscientos ";
            break;
        case 3:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "trescientos millones ";
            else
                s1000Millon = "trescientos ";
            break;
        case 4:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cuatrocientos millones ";
            else
                s1000Millon = "cuatrocientos ";
            break;
        case 5:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "quinientos millones ";
            else
                s1000Millon = "quinientos ";
            break;
        case 6:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "seiscientos millones ";
            else
                s1000Millon = "seiscientos ";
            break;
        case 7:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "setecientos millones ";
            else
                s1000Millon = "setecientos ";
            break;
        case 8:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "ochocientos millones ";
            else
                s1000Millon = "ochocientos ";
            break;
        case 9:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "novecientos millones ";
            else
                s1000Millon = "novecientos ";
            break;
        default:
            s1000Millon = "";
            break;
        }
    }

    String res = s1000Millon + s100Millon + s10Millon + sMillon + s100Mil + s10Mil + sMil + sCen + sDec;
    res += " " + MONEDA + " " + decim + " " + MN;

    //sCant.MakeUpper();

    return res;

}