Examples of ByteArrayInput


Examples of org.apache.xindice.util.ByteArrayInput

        try {
            if (data != null) {
                DocumentImpl doc = (DocumentImpl) getOwnerDocument();
                SymbolTable st = doc.getSymbols();

                ByteArrayInput bis = new ByteArrayInput(data, pos, len);
                XMLCompressedInput xci = new XMLCompressedInput(bis, st);

                xci.readSignature(); // Skip The Signature
                xci.readInt(); // Skip size

                byte[] buf = new byte[bis.available()];
                xci.read(buf);

                String value = new String(buf, "UTF-8");
                int i = value.indexOf(' ');
                nodeName = value.substring(0, i);
View Full Code Here

Examples of org.apache.xindice.util.ByteArrayInput

    private final boolean isNSAttr(final String qName) {
        return (("xmlns".equals(qName)) || qName.startsWith("xmlns:"));
    }

    public boolean processContainer(boolean element, int pos, int len) throws IOException, SAXException {
        ByteArrayInput bis = new ByteArrayInput(data, pos, len);
        XMLCompressedInput in = new XMLCompressedInput(bis, symbols);
        String elemName = null;
        String localName = null;
        String nsURI = null;
        String[] mappedPrefixes = null;
        int nsMapCount = 0;

        if (element) {
            in.readSignature();
            in.readContentSize();

            short elemSymbol = in.readShort();
            elemName = symbols.getName(elemSymbol);
            localName = getLocalName(elemName);
            nsURI = symbols.getNamespaceURI(elemSymbol);
            int attrCount = in.readAttributeCount();
            AttributesImpl attrs = new AttributesImpl();
            for (int i = 0; i < attrCount; i++) {
                short symbol = in.readShort();
                short strLen = in.readShort();
                byte[] b = new byte[strLen];
                in.read(b);

                String attrName = symbols.getName(symbol);
                String attrURI = symbols.getNamespaceURI(symbol);
                String lclName = getLocalName(attrName);

                String attrValue = new String(b, "UTF8");

                // look for and buffer newly mapped namespace prefixes
                if (isNSAttr(attrName)) {

                    // create the buffer if needed
                    if (mappedPrefixes == null) {
                        mappedPrefixes = new String[XMLNS_MAP_INCREMENT];

                    }

                    // check the buffer's capacity
                    if (nsMapCount >= mappedPrefixes.length) {
                        String[] newBuf = new String[mappedPrefixes.length + XMLNS_MAP_INCREMENT];
                        System.arraycopy(mappedPrefixes, 0, newBuf, 0, mappedPrefixes.length);
                        mappedPrefixes = newBuf;
                    }

                    // The prefix is the attr "local name", unless this is the
                    // default namespace, in which case the prefix is the empty
                    // string
                    String prefix = ("xmlns".equals(attrName) ? "" : lclName);

                    // Prefix mappings MAY always be reported, regardless of
                    // feature settings.
                    content.startPrefixMapping(prefix, attrValue);
                    mappedPrefixes[nsMapCount++] = prefix;

                    if (hasSaxNamespacesPrefixes) {
                        // According to SAX, the local name should be EMPTY
                        attrs.addAttribute("", "", attrName, "CDATA", attrValue);
                    }
                } else {
                    // Regular attribute
                    attrs.addAttribute(attrURI != null ? attrURI : "",
                                       lclName, attrName, "", attrValue);
                }
            }

            if (comp != null) {
                comp.symbolID(elemSymbol);
                comp.dataLocation(pos, len);
            }
            content.startElement(nsURI != null ? nsURI : "", localName, elemName, attrs);
        } else {
            in.readInt();
        }

        while (!interrupt && bis.available() > 0) {
            pos = bis.getPos();
            in.readSignature(); // Read signature
            len = in.readContentSize();
            if (len == 0) {
                len = 1;
            }

            int type = in.getNodeType();
            switch (type) {

                case Node.ELEMENT_NODE:
                    processContainer(true, pos, len);
                    break;

                case Node.TEXT_NODE:
                case Node.PROCESSING_INSTRUCTION_NODE:
                case Node.CDATA_SECTION_NODE:
                case Node.COMMENT_NODE:
                    {

                        ByteArrayInput tbis = new ByteArrayInput(data, pos, len);
                        XMLCompressedInput tin = new XMLCompressedInput(tbis, symbols);

                        tin.readSignature(); // Skip The Signature
                        if (type == Node.TEXT_NODE) {
                            tin.readContentSize();
                        } else {
                            tin.readInt();
                        }
                       
                        byte[] buf = new byte[tbis.available()];
                        tin.read(buf);

                        String value = new String(buf, "UTF-8");

                        switch (type) {
View Full Code Here

Examples of org.apache.xindice.util.ByteArrayInput

        try {
            if (data != null) {
                DocumentImpl doc = (DocumentImpl) getOwnerDocument();
                SymbolTable st = doc.getSymbols();

                ByteArrayInput bis = new ByteArrayInput(data, pos, len);
                XMLCompressedInput in = new XMLCompressedInput(bis, st);

                in.readSignature(); // Skip The Signature
                in.readContentSize(); // Skip The Content Size
View Full Code Here

Examples of org.apache.xindice.util.ByteArrayInput

        return result;
    }

    protected void loadAttributes(SymbolTable st) throws IOException {
        ByteArrayInput bis = new ByteArrayInput(data, pos, len);
        XMLCompressedInput in = new XMLCompressedInput(bis, st);

        in.readSignature();
        in.readContentSize();
        in.readShort(); // Some "elemSymbol" - symbol ID?
View Full Code Here

Examples of org.apache.xindice.util.ByteArrayInput

        try {
            if (data != null) {
                DocumentImpl doc = (DocumentImpl) getOwnerDocument();
                SymbolTable st = doc.getSymbols();

                ByteArrayInput bis = new ByteArrayInput(data, pos, len);
                XMLCompressedInput xci = new XMLCompressedInput(bis, st);

                byte signature = xci.readByte();
                byte entityType = (byte) (signature & 0x1F);
                switch (entityType) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.