1 /* 2 * Copyright (c) 2003, 2019, 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 23 * questions. 24 */ 25 26 package jdk.javadoc.internal.doclets.toolkit.builders; 27 28 import java.util.*; 29 30 import javax.lang.model.element.PackageElement; 31 32 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; 33 import jdk.javadoc.internal.doclets.toolkit.BaseOptions; 34 import jdk.javadoc.internal.doclets.toolkit.DocletException; 35 import jdk.javadoc.internal.doclets.toolkit.Messages; 36 import jdk.javadoc.internal.doclets.toolkit.Resources; 37 import jdk.javadoc.internal.doclets.toolkit.util.Utils; 38 39 40 /** 41 * The superclass for all builders. A builder is a class that provides 42 * the structure and content of API documentation. A builder is completely 43 * doclet independent which means that any doclet can use builders to 44 * construct documentation, as long as it implements the appropriate 45 * writer interfaces. For example, if a doclet wanted to use 46 * {@link ConstantsSummaryBuilder} to build a constant summary, all it has to 47 * do is implement the ConstantsSummaryWriter interface and pass it to the 48 * builder using a WriterFactory. 49 * 50 * <p><b>This is NOT part of any supported API. 51 * If you write code that depends on this, you do so at your own risk. 52 * This code and its internal interfaces are subject to change or 53 * deletion without notice.</b> 54 */ 55 56 public abstract class AbstractBuilder { 57 public static class Context { 58 /** 59 * The configuration used in this run of the doclet. 60 */ 61 final BaseConfiguration configuration; 62 63 /** 64 * Keep track of which packages we have seen for 65 * efficiency purposes. We don't want to copy the 66 * doc files multiple times for a single package. 67 */ 68 final Set<PackageElement> containingPackagesSeen; 69 70 Context(BaseConfiguration configuration, Set<PackageElement> containingPackagesSeen) { 71 this.configuration = configuration; 72 this.containingPackagesSeen = containingPackagesSeen; 73 } 74 } 75 76 /** 77 * The configuration used in this run of the doclet. 78 */ 79 protected final BaseConfiguration configuration; 80 protected final BaseOptions options; 81 82 protected final BuilderFactory builderFactory; 83 protected final Messages messages; 84 protected final Resources resources; 85 protected final Utils utils; 86 87 /** 88 * Keep track of which packages we have seen for 89 * efficiency purposes. We don't want to copy the 90 * doc files multiple times for a single package. 91 */ 92 protected final Set<PackageElement> containingPackagesSeen; 93 94 /** 95 * Construct a Builder. 96 * @param c a context providing information used in this run of the doclet 97 */ 98 public AbstractBuilder(Context c) { 99 this.configuration = c.configuration; 100 this.options = configuration.getOptions(); 101 this.builderFactory = configuration.getBuilderFactory(); 102 this.messages = configuration.getMessages(); 103 this.resources = configuration.getResources(); 104 this.utils = configuration.utils; 105 this.containingPackagesSeen = c.containingPackagesSeen; 106 } 107 108 /** 109 * Build the documentation. 110 * 111 * @throws DocletException if there is a problem building the documentation 112 */ 113 public abstract void build() throws DocletException; 114 }