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