jjg@589: /* jjg@589: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. jjg@589: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@589: * jjg@589: * This code is free software; you can redistribute it and/or modify it jjg@589: * under the terms of the GNU General Public License version 2 only, as jjg@589: * published by the Free Software Foundation. Oracle designates this jjg@589: * particular file as subject to the "Classpath" exception as provided jjg@589: * by Oracle in the LICENSE file that accompanied this code. jjg@589: * jjg@589: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@589: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@589: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@589: * version 2 for more details (a copy is included in the LICENSE file that jjg@589: * accompanied this code). jjg@589: * jjg@589: * You should have received a copy of the GNU General Public License version jjg@589: * 2 along with this work; if not, write to the Free Software Foundation, jjg@589: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@589: * jjg@589: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@589: * or visit www.oracle.com if you need additional information or have any jjg@589: * questions. jjg@589: */ jjg@589: jjg@589: package com.sun.tools.doclets.internal.toolkit.builders; jjg@589: jjg@589: import java.util.ArrayList; jjg@589: import java.util.HashMap; jjg@589: import java.util.List; jjg@589: import java.util.Map; jjg@589: jjg@589: /** jjg@589: * Simple class to represent the attribute and elements of an XML node. jjg@589: */ jjg@589: public class XMLNode { jjg@589: XMLNode(XMLNode parent, String qname) { jjg@589: this.parent = parent; jjg@589: name = qname; jjg@589: attrs = new HashMap(); jjg@589: children = new ArrayList(); jjg@589: jjg@589: if (parent != null) jjg@589: parent.children.add(this); jjg@589: } jjg@589: jjg@589: @Override jjg@589: public String toString() { jjg@589: StringBuilder sb = new StringBuilder(); jjg@589: sb.append("<"); jjg@589: sb.append(name); jjg@589: for (Map.Entry e: attrs.entrySet()) jjg@589: sb.append(" " + e.getKey() + "=\"" + e.getValue() + "\""); jjg@589: if (children.size() == 0) jjg@589: sb.append("/>"); jjg@589: else { jjg@589: sb.append(">"); jjg@589: for (XMLNode c: children) jjg@589: sb.append(c.toString()); jjg@589: sb.append(""); jjg@589: } jjg@589: return sb.toString(); jjg@589: } jjg@589: jjg@589: final XMLNode parent; jjg@589: final String name; jjg@589: final Map attrs; jjg@589: final List children; jjg@589: }