/*
* 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 java.util.Map;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.Taglet;
/**
* The <code>@section</code> tag for inserting a new section in a javadoc comment.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.00)
* @version 0.3
* @module
*/
public final class Section extends InlineTaglet {
/**
* Register this taglet.
*
* @param tagletMap the map to register this tag to.
*/
public static void register(final Map<String,Taglet> tagletMap) {
final Section tag = new Section();
tagletMap.put(tag.getName(), tag);
}
/**
* Constructs a default <code>@section</code> taglet.
*/
private Section() {
super();
}
/**
* Returns the name of this custom tag.
*
* @return The tag name.
*/
@Override
public String getName() {
return "section";
}
/**
* Returns {@code false} since <code>@section</code> can not be used in overview.
*
* @return Always {@code false}.
*/
@Override
public boolean inOverview() {
return false;
}
/**
* Given the <code>Tag</code> representation of this custom tag, return its string representation.
*
* @param tag The tag to format.
* @return A string representation of the given tag.
*/
@Override
public String toString(final Tag tag) {
final Doc holder = tag.holder();
final boolean small = (holder == null)
|| holder.isEnumConstant()
|| holder.isField()
|| holder.isMethod()
|| holder.isConstructor();
final String text = tag.text();
final StringBuilder buffer = new StringBuilder(text.length() + 8);
buffer.append('\n')
.append(small ? "<h6>" : "<h5>")
.append(text)
.append(small ? "</h6>" : "</h5>");
return buffer.toString();
}
}