src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java

Wed, 18 Sep 2013 17:13:26 -0700

author
bpatel
date
Wed, 18 Sep 2013 17:13:26 -0700
changeset 2035
a2a5ad0853ed
parent 1359
25e14ad23cef
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8015249: javadoc fails to document static final fields in annotation types
Reviewed-by: jjg

jjg@589 1 /*
jjg@1359 2 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
jjg@589 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@589 4 *
jjg@589 5 * This code is free software; you can redistribute it and/or modify it
jjg@589 6 * under the terms of the GNU General Public License version 2 only, as
jjg@589 7 * published by the Free Software Foundation. Oracle designates this
jjg@589 8 * particular file as subject to the "Classpath" exception as provided
jjg@589 9 * by Oracle in the LICENSE file that accompanied this code.
jjg@589 10 *
jjg@589 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@589 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@589 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@589 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@589 15 * accompanied this code).
jjg@589 16 *
jjg@589 17 * You should have received a copy of the GNU General Public License version
jjg@589 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@589 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@589 20 *
jjg@589 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@589 22 * or visit www.oracle.com if you need additional information or have any
jjg@589 23 * questions.
jjg@589 24 */
jjg@589 25
jjg@589 26 package com.sun.tools.doclets.internal.toolkit.builders;
jjg@589 27
jjg@589 28 import java.util.ArrayList;
jjg@589 29 import java.util.HashMap;
jjg@589 30 import java.util.List;
jjg@589 31 import java.util.Map;
jjg@589 32
jjg@589 33 /**
jjg@589 34 * Simple class to represent the attribute and elements of an XML node.
jjg@1359 35 *
jjg@1359 36 * <p><b>This is NOT part of any supported API.
jjg@1359 37 * If you write code that depends on this, you do so at your own risk.
jjg@1359 38 * This code and its internal interfaces are subject to change or
jjg@1359 39 * deletion without notice.</b>
jjg@589 40 */
jjg@589 41 public class XMLNode {
jjg@589 42 XMLNode(XMLNode parent, String qname) {
jjg@589 43 this.parent = parent;
jjg@589 44 name = qname;
jjg@589 45 attrs = new HashMap<String,String>();
jjg@589 46 children = new ArrayList<XMLNode>();
jjg@589 47
jjg@589 48 if (parent != null)
jjg@589 49 parent.children.add(this);
jjg@589 50 }
jjg@589 51
jjg@589 52 @Override
jjg@589 53 public String toString() {
jjg@589 54 StringBuilder sb = new StringBuilder();
jjg@589 55 sb.append("<");
jjg@589 56 sb.append(name);
jjg@589 57 for (Map.Entry<String,String> e: attrs.entrySet())
jjg@589 58 sb.append(" " + e.getKey() + "=\"" + e.getValue() + "\"");
jjg@589 59 if (children.size() == 0)
jjg@589 60 sb.append("/>");
jjg@589 61 else {
jjg@589 62 sb.append(">");
jjg@589 63 for (XMLNode c: children)
jjg@589 64 sb.append(c.toString());
jjg@589 65 sb.append("</" + name + ">");
jjg@589 66 }
jjg@589 67 return sb.toString();
jjg@589 68 }
jjg@589 69
jjg@589 70 final XMLNode parent;
jjg@589 71 final String name;
jjg@589 72 final Map<String,String> attrs;
jjg@589 73 final List<XMLNode> children;
jjg@589 74 }

mercurial