Here you can find the source of getRoot(SOAPElement e)
Parameter | Description |
---|---|
e | a parameter |
public static SOAPElement getRoot(SOAPElement e)
//package com.java2s; /**/*from w w w . j a v a2 s . c o m*/ * WS-Attacker - A Modular Web Services Penetration Testing Framework Copyright * (C) 2010 Christian Mainka * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.util.ArrayList; import java.util.List; import javax.xml.soap.SOAPElement; public class Main { /** * Returns the root element of e * * @param e * @return */ public static SOAPElement getRoot(SOAPElement e) { List<SOAPElement> parents = getParents(e); int size = parents.size(); if (size > 0) { return parents.get(size - 1); } else { return e; } } /** * Returns a list of all parents of a SOAPElement The first element of the list is the father of e, the second the * grand-father and so on. Last element is always the root. * * @param e * @return */ public static List<SOAPElement> getParents(SOAPElement e) { // searching all parent nodes List<SOAPElement> parents = new ArrayList<SOAPElement>(); SOAPElement zwerg = e.getParentElement(); while (zwerg != null) { parents.add(zwerg); zwerg = zwerg.getParentElement(); } return parents; } }