src/share/classes/com/sun/tools/javac/util/ForwardingDiagnosticFormatter.java

Mon, 27 Jul 2009 19:52:42 -0700

author
jjg
date
Mon, 27 Jul 2009 19:52:42 -0700
changeset 333
7c2d6da61646
parent 288
d402db1005ad
child 554
9d9f26857129
permissions
-rw-r--r--

6865399: some javac files are missing Sun internal API comment
Reviewed-by: darcy

mcimadamore@288 1 /*
mcimadamore@288 2 * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
mcimadamore@288 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@288 4 *
mcimadamore@288 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@288 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@288 7 * published by the Free Software Foundation. Sun designates this
mcimadamore@288 8 * particular file as subject to the "Classpath" exception as provided
mcimadamore@288 9 * by Sun in the LICENSE file that accompanied this code.
mcimadamore@288 10 *
mcimadamore@288 11 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@288 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@288 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@288 14 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@288 15 * accompanied this code).
mcimadamore@288 16 *
mcimadamore@288 17 * You should have received a copy of the GNU General Public License version
mcimadamore@288 18 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@288 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@288 20 *
mcimadamore@288 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
mcimadamore@288 22 * CA 95054 USA or visit www.sun.com if you need additional information or
mcimadamore@288 23 * have any questions.
mcimadamore@288 24 */
mcimadamore@288 25 package com.sun.tools.javac.util;
mcimadamore@288 26
mcimadamore@288 27 import java.util.Set;
mcimadamore@288 28 import java.util.Locale;
mcimadamore@288 29 import javax.tools.Diagnostic;
mcimadamore@288 30
mcimadamore@288 31 import com.sun.tools.javac.api.DiagnosticFormatter;
mcimadamore@288 32 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration;
mcimadamore@288 33 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart;
mcimadamore@288 34 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit;
mcimadamore@288 35 import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind;
mcimadamore@288 36
mcimadamore@288 37 /**
mcimadamore@288 38 * A delegated diagnostic formatter delegates all formatting
mcimadamore@288 39 * actions to an underlying formatter (aka the delegated formatter).
jjg@333 40 *
jjg@333 41 * <p><b>This is NOT part of any API supported by Sun Microsystems.
jjg@333 42 * If you write code that depends on this, you do so at your own risk.
jjg@333 43 * This code and its internal interfaces are subject to change or
jjg@333 44 * deletion without notice.</b>
mcimadamore@288 45 */
mcimadamore@288 46 public class ForwardingDiagnosticFormatter<D extends Diagnostic<?>, F extends DiagnosticFormatter<D>>
mcimadamore@288 47 implements DiagnosticFormatter<D> {
mcimadamore@288 48
mcimadamore@288 49 /**
mcimadamore@288 50 * The delegated formatter
mcimadamore@288 51 */
mcimadamore@288 52 protected F formatter;
mcimadamore@288 53
mcimadamore@288 54 /*
mcimadamore@288 55 * configuration object used by this formatter
mcimadamore@288 56 */
mcimadamore@288 57 protected ForwardingConfiguration configuration;
mcimadamore@288 58
mcimadamore@288 59 public ForwardingDiagnosticFormatter(F formatter) {
mcimadamore@288 60 this.formatter = formatter;
mcimadamore@288 61 this.configuration = new ForwardingConfiguration(formatter.getConfiguration());
mcimadamore@288 62 }
mcimadamore@288 63
mcimadamore@288 64 /**
mcimadamore@288 65 * Returns the underlying delegated formatter
mcimadamore@288 66 * @return delegate formatter
mcimadamore@288 67 */
mcimadamore@288 68 public F getDelegatedFormatter() {
mcimadamore@288 69 return formatter;
mcimadamore@288 70 }
mcimadamore@288 71
mcimadamore@288 72 public Configuration getConfiguration() {
mcimadamore@288 73 return configuration;
mcimadamore@288 74 }
mcimadamore@288 75
mcimadamore@288 76 public boolean displaySource(D diag) {
mcimadamore@288 77 return formatter.displaySource(diag);
mcimadamore@288 78 }
mcimadamore@288 79
mcimadamore@288 80 public String format(D diag, Locale l) {
mcimadamore@288 81 return formatter.format(diag, l);
mcimadamore@288 82 }
mcimadamore@288 83
mcimadamore@288 84 public String formatKind(D diag, Locale l) {
mcimadamore@288 85 return formatter.formatKind(diag, l);
mcimadamore@288 86 }
mcimadamore@288 87
mcimadamore@288 88 public String formatMessage(D diag, Locale l) {
mcimadamore@288 89 return formatter.formatMessage(diag, l);
mcimadamore@288 90 }
mcimadamore@288 91
mcimadamore@288 92 public String formatPosition(D diag, PositionKind pk, Locale l) {
mcimadamore@288 93 return formatter.formatPosition(diag, pk, l);
mcimadamore@288 94 }
mcimadamore@288 95
mcimadamore@288 96 public String formatSource(D diag, boolean fullname, Locale l) {
mcimadamore@288 97 return formatter.formatSource(diag, fullname, l);
mcimadamore@288 98 }
mcimadamore@288 99
mcimadamore@288 100 /**
mcimadamore@288 101 * A delegated formatter configuration delegates all configurations settings
mcimadamore@288 102 * to an underlying configuration object (aka the delegated configuration).
mcimadamore@288 103 */
mcimadamore@288 104 public static class ForwardingConfiguration implements DiagnosticFormatter.Configuration {
mcimadamore@288 105
mcimadamore@288 106 /** The configurationr object to which the forwarding configuration delegates some settings */
mcimadamore@288 107 protected Configuration configuration;
mcimadamore@288 108
mcimadamore@288 109 public ForwardingConfiguration(Configuration configuration) {
mcimadamore@288 110 this.configuration = configuration;
mcimadamore@288 111 }
mcimadamore@288 112
mcimadamore@288 113 /**
mcimadamore@288 114 * Returns the underlying delegated configuration.
mcimadamore@288 115 * @return delegated configuration
mcimadamore@288 116 */
mcimadamore@288 117 public Configuration getDelegatedConfiguration() {
mcimadamore@288 118 return configuration;
mcimadamore@288 119 }
mcimadamore@288 120
mcimadamore@288 121 public int getMultilineLimit(MultilineLimit limit) {
mcimadamore@288 122 return configuration.getMultilineLimit(limit);
mcimadamore@288 123 }
mcimadamore@288 124
mcimadamore@288 125 public Set<DiagnosticPart> getVisible() {
mcimadamore@288 126 return configuration.getVisible();
mcimadamore@288 127 }
mcimadamore@288 128
mcimadamore@288 129 public void setMultilineLimit(MultilineLimit limit, int value) {
mcimadamore@288 130 configuration.setMultilineLimit(limit, value);
mcimadamore@288 131 }
mcimadamore@288 132
mcimadamore@288 133 public void setVisible(Set<DiagnosticPart> diagParts) {
mcimadamore@288 134 configuration.setVisible(diagParts);
mcimadamore@288 135 }
mcimadamore@288 136 }
mcimadamore@288 137 }

mercurial