jkesselm    2002/05/31 17:23:23

  Modified:    java/src/org/apache/xml/utils Tag: Xalan3
                        CharacterBlockEnumeration.java
                        FastStringBuffer.java
  Removed:     java/src/org/apache/xml/utils Tag: Xalan3
                        CharacterBlockEnumeration
  Log:
  FastStringBuffer changes for CharacterBlockEnumeration.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +3 -1      
xml-xalan/java/src/org/apache/xml/utils/Attic/CharacterBlockEnumeration.java
  
  Index: CharacterBlockEnumeration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/Attic/CharacterBlockEnumeration.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CharacterBlockEnumeration.java    31 May 2002 20:58:05 -0000      1.1.2.1
  +++ CharacterBlockEnumeration.java    1 Jun 2002 00:23:23 -0000       1.1.2.2
  @@ -90,6 +90,8 @@
        protected int _length;
        protected String _string=null;
        
  +     static final protected char[] EMPTY=new char[0];
  +     
        /** Create an empty enumeration. */
        public CharacterBlockEnumeration()
        {
  @@ -217,7 +219,7 @@
                        if(_string!=null)
                                _chars=_string.toCharArray();
                        else
  -                             _chars=new char[0];
  +                             _chars=EMPTY;
                }
                return _chars;          
        }
  
  
  
  1.19.2.1  +158 -0    
xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java
  
  Index: FastStringBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java,v
  retrieving revision 1.19
  retrieving revision 1.19.2.1
  diff -u -r1.19 -r1.19.2.1
  --- FastStringBuffer.java     22 Apr 2002 19:26:02 -0000      1.19
  +++ FastStringBuffer.java     1 Jun 2002 00:23:23 -0000       1.19.2.1
  @@ -1373,4 +1373,162 @@
       source.m_chunkSize = 1 << (source.m_chunkBits);
       source.m_chunkMask = source.m_chunkSize - 1;
     }
  +
  +     /** Support for DTM2XNI. Rather than push XNI awareness into this class,
  +      * (as we did for SAX in sendSAX*), yield the content in a reasonably
  +      * efficient manner for the caller to pass along.
  +      * */
  +  public CharacterBlockEnumeration enumerateCharacterBlocks(int start, int 
length)
  +  {
  +     return new FSBCharacterBlockEnumeration(start,length);
  +  }
  +  
  +     /** Support for DTM2XNI. Rather than push XNI awareness into this class,
  +      * (as we did for SAX in sendSAX*), yield the content in a reasonably
  +      * efficient manner for the caller to pass along.
  +      * 
  +      * %BUG% %REVIEW% Currently does _NOT_ support inner FSBs.
  +      * We need to either rearchitect those or get rid of 'em...
  +      * */
  +  protected class FSBCharacterBlockEnumeration
  +  extends CharacterBlockEnumeration
  +  {
  +     int f_remaining;
  +     int f_chunk;
  +     
  +     FSBCharacterBlockEnumeration(int start,int length)
  +     {
  +             if(m_innerFSB!=null)
  +                     throw new UnsupportedOperationException("Can't handle 
innerFSBs yet");
  +             
  +             int l=length();
  +             if(start>l)
  +             {
  +                     // Don't start off end -- take that as empty
  +                     _start=_length=f_remaining=0;
  +                     _chars=m_array[0];
  +             }
  +             else
  +             {
  +                     // Don't run off end -- truncate to fit
  +                     l-=start;
  +                     f_remaining = (l>length) ? length : l;
  +                     
  +                     // Set up first chunk
  +                     f_chunk=start>>>m_chunkBits;
  +                     
  +                     _start=start & m_chunkMask;
  +                     
  +                     l=m_chunkSize-start;
  +                     _length = (l>f_remaining) ? f_remaining : l;
  +                     
  +                     f_remaining -= _length;
  +             }
  +     }
  +
  +     /** Not supported in this implementaton */
  +     public FSBCharacterBlockEnumeration()
  +     {
  +             throw new UnsupportedOperationException("Not supported in this 
implementaton");
  +     }
  +     
  +     /** Not supported in this implementaton */
  +     public FSBCharacterBlockEnumeration(String s)
  +     {
  +             throw new UnsupportedOperationException("Not supported in this 
implementaton");
  +     }
  +     
  +     /** Not supported in this implementaton */
  +     public FSBCharacterBlockEnumeration(String s, int start, int length)
  +     {
  +             throw new UnsupportedOperationException("Not supported in this 
implementaton");
  +     }
  +     
  +     /** Not supported in this implementaton */
  +     public FSBCharacterBlockEnumeration(char[] ch)
  +     {
  +             throw new UnsupportedOperationException("Not supported in this 
implementaton");
  +     }
  +
  +     /** Not supported in this implementaton */
  +     public FSBCharacterBlockEnumeration(char[] ch, int start, int length)
  +     {
  +             throw new UnsupportedOperationException("Not supported in this 
implementaton");
  +     }
  +     
  +     /** @return true if another character block can be accessed by calling
  +      * nextElement()
  +      */
  +     public boolean hasMoreElements()
  +     {
  +             return f_remaining>0;
  +     }
  +     
  +     /** Advance to the next character block. 
  +      * 
  +      * @returns either this CharacterBlockEnumeration object (as a
  +      * transient accessor to the "element") or null if no more elements are 
available.
  +      * This is a bit of a kluge, but it allows us to claim that we
  +      * implement the Java Enumeration interface if we want to do so, and
  +      * it seems to be as good or bad as any other return value.
  +      * */
  +     public Object nextElement()
  +     {
  +             if(f_remaining==0)
  +                     return null;
  +                     
  +             // Next chunk
  +             ++f_chunk;
  +             _start=0;
  +             _length = (m_chunkSize>f_remaining) ? f_remaining : m_chunkSize;
  +             f_remaining -= _length;
  +             return this;
  +     }
  +     
  +     
  +     /** @return the starting offset in the current block's character array
  +      * */
  +     public int getStart()
  +     {
  +             return _start;
  +     }
  +
  +     /** @return the length of the the current block
  +      * */
  +     public int getLength()
  +     {
  +             return _length;
  +     }
  +
  +     /** 
  +      * @return the current block's character array. Data will begin at
  +      * offset {start}.
  +      * */
  +     public char[] getChars()
  +     {
  +             char[] ch=(_length>0)
  +                     ? m_array[f_chunk] 
  +                     : EMPTY;
  +             return ch;
  +     }
  +
  +     /** @param target A char[] to be copied into. If a buffer is not 
supplied
  +      * we will create one.
  +      *
  +      * @param targetStart Offset in the target at which copying should 
begin.
  +      * 
  +      * @return the buffer, filled with {length} characters starting at 
offset
  +      * {targetStart}. Characters before or after that block should be 
unaffected.
  +      * */
  +     public char[] getChars(char[] target, int targetStart)
  +     {
  +             if(_length>0)
  +             {
  +                     
System.arraycopy(m_array[f_chunk],_start,target,targetStart,_length);
  +             }
  +                     
  +             return target;
  +     }
  +     
  +  }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to