Package java.lang

Examples of java.lang.CharSequence


        public boolean areEqual(Object o1, Object o2) {
            if ((o1 instanceof String) && (o2 instanceof String))
                return o1.equals(o2);
            if ((o1 instanceof CharSequence) && (o2 instanceof String)) {
                final CharSequence csq = (CharSequence) o1;
                final String str = (String) o2;
                final int length = str.length();
                if (csq.length() != length)
                    return false;
                for (int i = 0; i < length;) {
                    if (str.charAt(i) != csq.charAt(i++))
                        return false;
                }
                return true;
            }
            if ((o1 instanceof String) && (o2 instanceof CharSequence)) {
                final CharSequence csq = (CharSequence) o2;
                final String str = (String) o1;
                final int length = str.length();
                if (csq.length() != length)
                    return false;
                for (int i = 0; i < length;) {
                    if (str.charAt(i) != csq.charAt(i++))
                        return false;
                }
                return true;
            }
            if ((o1 == null) || (o2 == null))
                return o1 == o2;
            final CharSequence csq1 = (CharSequence) o1;
            final CharSequence csq2 = (CharSequence) o2;
            final int length = csq1.length();
            if (csq2.length() != length)
                return false;
            for (int i = 0; i < length;) {
                if (csq1.charAt(i) != csq2.charAt(i++))
                    return false;
            }
            return true;
        }
View Full Code Here


            if (left instanceof String) {
                if (right instanceof String)
                    return ((String) left).compareTo((String) right);
                // Right must be a CharSequence.
                String seq1 = (String) left;
                CharSequence seq2 = (CharSequence) right;
                int i = 0;
                int n = Math.min(seq1.length(), seq2.length());
                while (n-- != 0) {
                    char c1 = seq1.charAt(i);
                    char c2 = seq2.charAt(i++);
                    if (c1 != c2)
                        return c1 - c2;
                }
                return seq1.length() - seq2.length();
            }
            if (right instanceof String)
                return -compare(right, left);

            // Both are CharSequence.
            CharSequence seq1 = (CharSequence) left;
            CharSequence seq2 = (CharSequence) right;
            int i = 0;
            int n = Math.min(seq1.length(), seq2.length());
            while (n-- != 0) {
                char c1 = seq1.charAt(i);
                char c2 = seq2.charAt(i++);
                if (c1 != c2)
                    return c1 - c2;
            }
            return seq1.length() - seq2.length();
        }
View Full Code Here

            return (_attributes != null ? _attributes.getLength() : 0);
        }

        // Implements Attributes
        public String getURI(int index) {
            CharSequence chars = (_attributes != null ? _attributes.getURI(index) : null);
            return (chars != null ? chars.toString() : "");
        }
View Full Code Here

            return (chars != null ? chars.toString() : "");
        }

        // Implements Attributes
        public String getLocalName(int index) {
            CharSequence chars = (_attributes != null ? _attributes.getLocalName(index) : null);
            return (chars != null ? chars.toString() : "");
        }
View Full Code Here

            return (chars != null ? chars.toString() : "");
        }

        // Implements Attributes
        public String getQName(int index) {
            CharSequence chars = (_attributes != null ? _attributes.getQName(index) : null);
            return (chars != null ? chars.toString() : "");
        }
View Full Code Here

            return (_attributes != null ? _attributes.getType(index).toString() : null);
        }

        // Implements Attributes
        public String getValue(int index) {
            CharSequence chars = (_attributes != null ? _attributes.getValue(index) : null);
            return (chars != null ? chars.toString() : null);
        }
View Full Code Here

            return 1;
        }

        // Searches user defined entities.
        _tmp.setArray(buffer, start + 1, length - 2);
        CharSequence replacementText = (_entitiesMapping != null) ?
                (CharSequence) _entitiesMapping.get(_tmp) : null;
        if (replacementText == null)
            throw new XMLStreamException("Entity " + _tmp + " not recognized");
        int replacementTextLength = replacementText.length();
        for (int i = 0; i < replacementTextLength; i++) {
            buffer[start + i] = replacementText.charAt(i);
        }
        return replacementTextLength;
    }
View Full Code Here

        // Sets the maximum length for replacement text.
        Collection values = entityToReplacementText.values();
        if (values instanceof FastCollection) { // Avoids allocating iterators.
             FastCollection fc = (FastCollection) values;
             for (Record r=fc.head(), t=fc.tail(); (r = r.getNext())!= t;) {
                 CharSequence value = (CharSequence) fc.valueOf(r);
                 if (_maxLength < value.length()) {
                     _maxLength = value.length();
                 }
             }
        } else {
            for (Iterator i=values.iterator(); i.hasNext();) {
                CharSequence value = (CharSequence) i.next();
                if (_maxLength < value.length()) {
                    _maxLength = value.length();
                }
            }
        }
        _entitiesMapping = entityToReplacementText;
    }
View Full Code Here

            return (_attributes != null ? _attributes.getLength() : 0);
        }

        // Implements Attributes
        public String getURI(int index) {
            CharSequence chars = (_attributes != null ? _attributes
                    .getURI(index) : null);
            return (chars != null ? chars.toString() : "");
        }
View Full Code Here

            return (chars != null ? chars.toString() : "");
        }

        // Implements Attributes
        public String getLocalName(int index) {
            CharSequence chars = (_attributes != null ? _attributes
                    .getLocalName(index) : null);
            return (chars != null ? chars.toString() : "");
        }
View Full Code Here

TOP

Related Classes of java.lang.CharSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.