Package javolution.text

Examples of javolution.text.CharArray


            if (((_isRepairingNamespaces && (i < i1) && !_namespaces._prefixesWritten[i]))
                    || ((i >= i1) && _namespaces._prefixesWritten[i])) { // Write namespace.

                // In repairing mode, removes redondancy.
                if (_isRepairingNamespaces) {
                    CharArray prefix = _namespaces.getPrefix(
                            _namespaces._namespaces[i], i);
                    if (_namespaces._prefixes[i].equals(prefix))
                        continue; // Not necessary.
                } // Direct mode, just write them as requested (no check).
View Full Code Here


    }

    // Returns the prefix for the specified namespace.
    private CharSequence getRepairedPrefix(CharSequence prefix,
            CharSequence namespaceURI) throws XMLStreamException {
        CharArray prefixForURI = _namespaces.getPrefix(namespaceURI);
        if ((prefixForURI != null)
                && ((prefix == null) || prefixForURI.equals(prefix)))
            return prefixForURI; // No repair needed.
        if ((prefix == null) || (prefix.length() == 0)) { // Creates new prefix.
            prefix = _autoPrefix.clear().append(_repairingPrefix).append(
                    _autoNSCount++);
        }
View Full Code Here

                uri, _namespacesCount[_nesting]);
    }

    CharArray getPrefix(CharSequence uri, int count) {
        for (int i = count; --i >= 0;) {
            CharArray prefix = _prefixes[i];
            CharArray namespace = _namespaces[i];
            if (namespace.equals(uri)) { // Find matching uri.
                // Checks that the prefix has not been overwriten after being set.
                boolean isPrefixOverwritten = false;
                for (int j = i + 1; j < count; j++) {
                    if (prefix.equals(_prefixes[j])) {
                        isPrefixOverwritten = true;
View Full Code Here

    void setPrefix(final CharSequence prefix, CharSequence uri,
            boolean isWritten) {
        final int index = _namespacesCount[_nesting];
        _prefixesWritten[index] = isWritten;
        final int prefixLength = prefix.length();
        CharArray prefixTmp = _prefixesTmp[index];
        if ((prefixTmp == null)
                || (prefixTmp.array().length < prefixLength)) {
            MemoryArea.getMemoryArea(this).executeInArea(new Runnable() {
                public void run() {
                    _prefixesTmp[index] = new CharArray().setArray(new char[prefixLength + 32], 0, 0);
                }
            });
            prefixTmp = _prefixesTmp[index];
        }
        for (int i = 0; i < prefixLength; i++) {
            prefixTmp.array()[i] = prefix.charAt(i);
        }
        prefixTmp.setArray(prefixTmp.array(), 0, prefixLength);

        final int uriLength = uri.length();
        CharArray namespaceTmp = _namespacesTmp[index];
        if ((namespaceTmp == null)
                || (namespaceTmp.array().length < uriLength)) {
            MemoryArea.getMemoryArea(this).executeInArea(new Runnable() {
                public void run() {
                    _namespacesTmp[index] = new CharArray().setArray(new char[uriLength + 32], 0, 0);
                }
            });
            namespaceTmp = _namespacesTmp[index];
        }
        for (int i = 0; i < uriLength; i++) {
            namespaceTmp.array()[i] = uri.charAt(i);
        }
        namespaceTmp.setArray(namespaceTmp.array(), 0, uriLength);
       
        // Sets the prefix using CharArray instances.
        setPrefix(prefixTmp, namespaceTmp);
    }
View Full Code Here

        if (uri == null)
            throw new IllegalArgumentException(
                    "null namespace URI is not allowed");
        for (int i = 0; i < _length; i++) {
            if (_localNames[i].equals(localName)) {
                CharArray ns = _namespaces.getNamespaceURINullAllowed(_prefixes[i]);
                if ((ns != null) && ns.equals(uri))
                    return i;
            }
        }
        return -1;
    }
View Full Code Here

            txt.getChars(index, index + count, cbuf, off);
        } else if (csq instanceof TextBuilder) {
            TextBuilder tb = (TextBuilder) csq;
            tb.getChars(index, index + count, cbuf, off);
        } else if (csq instanceof CharArray) {
            CharArray ca = (CharArray) csq;
            System.arraycopy(ca.array(), index + ca.offset(), cbuf, off, count);
        } else { // Generic CharSequence.
            for (int i = off, n = off + count, j = index; i < n;) {
                cbuf[i++] = input.charAt(j++);
            }
        }
View Full Code Here

     * @return the referenced object or <code>null</code> if the specified
     *         XML input does not have a reference attribute.
     */
    public Object readReference(XMLFormat.InputElement xml)
            throws XMLStreamException {
        CharArray value = xml._reader.getAttributeValue(_refURI, _refName);
        if (value == null)
            return null;
        int ref = value.toInt();
        if (ref >= _idToObject.size())
            throw new XMLStreamException("Reference: " + value + " not found");
        return _idToObject.get(ref);
    }
View Full Code Here

     * @param  obj the object being referenced.
     * @param  xml the input XML element holding the reference identifier.
     */
    public void createReference(Object obj, XMLFormat.InputElement xml)
            throws XMLStreamException {
        CharArray value = xml._reader.getAttributeValue(_idURI, _idName);
        if (value == null)
            return;
        int i = value.toInt();
        if (_idToObject.size() != i)
            throw new XMLStreamException("Identifier discontinuity detected "
                    + "(expected " + _idToObject.size() + " found " + i + ")");
        _idToObject.add(obj);
    }
View Full Code Here

         * getStreamReader().getElementText()}).
         *
         * @return the element text content or an empty sequence if none.
         */
        public CharArray getText() throws XMLStreamException {
            CharArray txt = _reader.getElementText();
            _isReaderAtNext = true; // End element is next.
            return txt;
        }
View Full Code Here

         * @return the value for the specified attribute or
         *         the <code>defaultValue</code> if the attribute is not found.
         */
        public String getAttribute(String name, String defaultValue)
                throws XMLStreamException {
            CharArray value = getAttribute(name);
            return (value != null) ? value.toString() : defaultValue;
        }
View Full Code Here

TOP

Related Classes of javolution.text.CharArray

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.