xdoclet.tagshandler

Class TypeTagsHandler


public class TypeTagsHandler
extends XDocletTagSupport

Simple tag support class.
Version:
$Revision: 1.15 $
Author:
Dmitri Colebatch (dim@bigpond.net.au)
xdoclet.taghandler
namespace = "Type"
created
October 12, 2001

Field Summary

static int
TYPE_CONCRETE_TYPE
Used by isOfType.
static int
TYPE_HIERARCHY
Used by isOfType.
static int
TYPE_SUPERCLASS
Used by isOfType.

Fields inherited from class xdoclet.XDocletTagSupport

FOR_CLASS, FOR_CONSTRUCTOR, FOR_FIELD, FOR_METHOD, PARAMETER_DELIMITER

Method Summary

static int
extractExtentType(String extent_str)
Return the integer constant based on the extent_str.
void
ifIsNotOfType(String template, Properties attributes)
Evaluate the body block if the entity is not of the specified type.
void
ifIsNotPrimitive(String template, Properties attributes)
Evaluate the body block if the value is not of a primitive type.
void
ifIsNotPrimitiveArray(String template, Properties attributes)
Evaluate the body block if the value is not of a primitive array type.
void
ifIsNotPrimitiveOrString(String template, Properties attributes)
Evaluate the body block if the value is of a primitive type or String.
void
ifIsOfType(String template, Properties attributes)
Evaluate the body block if the entity is of the specified type.
protected void
ifIsOfType_Impl(String template, Properties attributes, boolean condition)
Implementation of ifIsOfType and ifIsNotOfType tags.
void
ifIsPrimitive(String template, Properties attributes)
Evaluate the body block if the value is of a primitive type.
void
ifIsPrimitiveArray(String template, Properties attributes)
Evaluate the body block if the value is of a primitive array type.
void
ifIsPrimitiveOrString(String template, Properties attributes)
Evaluate the body block if the value is of a primitive type or String.
static boolean
isOfType(XClass clazz, String type, int extent)
Returns true if cur_class is of type type.
static boolean
isPrimitiveArray(String name)
Returns true if name is a primitive type and is an array (ends with [])
static boolean
isPrimitiveType(String name)
Returns true if name is a primitive type, in that case name contains the string "int"/"float"/etc.
String
typeWithoutDimensions(Properties attributes)
Returns the type specified with the type parameter without dimensions.

Methods inherited from class xdoclet.XDocletTagSupport

delimit, expandClassName, generate, getCurrentClass, getCurrentClassTag, getCurrentConstructor, getCurrentField, getCurrentFieldTag, getCurrentMethod, getCurrentMethodTag, getCurrentPackage, getDocletContext, getEngine, getExpandedDelimitedTagValue, getTagValue, getTagValue, getTagValue, hasTag, isTagValueEqual, mandatoryParamNotFound, mandatoryTemplateTagParamNotFound, modifiers, popCurrentClass, pushCurrentClass, setCurrentClass, setCurrentClassTag, setCurrentConstructor, setCurrentField, setCurrentFieldTag, setCurrentMethod, setCurrentMethodTag, setCurrentPackage

Methods inherited from class xdoclet.template.TemplateTagHandler

getXJavaDoc, setXJavaDoc

Field Details

TYPE_CONCRETE_TYPE

public static final int TYPE_CONCRETE_TYPE
Used by isOfType. isOfType searches for the type according to the type parameter. TYPE_CONCRETE_TYPE specifies that only the type of the current entity (class, method return type, parameter type depdening on the context) should be checked for equality.
Field Value:
0

TYPE_HIERARCHY

public static final int TYPE_HIERARCHY
Used by isOfType. isOfType searches for the type according to the type parameter. TYPE_HIERARCHY specifies that not only the type of the current entity (class, method return type, parameter type depdening on the context) should be checked for equality, but also superclasses and interfaces of the entity and recursively superclasses and interfaces.
Field Value:
2

TYPE_SUPERCLASS

public static final int TYPE_SUPERCLASS
Used by isOfType. isOfType searches for the type according to the type parameter. TYPE_SUPERCLASS specifies that not only the type of the current entity (class, method return type, parameter type depdening on the context) should be checked for equality, but also direct superclasses and interfaces of the entity.
Field Value:
1

Method Details

extractExtentType

public static int extractExtentType(String extent_str)
Return the integer constant based on the extent_str. Used by forAllClasses and ifIsOfType_Impl. If the string doesn't have one of the expected values TYPE_HIERARCHY is returned.
Parameters:
extent_str - Description of Parameter
Returns:
Description of the Returned Value

ifIsNotOfType

public void ifIsNotOfType(String template,
                          Properties attributes)
            throws XDocletException
Evaluate the body block if the entity is not of the specified type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsOfType(java.lang.String,java.util.Properties)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" values = "class,return-type" description = "If class then check current class's type, if return-type then check current method return type, if property-type and the current method is a getter or setter then check current method's property type. Default is class."
name = "type" optional = "false" description = "The type we are checking against."
name = "extent" optional = "true" values = "concrete-type,superclass,hierarchy" description = "Specifies the extent of the type search. If concrete-type then only check the concrete type, if superclass then check also superclass, if hierarchy then search the whole hierarchy and find if the class is of the specified type. Default is hierarchy."

ifIsNotPrimitive

public void ifIsNotPrimitive(String template,
                             Properties attributes)
            throws XDocletException
Evaluate the body block if the value is not of a primitive type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - If the evaluation of the body block fails.
See Also:
ifIsPrimitive(java.lang.String,java.util.Properties), isPrimitiveType(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

ifIsNotPrimitiveArray

public void ifIsNotPrimitiveArray(String template,
                                  Properties attributes)
            throws XDocletException
Evaluate the body block if the value is not of a primitive array type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsPrimitiveArray(java.lang.String,java.util.Properties), isPrimitiveArray(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

ifIsNotPrimitiveOrString

public void ifIsNotPrimitiveOrString(String template,
                                     Properties attributes)
            throws XDocletException
Evaluate the body block if the value is of a primitive type or String.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsNotPrimitive(java.lang.String,java.util.Properties), isPrimitiveType(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

ifIsOfType

public void ifIsOfType(String template,
                       Properties attributes)
            throws XDocletException
Evaluate the body block if the entity is of the specified type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsNotOfType(java.lang.String,java.util.Properties)
doc.tag
type = "block"
doc.param
name = "value" optional = "true" values = "class,return-type,property-type" description = "If class then check current class's type, if return-type then check current method return type, if property-type and the current method is a getter or setter then check current method's property type. Default is class."
name = "type" optional = "false" description = "The type we are checking against."
name = "extent" optional = "true" values = "concrete-type,superclass,hierarchy" description = "Specifies the extent of the type search. If concrete-type then only check the concrete type, if superclass then check also superclass, if hierarchy then search the whole hierarchy and find if the class is of the specified type. Default is hierarchy."

ifIsOfType_Impl

protected void ifIsOfType_Impl(String template,
                               Properties attributes,
                               boolean condition)
            throws XDocletException
Implementation of ifIsOfType and ifIsNotOfType tags.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
condition - Whether to look for a match (true) or non-match (false)
Throws:
XDocletException - Description of Exception
See Also:
ifIsOfType(java.lang.String,java.util.Properties), ifIsNotOfType(java.lang.String,java.util.Properties)

ifIsPrimitive

public void ifIsPrimitive(String template,
                          Properties attributes)
            throws XDocletException
Evaluate the body block if the value is of a primitive type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsNotPrimitive(java.lang.String,java.util.Properties), isPrimitiveType(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

ifIsPrimitiveArray

public void ifIsPrimitiveArray(String template,
                               Properties attributes)
            throws XDocletException
Evaluate the body block if the value is of a primitive array type.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsNotPrimitiveArray(java.lang.String,java.util.Properties), isPrimitiveArray(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

ifIsPrimitiveOrString

public void ifIsPrimitiveOrString(String template,
                                  Properties attributes)
            throws XDocletException
Evaluate the body block if the value is of a primitive type or String.
Parameters:
template - The body of the block tag
attributes - The attributes of the template tag
Throws:
XDocletException - Description of Exception
See Also:
ifIsNotPrimitive(java.lang.String,java.util.Properties), isPrimitiveType(java.lang.String)
doc.tag
type = "block"
doc.param
name = "value" optional = "false" description = "A string containsing the type name."

isOfType

public static boolean isOfType(XClass clazz,
                               String type,
                               int extent)
Returns true if cur_class is of type type. It searches for type in cur_class's hierarchy according to the value of extent parameter.
Parameters:
clazz - The passed class to compare to the reference type
type - The reference type
extent - One of TypeTagsHandler.TYPE_*
Returns:
True if there is a match.
To do:
move this to xjavadoc

isPrimitiveArray

public static boolean isPrimitiveArray(String name)
Returns true if name is a primitive type and is an array (ends with [])
Parameters:
name - The name of the type.
Returns:
true if name is an array of a primitive type.

isPrimitiveType

public static boolean isPrimitiveType(String name)
Returns true if name is a primitive type, in that case name contains the string "int"/"float"/etc.
Parameters:
name - The passed type to check
Returns:
true if this is a primitive type

typeWithoutDimensions

public String typeWithoutDimensions(Properties attributes)
            throws XDocletException
Returns the type specified with the type parameter without dimensions.
Parameters:
attributes -
Returns:
doc.tag
type = "content"
doc.param
name = "type" optional = "false" description = "Specifies the type to return without dimensions. So, the value String[][] will be returned as String."