⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printfformat.java

📁 一个cms内容管理平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        int getArgumentPosition() {

            return m_argumentPosition;
        }

        /**
         * Internal helper.<p> 
         * 
         * @return the result
         */
        int getArgumentPositionForFieldWidth() {

            return m_argumentPositionForFieldWidth;
        }

        /**
         * Internal helper.<p>
         * 
         * @return the result
         */
        int getArgumentPositionForPrecision() {

            return m_argumentPositionForPrecision;
        }

        /**
         * Get the conversion character that tells what
         * type of control character this instance has.
         *
         * @return the conversion character.
         */
        char getConversionCharacter() {

            return m_conversionCharacter;
        }

        /**
         * Get the String for this instance.  Translate
         * any escape sequences.
         *
         * @return s the stored String.
         */
        String getLiteral() {

            StringBuffer sb = new StringBuffer();
            int i = 0;
            while (i < m_fmt.length()) {
                if (m_fmt.charAt(i) == '\\') {
                    i++;
                    if (i < m_fmt.length()) {
                        char c = m_fmt.charAt(i);
                        switch (c) {
                            case 'a':
                                sb.append((char)0x07);
                                break;
                            case 'b':
                                sb.append('\b');
                                break;
                            case 'f':
                                sb.append('\f');
                                break;
                            case 'n':
                                sb.append(System.getProperty("line.separator"));
                                break;
                            case 'r':
                                sb.append('\r');
                                break;
                            case 't':
                                sb.append('\t');
                                break;
                            case 'v':
                                sb.append((char)0x0b);
                                break;
                            case '\\':
                                sb.append('\\');
                                break;
                            default:
                        // noop
                        }
                        i++;
                    } else {
                        sb.append('\\');
                    }
                } else {
                    i++;
                }
            }
            return m_fmt;
        }

        /**
         * Format a double argument using this conversion
         * specification.
         * @param s the double to format.
         * @return the formatted String.
         * @exception CmsIllegalArgumentException if the
         *     conversion character is c, C, s, S, i, d,
         *     x, X, or o.
         */
        String internalsprintf(double s) throws CmsIllegalArgumentException {

            String s2 = "";
            switch (m_conversionCharacter) {
                case 'f':
                    s2 = printFFormat(s);
                    break;
                case 'E':
                case 'e':
                    s2 = printEFormat(s);
                    break;
                case 'G':
                case 'g':
                    s2 = printGFormat(s);
                    break;
                default:
                    throw new CmsIllegalArgumentException(Messages.get().container(
                        Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2,
                        "double",
                        new Character(m_conversionCharacter)));
            }
            return s2;
        }

        /**
         * Format an int argument using this conversion
         * specification.
         * @param s the int to format.
         * @return the formatted String.
         * @exception CmsIllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(int s) throws CmsIllegalArgumentException {

            String s2 = "";
            switch (m_conversionCharacter) {
                case 'd':
                case 'i':
                    if (m_optionalh) {
                        s2 = printDFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printDFormat((long)s);
                    } else {
                        s2 = printDFormat(s);
                    }
                    break;
                case 'x':
                case 'X':
                    if (m_optionalh) {
                        s2 = printXFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printXFormat((long)s);
                    } else {
                        s2 = printXFormat(s);
                    }
                    break;
                case 'o':
                    if (m_optionalh) {
                        s2 = printOFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printOFormat((long)s);
                    } else {
                        s2 = printOFormat(s);
                    }
                    break;
                case 'c':
                case 'C':
                    s2 = printCFormat((char)s);
                    break;
                default:
                    throw new CmsIllegalArgumentException(Messages.get().container(
                        Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2,
                        "int",
                        new Character(m_conversionCharacter)));
            }
            return s2;
        }

        /**
         * Format a long argument using this conversion
         * specification.
         * @param s the long to format.
         * @return the formatted String.
         * @exception CmsIllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(long s) throws CmsIllegalArgumentException {

            String s2 = "";
            switch (m_conversionCharacter) {
                case 'd':
                case 'i':
                    if (m_optionalh) {
                        s2 = printDFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printDFormat(s);
                    } else {
                        s2 = printDFormat((int)s);
                    }
                    break;
                case 'x':
                case 'X':
                    if (m_optionalh) {
                        s2 = printXFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printXFormat(s);
                    } else {
                        s2 = printXFormat((int)s);
                    }
                    break;
                case 'o':
                    if (m_optionalh) {
                        s2 = printOFormat((short)s);
                    } else if (m_optionall) {
                        s2 = printOFormat(s);
                    } else {
                        s2 = printOFormat((int)s);
                    }
                    break;
                case 'c':
                case 'C':
                    s2 = printCFormat((char)s);
                    break;
                default:
                    throw new CmsIllegalArgumentException(Messages.get().container(
                        Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2,
                        "long",
                        new Character(m_conversionCharacter)));
            }
            return s2;
        }

        /**
         * Format an Object argument using this conversion
         * specification.
         * @param s the Object to format.
         * @return the formatted String.
         * @exception CmsIllegalArgumentException if the
         *     conversion character is neither s nor S.
         */
        String internalsprintf(Object s) throws CmsIllegalArgumentException {

            String s2 = "";
            if (m_conversionCharacter == 's' || m_conversionCharacter == 'S') {
                s2 = printSFormat(s.toString());
            } else {
                throw new CmsIllegalArgumentException(Messages.get().container(
                    Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2,
                    "String",
                    new Character(m_conversionCharacter)));
            }
            return s2;
        }

        /**
         * Format a String argument using this conversion
         * specification.
         * @param s the String to format.
         * @return the formatted String.
         * @exception CmsIllegalArgumentException if the
         *   conversion character is neither s nor S.
         */
        String internalsprintf(String s) throws CmsIllegalArgumentException {

            String s2 = "";
            if (m_conversionCharacter == 's' || m_conversionCharacter == 'S') {
                s2 = printSFormat(s);
            } else {
                throw new CmsIllegalArgumentException(Messages.get().container(
                    Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2,
                    "String",
                    new Character(m_conversionCharacter)));
            }
            return s2;
        }

        /**
         * Internal helper.<p>
         * 
         * @return the result
         */
        boolean isPositionalFieldWidth() {

            return m_positionalFieldWidth;
        }

        /**
         * Internal helper.<p>
         * 
         * @return the result
         */
        boolean isPositionalPrecision() {

            return m_positionalPrecision;
        }

        /**
         * Internal helper.<p> 
         * 
         * @return the result
         */
        boolean isPositionalSpecification() {

            return m_positionalSpecification;
        }

        /**
         * Check whether the specifier has a variable
         * field width that is going to be set by an
         * argument.
         * @return <code>true</code> if the conversion
         *   uses an * field width; otherwise
         *   <code>false</code>.
         */
        boolean isVariableFieldWidth() {

            return m_variableFieldWidth;
        }

        /**
         * Check whether the specifier has a variable
         * precision that is going to be set by an
         * argument.
         * @return <code>true</code> if the conversion
         *   uses an * precision; otherwise
         *   <code>false</code>.
         */
        boolean isVariablePrecision() {

            return m_variablePrecision;
        }

        /**
         * Set the field width with an argument.  A
         * negative field width is taken as a - flag
         * followed by a positive field width.
         * @param fw the field width.
         */
        void setFieldWidthWithArg(int fw) {

            if (fw < 0) {
                m_leftJustify = true;
            }
            m_fieldWidthSet = true;
            m_fieldWidth = Math.abs(fw);
        }

        /**
         * Set the String for this instance.
         * @param s the String to store.
         */
        void setLiteral(String s) {

            m_fmt = s;
        }

        /**
         * Set the precision with an argument.  A

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -