Package org.apache.xindice.xml

Examples of org.apache.xindice.xml.XMLCompressedInput


      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();
         /* TODO why is it used for? byte signature = */ in.readSignature();
         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


         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
            /* TODO why is it used for? int size = */ xci.readInt();

            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);
            nodeValue = value.substring(i+1);
View Full Code Here

         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
            if ( getNodeType() == TEXT_NODE)
               xci.readContentSize();
            else
               xci.readInt();

            byte[] buf = new byte[bis.available()];
            xci.read(buf);
            nodeValue = new String(buf, "UTF-8");
         }
      }
      catch ( Exception e ) {
         if (log.isDebugEnabled()) {
View Full Code Here

      }
   }

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

      if ( getNodeType() == Node.ELEMENT_NODE ) {
         // Have to skip the attributes
         in.readSignature();
         in.readContentSize();
         in.readShort();             // Element Symbol
         int attrCount = in.readAttributeCount();
         for ( int i = 0 ; i < attrCount; i++ ) {
            in.readShort();          // Attribute Symbol
            in.skip(in.readShort()); // Attribute Length
         }
      }
      else {
         in.readInt();
      }

      while ( bis.available() > 0 ) {
         int pos = bis.getPos();
         /* TODO why is it used for? byte signature = */ in.readSignature();
         int len = in.readContentSize();
         if ( len == 0 )
            len = 1;

         switch ( in.getNodeType() ) {

            case Node.ELEMENT_NODE:
               childNodes.add(new ElementImpl(this, data, pos, len));
               break;

View Full Code Here

         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

            symbolID = in.readShort();
            SymbolTable.SymbolInfo si = st.getSymbolInfo(symbolID);
            nodeName = si.getQName();
            nsURI = si.getNamespaceURI();

            loadChildren(st);
View Full Code Here

      }
   }

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

      in.readSignature();
      in.readContentSize();
      /* TODO why is it used for? short elemSymbol = */ in.readShort();
      int attrCount = in.readAttributeCount();

      for ( int i = 0 ; i < attrCount; i++ ) {
         short symbol = in.readShort();
         short strLen = in.readShort();
         byte[] b = new byte[strLen];
         in.read(b);
         SymbolTable.SymbolInfo si = st.getSymbolInfo(symbol);
         String name = si.getQName();
         String nsURI = si.getNamespaceURI();
         AttrImpl attr = new AttrImpl(this, name, nsURI, symbol, new String(b, "UTF-8"));
         attributes.setNamedItem(attr);
View Full Code Here

         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 ) {

               case Signatures.EntUnknown:
                  nodeName = null;
                  break;

               case Signatures.EntDefined:
                  symbolID = xci.readShort();
                  nodeName = st.getName(symbolID);
                  break;

               case Signatures.EntAmp:
                  nodeName = "&amp;";
View Full Code Here

            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
                if (getNodeType() == TEXT_NODE) {
                    xci.readContentSize();
                } else {
                    xci.readInt();
                }

                byte[] buf = new byte[bis.available()];
                xci.read(buf);
                nodeValue = new String(buf, "UTF-8");
            }
        } catch (Exception e) {
            if (log.isWarnEnabled()) {
                log.warn("ignored exception", e);
View Full Code Here

            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

                symbolID = in.readShort();
                SymbolTable.SymbolInfo si = st.getSymbolInfo(symbolID);
                nodeName = si.getQName();
                nsURI = si.getNamespaceURI();

                loadChildren(st);
View Full Code Here

        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?
        int attrCount = in.readAttributeCount();

        for (int i = 0; i < attrCount; i++) {
            short symbol = in.readShort();
            short strLen = in.readShort();
            byte[] b = new byte[strLen];
            in.read(b);
            SymbolTable.SymbolInfo si = st.getSymbolInfo(symbol);
            String name = si.getQName();
            String nsURI = si.getNamespaceURI();
            AttrImpl attr = new AttrImpl(this, name, nsURI, symbol, new String(b, "UTF-8"));
            attributes.setNamedItem(attr);
View Full Code Here

TOP

Related Classes of org.apache.xindice.xml.XMLCompressedInput

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.