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

" + HEADER + "

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

" + HEADER + "

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