xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eric...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/erictest EricTest.java
Date Tue, 16 Mar 2004 19:35:43 GMT
ericvas     2004/03/16 11:35:43

  Modified:    v2/src/newstore2/org/apache/xmlbeans/impl/newstore2 Cur.java
                        Cursor.java DomImpl.java Public2.java Saver.java
               v2/test/src/erictest EricTest.java
  Log:
  Misc saver/cursor fixes
  
  Revision  Changes    Path
  1.22      +18 -4     xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java
  
  Index: Cur.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Cur.java	16 Mar 2004 01:50:55 -0000	1.21
  +++ Cur.java	16 Mar 2004 19:35:42 -0000	1.22
  @@ -724,10 +724,24 @@
           return true;
       }
   
  -//    int nextChars ( int cch )
  -//    {
  -//        
  -//    }
  +    int nextChars ( int cch )
  +    {
  +        int cchRight = cchRight();
  +
  +        if (cchRight == 0)
  +            return 0;
  +
  +        if (cch < 0 || cch >= cchRight)
  +        {
  +            // Use next to not skip over children
  +            next();
  +            return cchRight;
  +        }
  +
  +        set( _xobj, _pos + cch );
  +        
  +        return cch;
  +    }
   
       void setCharNodes ( CharNode nodes )
       {
  
  
  
  1.10      +6 -4      xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cursor.java
  
  Index: Cursor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cursor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Cursor.java	16 Mar 2004 01:50:55 -0000	1.9
  +++ Cursor.java	16 Mar 2004 19:35:42 -0000	1.10
  @@ -933,13 +933,15 @@
       
       public void _insertChars ( String text )
       {
  -        if (text != null && text.length() > 0)
  +        int l = text == null ? 0 : text.length();
  +        
  +        if (l > 0)
           {
               if (_cur.isRoot() || _cur.isAttr())
                   complain( "Can't insert before the document or an attribute." );
   
  -            _cur.insertChars( text, 0, text.length() );
  -//            _cur.
  +            _cur.insertChars( text, 0, l );
  +            _cur.nextChars( l );
           }
       }
   
  @@ -1014,7 +1016,7 @@
       {
           validateLocalName( target );
   
  -        if (Locale.beginsWithXml( target ))
  +        if (Locale.beginsWithXml( target ) && target.length() == 3)
               throw new IllegalArgumentException( "Target is 'xml'" );
           
           Cur c = _locale.tempCur();
  
  
  
  1.23      +1 -1      xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/DomImpl.java
  
  Index: DomImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/DomImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DomImpl.java	16 Mar 2004 01:50:55 -0000	1.22
  +++ DomImpl.java	16 Mar 2004 19:35:42 -0000	1.23
  @@ -791,7 +791,7 @@
       {
           validateName( target );
           
  -        if (Locale.beginsWithXml( target ))
  +        if (Locale.beginsWithXml( target ) && target.length() == 3)
               throw new NamespaceErr( "Invalid target - is 'xml'" );
           
           Locale l = d.locale();
  
  
  
  1.8       +10 -15    xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Public2.java
  
  Index: Public2.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Public2.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Public2.java	4 Mar 2004 23:56:21 -0000	1.7
  +++ Public2.java	16 Mar 2004 19:35:42 -0000	1.8
  @@ -227,23 +227,18 @@
           c.moveToDom( d );
   
           c.dump();
  -        
  -        for ( ; ; )
  -        {
  -            if (!c.next())
  -                break;
  -            
  -            c.dump();
  -        }
   
  -        for ( ; ; )
  -        {
  -            if (!c.prev())
  -                break;
  -            
  -            c.dump();
  -        }
  +        c.next();
  +        c.next();
  +        c.next();
   
  +        c.dump();
  +        
  +        c.nextChars( -1 );
  +//        c.next();
  +        
  +        c.dump();
  +        
           c.release();
       }
   }
  
  
  
  1.18      +25 -20    xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Saver.java
  
  Index: Saver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Saver.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Saver.java	12 Mar 2004 21:18:18 -0000	1.17
  +++ Saver.java	16 Mar 2004 19:35:42 -0000	1.18
  @@ -283,8 +283,8 @@
               
               start.next();
           }
  -        
  -        return !start.isSamePos( end );
  +
  +        return numDocElems != 1;
       }
   
       protected boolean saveNamespacesFirst ( )
  @@ -2134,22 +2134,29 @@
           boolean toNextAttr    ( ) { assert _txt == null; return _cur.toNextAttr(); }
           String  getAttrValue  ( ) { assert _txt == null; return _cur.getAttrValue(); }
           
  -        void toEnd ( ) { assert _txt == null; _cur.toEnd(); }
  +        void toEnd ( )
  +        {
  +            assert _txt == null;
  +            _cur.toEnd();
  +            
  +            if (_cur.kind() == -ELEM)
  +                _depth--;
  +        }
           
           boolean next ( )
           {
  -            int k = kind();
  +            int k;
               
               if (_txt != null)
               {
                   assert _txt.length() > 0;
                   assert !_cur.isText();
                   _txt = null;
  -                k = kind();
  +                k = _cur.kind();
               }
               else
               {
  -                int prevKind = k;
  +                int prevKind = k = _cur.kind();
   
                   if (!_cur.next())
                       return false;
  @@ -2158,6 +2165,7 @@
   
                   assert _txt == null;
   
  +                // place any text encountered in the buffer
                   if (_cur.isText())
                   {
                       CharUtil.getString( _sb, _cur.getChars(), _cur._offSrc, _cur._cchSrc
);
  @@ -2165,31 +2173,28 @@
                       trim( _sb );
                   }
   
  -                k = kind();
  -
  -                boolean isLeaf =
  -                    prevKind == COMMENT || prevKind == PROCINST ||
  -                        (prevKind == ELEM && k == -ELEM);
  +                k = _cur.kind();
   
  -                if (_sb.length() > 0 && !isLeaf)
  -                {
  -                    _sb.insert( 0, _newLine );
  -                    spaces( _sb, _newLine.length(), _prettyOffset + _prettyIndent * _depth
);
  -                }
  -
  -                if (!isLeaf)
  +                // Check for non leaf
  +                if (prevKind != COMMENT && prevKind != PROCINST && (prevKind
!= ELEM || k != -ELEM))
                   {
  +                    if (_sb.length() > 0)
  +                    {
  +                        _sb.insert( 0, _newLine );
  +                        spaces( _sb, _newLine.length(), _prettyOffset + _prettyIndent *
_depth );
  +                    }
  +                    
                       if (prevKind != ROOT)
                           _sb.append( _newLine );
                       
                       int d = k < 0 ? _depth - 1 : _depth;
                       spaces( _sb, _sb.length(), _prettyOffset + _prettyIndent * d );
                   }
  -                
  +
                   if (_sb.length() > 0)
                   {
                       _txt = _sb.toString();
  -                    k = kind();
  +                    k = TEXT;
                   }
               }
   
  
  
  
  1.37      +6 -17     xml-xmlbeans/v2/test/src/erictest/EricTest.java
  
  Index: EricTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/erictest/EricTest.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- EricTest.java	16 Mar 2004 01:50:55 -0000	1.36
  +++ EricTest.java	16 Mar 2004 19:35:43 -0000	1.37
  @@ -106,30 +106,19 @@
   {
       public static void main ( String[] args ) throws Exception
       {
  -        Document doc = Public2.parse( "<z:foo xmlns:z='uri'>text<z:a>25</z:a></z:foo>"
);
  -
  -        Element e = doc.getDocumentElement();
  -
  -        Attr a = (Attr) e.getAttributes().item( 0 );
  -
  -        Public2.dump( doc );
  -
  -        e.removeAttributeNode( a );
  -
  -        Public2.dump( doc );
  -        
  -
  -        
  +        XmlOptions pp = new XmlOptions();
  +        pp.setSavePrettyPrint();
           
           XmlCursor c = Public2.newStore();
   
           c.toNextToken();
  -        c.insertChars( "abc" );
  -        c.insertElement( "foo" );
  +        c.beginElement( "a" );
  +        c.insertChars( "xyz" );
  +        c.beginElement( "b" );
   
           c.toStartDoc();
   
  -        System.out.println( Public2.save( c ) );
  +        System.out.println( "\"" + Public2.save( c, pp ) + "\"" );
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message