Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. 
   * See the copyright.txt in the distribution for a full listing 
   * of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  * 
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 package com.arjuna.mw.wst.common;
 
 
Utility class for SOAP.

Author(s):
kevin
 
 public class SOAPUtil
 {
    
Get an iterator containing just child elements.

Parameters:
soapElement The parent soap element.
Returns:
The iterator of SOAPElements.
 
     public static Iterator getChildElements(final SOAPElement soapElement)
     {
         return new SOAPElementIterator(soapElement.getChildElements()) ;
     }
    
    
An iterator class that skips any nodes which are not SOAPElements.

Author(s):
kevin
 
     private static final class SOAPElementIterator implements Iterator
     {
        
The wrapped iterator.
 
         private final Iterator elementIter ;
        
The current object.
 
         private Object current ;
        
        
Construct the iterator.

Parameters:
elementIter The iterator being wrapped.
 
         SOAPElementIterator(final Iterator elementIter)
         {
             this. = elementIter ;
         }
        
        
Are there any more elements?

Returns:
true if the iterator has more elements, false otherwise.
 
         public boolean hasNext()
         {
             checkCurrent() ;
             return ( != null) ;
         }
        
        
Get the next element.

Returns:
the next element.
Throws:
java.util.NoSuchElementException if there are no more elements.
 
         public Object next()
             throws NoSuchElementException
         {
             checkCurrent() ;
             if ( == null)
             {
                 throw new NoSuchElementException("No more elements in iterator") ;
             }
             final Object result =  ;
              = null ;
             return result ;
         }
        
        
Remove the current object.  This method is not supported on this iterator.

Throws:
java.lang.UnsupportedOperationException if not supported.
java.lang.IllegalStateException if the next method has not been called or remove has already been called on the current element.
        public void remove()
            throws UnsupportedOperationException
        {
            throw new UnsupportedOperationException("Remove not supported on this iterator") ;
        }
        
        
Check the current element.
        private void checkCurrent()
        {
            if ( == null)
            {
                while (.hasNext())
                {
                    final Object  next = .next() ;
                    if (next instanceof SOAPElement)
                    {
                         = next ;
                        break ;
                    }
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X