/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.sis.internal.taglet;

import com.sun.javadoc.Tag;
import com.sun.javadoc.RootDoc;
import com.sun.javadoc.SourcePosition;
import com.sun.tools.doclets.Taglet;
import com.sun.tools.doclets.internal.toolkit.Configuration;
import com.sun.tools.doclets.formats.html.ConfigurationImpl;


/**
 * Base class of inline taglets.
 *
 * @author  Martin Desruisseaux (Geomatys)
 * @since   0.3
 * @version 0.3
 * @module
 */
abstract class InlineTaglet implements Taglet {
    /**
     * The doclet configuration, created when first needed for reporting warnings.
     *
     * <p>Note: the JDK7 branch uses {@code ConfigurationImpl.getInstance()} method instead.
     * But that method does not exist anymore in JDK8.</p>
     */
    private static Configuration configuration;

    /**
     * Returns the doclet configuration.
     */
    private static synchronized Configuration getConfiguration() {
        if (configuration == null) {
            configuration = new ConfigurationImpl();
        }
        return configuration;
    }

    /**
     * Constructs a default inline taglet.
     */
    InlineTaglet() {
    }

    /**
     * Returns {@code true} since SIS taglets can be used in overview.
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inOverview() {
        return true;
    }

    /**
     * Returns {@code true} since SIS taglets can be used in package documentation.
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inPackage() {
        return true;
    }

    /**
     * Returns {@code true} since SIS taglets can be used in type documentation
     * (classes or interfaces).
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inType() {
        return true;
    }

    /**
     * Returns {@code true} since SIS taglets can be used in constructor
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inConstructor() {
        return true;
    }

    /**
     * Returns {@code true} since SIS taglets can be used in method documentation.
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inMethod() {
        return true;
    }

    /**
     * Returns {@code true} since SIS taglets can be used in field documentation.
     *
     * @return Default to {@code true}.
     */
    @Override
    public boolean inField() {
        return true;
    }

    /**
     * Returns {@code true} since this base class is all about inline tags.
     *
     * @return Always {@code true}.
     */
    @Override
    public final boolean isInlineTag() {
        return true;
    }

    /**
     * Given an array of {@code Tag}s representing this custom tag, return its string
     * representation. This method should not be called since arrays of inline tags do
     * not exist. However we define it as a matter of principle.
     *
     * @param  tags The tags to format.
     * @return A string representation of the given tags.
     */
    @Override
    public final String toString(final Tag[] tags) {
        final StringBuilder buffer = new StringBuilder(64);
        for (int i=0; i<tags.length; i++) {
            buffer.append(toString(tags[i]));
        }
        return buffer.toString();
    }

    /**
     * Prints a warning message.
     */
    static void printWarning(final SourcePosition position, final String message) {
        final RootDoc root = getConfiguration().root;
        if (root != null) {
            root.printWarning(position, message);
        } else {
            System.err.println(message);
        }
    }

    /**
     * Prints an error message.
     */
    static void printError(final SourcePosition position, final String message) {
        final RootDoc root = getConfiguration().root;
        if (root != null) {
            root.printError(position, message);
        } else {
            System.err.println(message);
        }
    }
}

@@ -1369,167 +1369,8 @@
 gs.%0A
-     *%0A     * %3Cp%3ENote: the JDK7 branch uses %7B@code ConfigurationImpl.getInstance()%7D method instead.%0A     * But that method does not exist anymore in JDK8.%3C/p%3E%0A
     
@@ -1449,36 +1449,54 @@
 rns the 
-doclet configurati
+root document, or %7B@code null%7D if n
 on
+e
 .%0A     *
@@ -1533,38 +1533,26 @@
 zed 
-Configuration getConfiguration
+RootDoc getRootDoc
 () %7B
@@ -1680,16 +1680,21 @@
 guration
+.root
 ;%0A    %7D%0A
@@ -4123,36 +4123,25 @@
 ot = get
-Configuration().root
+RootDoc()
 ;%0A      
@@ -4453,28 +4453,17 @@
  get
-Configuration().root
+RootDoc()
 ;%0A  

Rewrite the private 'getConfiguration()' method in a way which will make easier for the JDK7 and JDK6 branches to be compilable with JDK8. The difficulty come from the fact that the way to get the Configuration object is different on JDK8 than on JDK7 and JDK6.