93b49b
/*
93b49b
 * Licensed to the Apache Software Foundation (ASF) under one or more
93b49b
 * contributor license agreements.  See the NOTICE file distributed with
93b49b
 * this work for additional information regarding copyright ownership.
93b49b
 * The ASF licenses this file to You under the Apache License, Version 2.0
93b49b
 * (the "License"); you may not use this file except in compliance with
93b49b
 * the License.  You may obtain a copy of the License at
93b49b
 * 
93b49b
 *      http://www.apache.org/licenses/LICENSE-2.0
93b49b
 * 
93b49b
 * Unless required by applicable law or agreed to in writing, software
93b49b
 * distributed under the License is distributed on an "AS IS" BASIS,
93b49b
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93b49b
 * See the License for the specific language governing permissions and
93b49b
 * limitations under the License.
93b49b
 */
93b49b
93b49b
package org.apache.xerces.util;
93b49b
93b49b
import java.util.Map;
93b49b
93b49b
import com.sun.javadoc.Tag;
93b49b
import com.sun.tools.doclets.Taglet;
93b49b
93b49b
/**
93b49b
 * This class provides support for a 'xerces.internal' tag
93b49b
 * in javadoc comments. The tag creates a warning in the generated
93b49b
 * html for users.
93b49b
 * 
93b49b
 * @author Ankit Pasricha, IBM
93b49b
 */
93b49b
public class InternalTaglet implements Taglet {
93b49b
    
93b49b
    private static final String NAME = "xerces.internal";
93b49b
    private static final String HEADER = "INTERNAL:";
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inConstructor()
93b49b
     */
93b49b
    public boolean inConstructor() {
93b49b
        return false;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inField()
93b49b
     */
93b49b
    public boolean inField() {
93b49b
        return false;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inMethod()
93b49b
     */
93b49b
    public boolean inMethod() {
93b49b
        return true;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inOverview()
93b49b
     */
93b49b
    public boolean inOverview() {
93b49b
        return true;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inPackage()
93b49b
     */
93b49b
    public boolean inPackage() {
93b49b
        return false;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#inType()
93b49b
     */
93b49b
    public boolean inType() {
93b49b
        return true;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#isInlineTag()
93b49b
     */
93b49b
    public boolean isInlineTag() {
93b49b
        return false;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#getName()
93b49b
     */
93b49b
    public String getName() {
93b49b
        return NAME;
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#toString(com.sun.javadoc.Tag)
93b49b
     */
93b49b
    public String toString(Tag arg0) {
93b49b
        return "

" + HEADER + "

"
93b49b
        + "Usage of this class is not supported. It may be altered or removed at any time.
"
93b49b
        + "" + arg0.text() + "\n";
93b49b
    }
93b49b
    
93b49b
    /* (non-Javadoc)
93b49b
     * @see com.sun.tools.doclets.Taglet#toString(com.sun.javadoc.Tag[])
93b49b
     */
93b49b
    public String toString(Tag[] tags) {
93b49b
        if (tags.length == 0) {
93b49b
            return null;
93b49b
        }
93b49b
        String result = "\n

" + HEADER + "

";
93b49b
        result += "Usage of this class is not supported. It may be altered or removed at any time.";
93b49b
        result += "";
93b49b
        for (int i = 0; i < tags.length; i++) {
93b49b
            result += "
";
93b49b
            result += tags[i].text();
93b49b
        }
93b49b
        return result + "\n";
93b49b
    }
93b49b
    
93b49b
    /**
93b49b
     * Register this Taglet.
93b49b
     * @param tagletMap  the map to register this tag to.
93b49b
     */
93b49b
    public static void register(Map tagletMap) {
93b49b
        InternalTaglet tag = new InternalTaglet();
93b49b
        Taglet t = (Taglet) tagletMap.get(tag.getName());
93b49b
        if (t != null) {
93b49b
            tagletMap.remove(tag.getName());
93b49b
        }
93b49b
        tagletMap.put(tag.getName(), tag);
93b49b
    }
93b49b
    
93b49b
}