Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

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

Prototype

public static String toString(int codePoint) 

Source Link

Document

Returns a String object representing the specified character (Unicode code point).

Usage

From source file:org.kuali.rice.testtools.selenium.WebDriverLegacyITBase.java

private String searchForAvailableCode(int codeLength) throws InterruptedException {
    String randomCode = RandomStringUtils.randomAlphabetic(codeLength).toUpperCase();
    waitAndTypeByName("code", randomCode);
    waitAndClickSearch();/*from   w  w  w .  j  av a 2  s  .co  m*/
    int attemptCount = 1;
    waitForTextPresent("You have entered the primary key for this table");
    while (!isTextPresent("No values match this search.") && attemptCount < 25) {
        randomCode = Character.toString((char) (randomCode.toCharArray()[0] + attemptCount++));
        clearTextByName("code");
        waitAndTypeByName("code", randomCode);
        waitAndClickSearch();
        waitForTextPresent("You have entered the primary key for this table");
    }
    return randomCode;
}

From source file:org.domainmath.gui.MainFrame.java

private void createFile(String path, String ext) {

    String name = path + "octave" + ext;
    String cmd = MainFrame.octavePath + " --persist " + Character.toString('"') + path + "dmns.m"
            + Character.toString('"');
    try {//from   w w w  .  ja  v a2s.  c  o  m
        try (FileWriter w = new FileWriter(new File(name))) {
            w.write(cmd, 0, cmd.length());
            w.flush();
        }
    } catch (IOException ex) {
    }

}

From source file:com.photon.phresco.framework.impl.SCMManagerImpl.java

public List<RepoFileInfo> getCommitableFiles(File path, String revision) throws SVNException {

    SVNClientManager svnClientManager = SVNClientManager.newInstance();
    final List<RepoFileInfo> filesList = new ArrayList<RepoFileInfo>();
    svnClientManager.getStatusClient().doStatus(path, SVNRevision.parse(revision), SVNDepth.INFINITY, false,
            false, false, false, new ISVNStatusHandler() {
                public void handleStatus(SVNStatus status) throws SVNException {
                    SVNStatusType statusType = status.getContentsStatus();
                    if (statusType != SVNStatusType.STATUS_NONE && statusType != SVNStatusType.STATUS_NORMAL
                            && statusType != SVNStatusType.STATUS_IGNORED) {
                        RepoFileInfo repoFileInfo = new RepoFileInfo();
                        String filePath = status.getFile().getPath();
                        String FileStatus = Character.toString(statusType.getCode());
                        repoFileInfo.setContentsStatus(statusType);
                        repoFileInfo.setStatus(FileStatus);
                        repoFileInfo.setCommitFilePath(filePath);
                        filesList.add(repoFileInfo);
                    }/* www.j  a v a  2s. c  o m*/
                }
            }, null);

    return filesList;
}

From source file:com.rfo.basic.Run.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Log.v(LOGTAG, "onKeyUp" + keyCode);
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        return handleMenuKey(event);
    }/* w ww  .j av a  2  s .co m*/
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        return super.onKeyUp(keyCode, event);
    }

    char c;
    String theKey = "@";
    int n;
    if (keyCode >= 7 && keyCode <= 16) {
        n = keyCode - 7;
        c = Numbers.charAt(n);
        theKey = Character.toString(c);

    } else if (keyCode >= 29 && keyCode <= 54) {
        n = keyCode - 29;
        c = Chars.charAt(n);
        theKey = Character.toString(c);
    } else if (keyCode == 62) {
        c = ' ';
        theKey = Character.toString(c);
    } else if (keyCode >= 19 && keyCode <= 23) {
        switch (keyCode) {
        case 19:
            theKey = "up";
            break;
        case 20:
            theKey = "down";
            break;
        case 21:
            theKey = "left";
            break;
        case 22:
            theKey = "right";
            break;
        case 23:
            theKey = "go";
            break;
        }
    } else {
        theKey = "key " + keyCode;
    }

    synchronized (this) {
        InChar.add(theKey);
    }
    triggerInterrupt(Interrupt.KEY_BIT);

    return true;
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private void stateTransition(char cTrans) throws BasicException {

    if (cTrans == '\n') {
        // Codigo de barras introducido
        if (m_sBarcode.length() > 0) {
            String sCode = m_sBarcode.toString();
            if (sCode.startsWith("c")) {
                // barcode of a customers card
                try {
                    CustomerInfoExt newcustomer = dlSales.findCustomerExt(sCode);
                    if (newcustomer == null) {
                        Toolkit.getDefaultToolkit().beep();
                        new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocustomer"))
                                .show(this);
                    } else {
                        m_oTicket.setCustomer(newcustomer);
                        //                            m_jTicketId.setText(m_oTicket.getName(m_oTicketExt));
                    }//from   w ww.j av a  2s .c o m
                } catch (BasicException e) {
                    Toolkit.getDefaultToolkit().beep();
                    new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocustomer"), e)
                            .show(this);
                }
                stateToZero();
            } else if (sCode.length() == 13 && sCode.startsWith("250")) {
                // barcode of the other machine
                ProductInfoExt oProduct = new ProductInfoExt(); // Es un ticket
                oProduct.setReference(null); // para que no se grabe
                oProduct.setCode(sCode);
                oProduct.setName("Ticket " + sCode.substring(3, 7));
                oProduct.setPriceSell(Double.parseDouble(sCode.substring(7, 12)) / 100);
                oProduct.setTaxCategoryID(((TaxCategoryInfo) taxcategoriesmodel.getSelectedItem()).getID());
                // Se anade directamente una unidad con el precio y todo
                addTicketLine(oProduct, 1.0,
                        includeTaxes(oProduct.getTaxCategoryID(), oProduct.getPriceSell()));
            } else if (sCode.length() == 13 && sCode.startsWith("210")) {
                // barcode of a weigth product
                incProductByCodePrice(sCode.substring(0, 7), Double.parseDouble(sCode.substring(7, 12)) / 100);
            } else {
                incProductByCode(sCode);
            }
        } else {
            Toolkit.getDefaultToolkit().beep();
        }
    } else {
        // otro caracter
        // Esto es para el codigo de barras...
        m_sBarcode.append(cTrans);

        // Esto es para el los productos normales...
        if (cTrans == '\u007f') {
            stateToZero();

        } else if ((cTrans == '0') && (m_iNumberStatus == NUMBER_INPUTZERO)) {
            //                m_jPrice.setText("0");
        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5'
                || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_INPUTZERO)) {
            // Un numero entero
            //       m_jPrice.setText(Character.toString(cTrans));
            m_iNumberStatus = NUMBER_INPUTINT;
            m_iNumberStatusInput = NUMBERVALID;
        } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4'
                || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_INPUTINT)) {
            // Un numero entero
            //      m_jPrice.setText(m_jPrice.getText() + cTrans);
        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTZERO) {
            //    m_jPrice.setText("0.");
            m_iNumberStatus = NUMBER_INPUTZERODEC;
        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTINT) {
            //    m_jPrice.setText(m_jPrice.getText() + ".");
            m_iNumberStatus = NUMBER_INPUTDEC;

        } else if ((cTrans == '0')
                && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {
            // Un numero decimal
            //   m_jPrice.setText(m_jPrice.getText() + cTrans);
        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5'
                || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {
            // Un numero decimal
            //   m_jPrice.setText(m_jPrice.getText() + cTrans);
            m_iNumberStatus = NUMBER_INPUTDEC;
            m_iNumberStatusInput = NUMBERVALID;

        } else if (cTrans == '*'
                && (m_iNumberStatus == NUMBER_INPUTINT || m_iNumberStatus == NUMBER_INPUTDEC)) {
            m_jPor.setText("x");
            m_iNumberStatus = NUMBER_PORZERO;
        } else if (cTrans == '*'
                && (m_iNumberStatus == NUMBER_INPUTZERO || m_iNumberStatus == NUMBER_INPUTZERODEC)) {
            //  m_jPrice.setText("0");
            m_jPor.setText("x");
            m_iNumberStatus = NUMBER_PORZERO;

        } else if ((cTrans == '0') && (m_iNumberStatus == NUMBER_PORZERO)) {
            m_jPor.setText("x0");
        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5'
                || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_PORZERO)) {
            // Un numero entero
            m_jPor.setText("x" + Character.toString(cTrans));
            m_iNumberStatus = NUMBER_PORINT;
            m_iNumberStatusPor = NUMBERVALID;
        } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4'
                || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_PORINT)) {
            // Un numero entero
            m_jPor.setText(m_jPor.getText() + cTrans);

        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORZERO) {
            m_jPor.setText("x0.");
            m_iNumberStatus = NUMBER_PORZERODEC;
        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORINT) {
            m_jPor.setText(m_jPor.getText() + ".");
            m_iNumberStatus = NUMBER_PORDEC;

        } else if ((cTrans == '0')
                && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {
            // Un numero decimal
            m_jPor.setText(m_jPor.getText() + cTrans);
        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5'
                || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
                && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {
            // Un numero decimal
            m_jPor.setText(m_jPor.getText() + cTrans);
            m_iNumberStatus = NUMBER_PORDEC;
            m_iNumberStatusPor = NUMBERVALID;

        } else if (cTrans == '\u00a7' && m_iNumberStatusInput == NUMBERVALID
                && m_iNumberStatusPor == NUMBERZERO) {
            // Scale button pressed and a number typed as a price
            if (m_App.getDeviceScale().existsScale()
                    && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
                try {
                    Double value = m_App.getDeviceScale().readWeight();
                    if (value != null) {
                        ProductInfoExt product = getInputProduct();
                        addTicketLine(product, value.doubleValue(), product.getPriceSell());
                    }
                } catch (ScaleException e) {
                    Toolkit.getDefaultToolkit().beep();
                    new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e)
                            .show(this);
                    stateToZero();
                }
            } else {
                // No existe la balanza;
                Toolkit.getDefaultToolkit().beep();
            }
        } else if (cTrans == '\u00a7' && m_iNumberStatusInput == NUMBERZERO
                && m_iNumberStatusPor == NUMBERZERO) {
            // Scale button pressed and no number typed.
            int i = m_ticketlines.getSelectedIndex();
            if (i < 0) {
                Toolkit.getDefaultToolkit().beep();
            } else if (m_App.getDeviceScale().existsScale()) {
                try {
                    Double value = m_App.getDeviceScale().readWeight();
                    if (value != null) {
                        RetailTicketLineInfo newline = new RetailTicketLineInfo(m_oTicket.getLine(i));
                        newline.setMultiply(value.doubleValue());
                        newline.setPrice(Math.abs(newline.getPrice()));
                        paintTicketLine(i, newline);
                    }
                } catch (ScaleException e) {
                    // Error de pesada.
                    Toolkit.getDefaultToolkit().beep();
                    new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e)
                            .show(this);
                    stateToZero();
                }
            } else {
                // No existe la balanza;
                Toolkit.getDefaultToolkit().beep();
            }

            // Add one product more to the selected line
        } else if (cTrans == '+' && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {

            int i = m_ticketlines.getSelectedIndex();
            if (i < 0) {
                Toolkit.getDefaultToolkit().beep();
            } else {
                RetailTicketLineInfo newline = new RetailTicketLineInfo(m_oTicket.getLine(i));
                //If it's a refund + button means one unit less
                if (m_oTicket.getTicketType() == RetailTicketInfo.RECEIPT_REFUND) {
                    newline.setMultiply(newline.getMultiply() - 1.0);
                    paintTicketLine(i, newline);
                } else {

                    //    ProductInfoExt product = new ProductInfoExt();
                    // add one unit to the selected line
                    newline.setMultiply(newline.getMultiply() + 1.0);
                    // buttonPlus = 2;

                    paintTicketLine(i, newline);
                    //    m_oTicket.refreshTxtFields(1);
                    //below line is for promotion products
                    //                        ProductInfoExt product = getInputProduct();
                    //                        addTicketLine(product, 1.0, product.getPriceSell());

                }
            }

            // Delete one product of the selected line
        } else if (cTrans == '-' && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {

            int i = m_ticketlines.getSelectedIndex();
            if (i < 0) {
                Toolkit.getDefaultToolkit().beep();
            } else {
                RetailTicketLineInfo newline = new RetailTicketLineInfo(m_oTicket.getLine(i));
                //If it's a refund - button means one unit more
                if (m_oTicket.getTicketType() == RetailTicketInfo.RECEIPT_REFUND) {
                    newline.setMultiply(newline.getMultiply() + 1.0);
                    if (newline.getMultiply() >= 0) {
                        removeTicketLine(i);
                    } else {
                        paintTicketLine(i, newline);
                    }
                } else {
                    // substract one unit to the selected line
                    newline.setMultiply(newline.getMultiply() - 1.0);
                    // m_oTicket.refreshTxtFields(1);

                    if (newline.getMultiply() > 0.0) {
                        // removeTicketLine(i); // elimino la linea
                        // } else {

                        paintTicketLine(i, newline);
                        // m_oTicket.refreshTxtFields(1);
                        //below line is for promotion products
                        //                            ProductInfoExt product = getInputProduct();
                        //                            addTicketLine(product, newline.getMultiply(), product.getPriceSell());
                    }
                }
            }

            // Set n products to the selected line
        } else if (cTrans == '+' && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERVALID) {
            int i = m_ticketlines.getSelectedIndex();
            if (i < 0) {
                Toolkit.getDefaultToolkit().beep();
            } else {
                double dPor = getPorValue();
                RetailTicketLineInfo newline = new RetailTicketLineInfo(m_oTicket.getLine(i));
                if (m_oTicket.getTicketType() == RetailTicketInfo.RECEIPT_REFUND) {
                    newline.setMultiply(-dPor);
                    newline.setPrice(Math.abs(newline.getPrice()));
                    paintTicketLine(i, newline);
                } else {
                    newline.setMultiply(dPor);
                    newline.setPrice(Math.abs(newline.getPrice()));
                    paintTicketLine(i, newline);
                }
            }

            // Set n negative products to the selected line
        } else if (cTrans == '-' && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERVALID
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {

            int i = m_ticketlines.getSelectedIndex();
            if (i < 0) {
                Toolkit.getDefaultToolkit().beep();
            } else {
                double dPor = getPorValue();
                RetailTicketLineInfo newline = new RetailTicketLineInfo(m_oTicket.getLine(i));
                if (m_oTicket.getTicketType() == RetailTicketInfo.RECEIPT_NORMAL) {
                    newline.setMultiply(dPor);
                    newline.setPrice(-Math.abs(newline.getPrice()));
                    paintTicketLine(i, newline);
                }
            }

            // Anadimos 1 producto
        } else if (cTrans == '+' && m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
            ProductInfoExt product = getInputProduct();
            addTicketLine(product, 1.0, product.getPriceSell());

            // Anadimos 1 producto con precio negativo
        } else if (cTrans == '-' && m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
            ProductInfoExt product = getInputProduct();
            addTicketLine(product, 1.0, -product.getPriceSell());

            // Anadimos n productos
        } else if (cTrans == '+' && m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERVALID
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
            ProductInfoExt product = getInputProduct();
            addTicketLine(product, getPorValue(), product.getPriceSell());

            // Anadimos n productos con precio negativo ?
        } else if (cTrans == '-' && m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERVALID
                && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
            ProductInfoExt product = getInputProduct();
            addTicketLine(product, getPorValue(), -product.getPriceSell());

            // Totals() Igual;
        } else if (cTrans == ' ' || cTrans == '=') {
            if (m_oTicket.getLinesCount() > 0) {

                if (closeTicket(m_oTicket, m_oTicketExt, m_aPaymentInfo)) {
                    // Ends edition of current receipt
                    if (!m_oTicket.getSplitValue().equals("Split")) {
                        m_ticketsbag.deleteTicket();
                    } else {
                        //  m_ticketsbag.deleteTicket(m_oTicket.getSplitSharedId());
                    }

                } else {
                    // repaint current ticket
                    refreshTicket();
                }
            } else {
                Toolkit.getDefaultToolkit().beep();
            }
        }
    }
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

protected void testReferenceCampusTypeBlanketApprove() throws Exception {
    selectFrameIframePortlet();/*from   w w w .j  av a2s.c  o  m*/
    waitAndCreateNew();
    String docId = waitForDocId();
    assertBlanketApproveButtonsPresent();
    String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits();
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Campus Type " + dtsTwo);
    waitAndTypeByXpath(DOC_CODE_XPATH, RandomStringUtils.randomAlphabetic(1));
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Indianapolis" + dtsTwo);
    int attemptCount = 1;
    blanketApproveCheck();
    while (hasDocError("same primary key already exists") && attemptCount < 25) {
        clearTextByXpath(DOC_CODE_XPATH);
        waitAndTypeByXpath(DOC_CODE_XPATH, Character.toString((char) ('A' + attemptCount++)));
        blanketApproveCheck();
    }
    blanketApproveAssert();
    assertDocFinal(docId);
}

From source file:ca.oson.json.Oson.java

private <E> String character2Json(FieldData objectDTO) {
    if (objectDTO == null || objectDTO.json2Java) {
        return null;
    }/*from w w  w  .  j av  a 2s  . co m*/

    Object value = objectDTO.valueToProcess;
    Class<E> returnType = objectDTO.returnType;

    if (returnType != null && value != null && (returnType == char.class || returnType == Character.class)) {
        Character valueToProcess = (Character) value;
        String valueToReturn = null;

        // convert from char to Character
        if (returnType == char.class) {
            valueToProcess = Character.valueOf((char) value); // new Character(value)
        } else {
            valueToProcess = (Character) value;
        }

        if (valueToProcess != null) {
            try {
                Function function = objectDTO.getSerializer();
                if (function != null) {
                    try {
                        if (function instanceof DataMapper2JsonFunction) {
                            DataMapper classData = new DataMapper(returnType, value, objectDTO.classMapper,
                                    objectDTO.level, getPrettyIndentation());
                            return ((DataMapper2JsonFunction) function).apply(classData);

                        } else if (function instanceof Character2JsonFunction) {
                            return ((Character2JsonFunction) function).apply(valueToProcess);

                        } else {

                            Object returnedValue = null;
                            if (function instanceof FieldData2JsonFunction) {
                                FieldData2JsonFunction f = (FieldData2JsonFunction) function;
                                FieldData fieldData = objectDTO.clone();
                                returnedValue = f.apply(fieldData);
                            } else {
                                returnedValue = function.apply(value);
                            }

                            if (returnedValue instanceof Optional) {
                                returnedValue = ObjectUtil.unwrap(returnedValue);
                            }

                            if (returnedValue == null) {
                                return null;

                            } else if (returnedValue instanceof Character
                                    || returnedValue.getClass() == char.class) {
                                valueToProcess = (Character) returnedValue;

                            } else {
                                objectDTO.valueToProcess = returnedValue;
                                return object2String(objectDTO);
                            }

                        }

                    } catch (Exception e) {
                    }
                }

                if (valueToProcess != null) {
                    return Character.toString(valueToProcess); // String.valueOf(valueToProcess);
                }

            } catch (Exception ex) {
                //ex.printStackTrace();
            }
        }
    }

    return character2JsonDefault(objectDTO);
}

From source file:com.zimbra.cs.account.ldap.LdapProvisioning.java

/**
 * called to check password strength. Should pass in either an Account, or Cos/Attributes (during creation).
 *
 * @param password/*www.  j a v a  2 s. c om*/
 * @param acct
 * @param cos
 * @param attrs
 * @throws ServiceException
 */
private void checkPasswordStrength(String password, Account acct, Cos cos, ZMutableEntry entry)
        throws ServiceException {
    int minLength = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinLength, 0);
    if (minLength > 0 && password.length() < minLength) {
        throw AccountServiceException.INVALID_PASSWORD("too short",
                new Argument(Provisioning.A_zimbraPasswordMinLength, minLength, Argument.Type.NUM));
    }

    int maxLength = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMaxLength, 0);
    if (maxLength > 0 && password.length() > maxLength) {
        throw AccountServiceException.INVALID_PASSWORD("too long",
                new Argument(Provisioning.A_zimbraPasswordMaxLength, maxLength, Argument.Type.NUM));
    }

    int minUpperCase = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinUpperCaseChars, 0);
    int minLowerCase = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinLowerCaseChars, 0);
    int minNumeric = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinNumericChars, 0);
    int minPunctuation = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinPunctuationChars, 0);
    int minAlpha = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinAlphaChars, 0);
    int minNumOrPunc = getInt(acct, cos, entry, Provisioning.A_zimbraPasswordMinDigitsOrPuncs, 0);

    String allowedChars = getString(acct, cos, entry, Provisioning.A_zimbraPasswordAllowedChars);
    Pattern allowedCharsPattern = null;
    if (allowedChars != null) {
        try {
            allowedCharsPattern = Pattern.compile(allowedChars);
        } catch (PatternSyntaxException e) {
            throw AccountServiceException.INVALID_PASSWORD(
                    Provisioning.A_zimbraPasswordAllowedChars + " is not valid regex: " + e.getMessage());
        }
    }
    String allowedPuncChars = getString(acct, cos, entry, Provisioning.A_zimbraPasswordAllowedPunctuationChars);
    Pattern allowedPuncCharsPattern = null;
    if (allowedPuncChars != null) {
        try {
            allowedPuncCharsPattern = Pattern.compile(allowedPuncChars);
        } catch (PatternSyntaxException e) {
            throw AccountServiceException.INVALID_PASSWORD(Provisioning.A_zimbraPasswordAllowedPunctuationChars
                    + " is not valid regex: " + e.getMessage());
        }
    }

    boolean hasPolicies = minUpperCase > 0 || minLowerCase > 0 || minNumeric > 0 || minPunctuation > 0
            || minAlpha > 0 || minNumOrPunc > 0 || allowedCharsPattern != null
            || allowedPuncCharsPattern != null;

    if (!hasPolicies) {
        return;
    }

    int upper = 0;
    int lower = 0;
    int numeric = 0;
    int punctuation = 0;
    int alpha = 0;

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

        if (allowedCharsPattern != null) {
            if (!allowedCharsPattern.matcher(Character.toString(ch)).matches()) {
                throw AccountServiceException.INVALID_PASSWORD(ch + " is not an allowed character",
                        new Argument(Provisioning.A_zimbraPasswordAllowedChars, allowedChars,
                                Argument.Type.STR));
            }
        }

        boolean isAlpha = true;
        if (Character.isUpperCase(ch)) {
            upper++;
        } else if (Character.isLowerCase(ch)) {
            lower++;
        } else if (Character.isDigit(ch)) {
            numeric++;
            isAlpha = false;
        } else if (allowedPuncCharsPattern != null) {
            if (allowedPuncCharsPattern.matcher(Character.toString(ch)).matches()) {
                punctuation++;
                isAlpha = false;
            }
        } else if (isAsciiPunc(ch)) {
            punctuation++;
            isAlpha = false;
        }
        if (isAlpha) {
            alpha++;
        }
    }

    if (upper < minUpperCase) {
        throw AccountServiceException.INVALID_PASSWORD("not enough upper case characters",
                new Argument(Provisioning.A_zimbraPasswordMinUpperCaseChars, minUpperCase, Argument.Type.NUM));
    }
    if (lower < minLowerCase) {
        throw AccountServiceException.INVALID_PASSWORD("not enough lower case characters",
                new Argument(Provisioning.A_zimbraPasswordMinLowerCaseChars, minLowerCase, Argument.Type.NUM));
    }
    if (numeric < minNumeric) {
        throw AccountServiceException.INVALID_PASSWORD("not enough numeric characters",
                new Argument(Provisioning.A_zimbraPasswordMinNumericChars, minNumeric, Argument.Type.NUM));
    }
    if (punctuation < minPunctuation) {
        throw AccountServiceException.INVALID_PASSWORD("not enough punctuation characters", new Argument(
                Provisioning.A_zimbraPasswordMinPunctuationChars, minPunctuation, Argument.Type.NUM));
    }
    if (alpha < minAlpha) {
        throw AccountServiceException.INVALID_PASSWORD("not enough alpha characters",
                new Argument(Provisioning.A_zimbraPasswordMinAlphaChars, minAlpha, Argument.Type.NUM));
    }
    if (numeric + punctuation < minNumOrPunc) {
        throw AccountServiceException.INVALID_PASSWORD("not enough numeric or punctuation characters",
                new Argument(Provisioning.A_zimbraPasswordMinDigitsOrPuncs, minNumOrPunc, Argument.Type.NUM));
    }
}