< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/NamespaceContextIterator.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  72             for (; attributeIndex < attributesLength; ++attributeIndex) {
  73                 Node currentAttribute = attributes.item(attributeIndex);
  74                 String attributeName = currentAttribute.getNodeName();
  75                 if (attributeName.startsWith("xmlns")
  76                     && (attributeName.length() == 5
  77                         || attributeName.charAt(5) == ':')) {
  78                     next = (Attr) currentAttribute;
  79                     ++attributeIndex;
  80                     return;
  81                 }
  82             }
  83             if (traverseStack) {
  84                 context = context.getParentNode();
  85                 findContextAttributes();
  86             } else {
  87                 context = null;
  88             }
  89         }
  90     }
  91 

  92     public boolean hasNext() {
  93         findNext();
  94         return next != null;
  95     }
  96 

  97     public Object next() {
  98         return getNext();
  99     }
 100 
 101     public Attr nextNamespaceAttr() {
 102         return getNext();
 103     }
 104 
 105     protected Attr getNext() {
 106         findNext();
 107         if (next == null) {
 108             throw new NoSuchElementException();
 109         }
 110         last = next;
 111         next = null;
 112         return last;
 113     }
 114 

 115     public void remove() {
 116         if (last == null) {
 117             throw new IllegalStateException();
 118         }
 119         ((Element) context).removeAttributeNode(last);
 120     }
 121 
 122 }
   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  72             for (; attributeIndex < attributesLength; ++attributeIndex) {
  73                 Node currentAttribute = attributes.item(attributeIndex);
  74                 String attributeName = currentAttribute.getNodeName();
  75                 if (attributeName.startsWith("xmlns")
  76                     && (attributeName.length() == 5
  77                         || attributeName.charAt(5) == ':')) {
  78                     next = (Attr) currentAttribute;
  79                     ++attributeIndex;
  80                     return;
  81                 }
  82             }
  83             if (traverseStack) {
  84                 context = context.getParentNode();
  85                 findContextAttributes();
  86             } else {
  87                 context = null;
  88             }
  89         }
  90     }
  91 
  92     @Override
  93     public boolean hasNext() {
  94         findNext();
  95         return next != null;
  96     }
  97 
  98     @Override
  99     public Object next() {
 100         return getNext();
 101     }
 102 
 103     public Attr nextNamespaceAttr() {
 104         return getNext();
 105     }
 106 
 107     protected Attr getNext() {
 108         findNext();
 109         if (next == null) {
 110             throw new NoSuchElementException();
 111         }
 112         last = next;
 113         next = null;
 114         return last;
 115     }
 116 
 117     @Override
 118     public void remove() {
 119         if (last == null) {
 120             throw new IllegalStateException();
 121         }
 122         ((Element) context).removeAttributeNode(last);
 123     }
 124 
 125 }
< prev index next >