xjavadoc
Class XDoc

java.lang.Object
  extended byxjavadoc.XDoc
All Implemented Interfaces:
EventListener, XTagListener

public final class XDoc
extends Object
implements XTagListener

Represents documentation

Author:
Aslak Hellesøy

Field Summary
static int instanceCount
           
 
Constructor Summary
XDoc(Token javadocToken, XProgramElement owner, XTagFactory tagFactory)
          Describe what the XDoc constructor does
 
Method Summary
 void addDocListener(XDocListener docListener)
          Add doc listener interested in changes.
 XTag addTag(String tagName, String text)
          Add a tag to the doc item.
static String dotted(String tagName)
          Convert a tag name from the old colon-separated form to the new preferred dot-separated form.
 String getCommentText()
          return description of program element
 String getFirstSentence()
          Return the first sentence of the text of the comment for this doc item.
 XProgramElement getOwner()
          Gets the Owner attribute of the XDoc object
 XTag getTag(String tagName)
          Get the first tag of name tagName from this doc.
 XTag getTag(String tagName, boolean superclasses)
          Get the first tag of name tagName.
 String getTagAttributeValue(String tagName, String attributeName)
          Returns the tag attribute value.
 String getTagAttributeValue(String tagName, String attributeName, boolean superclasses)
          Returns the tag attribute value.
 List getTags()
          Returns all the tags in this doc (not superclasses).
 List getTags(boolean superclasses)
          Returns all the tags.
 List getTags(String tagName)
          Returns all the tags in this doc with the specified tagName (not superclasses).
 List getTags(String tagName, boolean superclasses)
          Returns all the tags with the specified tagName.
 boolean hasTag(String tagName)
          Returns true if the tag exists.
 boolean hasTag(String tagName, boolean superclasses)
          Returns true if the tag exists.
 void removeDocListener(XDocListener docListener)
          remove doc listener
 boolean removeTag(XTag tag)
          Removes tag.
 void setCommentText(String commentText)
          Set the text of the comment for this doc item.
 void tagChanged(XTagEvent event)
          receive change notification from xtag
 String toString()
          Returns a String representation of this doc.
 XTag updateTagValue(String tagName, String attributeName, String attributeValue, int tagIndex)
          Utility method to set the value of a tag attribute.
 void updateToken()
          update token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instanceCount

public static int instanceCount
Constructor Detail

XDoc

public XDoc(Token javadocToken,
            XProgramElement owner,
            XTagFactory tagFactory)
Describe what the XDoc constructor does

Parameters:
javadocToken - Describe what the parameter does
owner - Describe what the parameter does
tagFactory - Describe what the parameter does
Method Detail

dotted

public static String dotted(String tagName)
Convert a tag name from the old colon-separated form to the new preferred dot-separated form.

Parameters:
tagName - The name of the tag
Returns:
Preferred form of the tag

getOwner

public XProgramElement getOwner()
Gets the Owner attribute of the XDoc object

Returns:
The Owner value

getTags

public List getTags(String tagName)
Returns all the tags in this doc with the specified tagName (not superclasses). If No tags are found, an empty Collection is returned.

Parameters:
tagName - the name of the tags to return (without the 'at')
Returns:
A Collection of XTag

getTags

public List getTags(String tagName,
                    boolean superclasses)
Returns all the tags with the specified tagName. If No tags are found, an empty Collection is returned.

Parameters:
tagName - the name of the tags to return (without the 'at')
superclasses - if this is true, return tags from superclasses too.
Returns:
A Collection of XTag

getTags

public List getTags()
Returns all the tags in this doc (not superclasses). If No tags are found, an empty Collection is returned.

Returns:
A Collection of XTag

getTags

public List getTags(boolean superclasses)
Returns all the tags. If no tags are found, an empty List is returned.

Parameters:
superclasses - if this is true, return tags from superclasses too.
Returns:
A List of XTag

getTag

public XTag getTag(String tagName)
Get the first tag of name tagName from this doc. Superclasses are not searched.

Parameters:
tagName - the name of the tag
Returns:
the tag

getTag

public XTag getTag(String tagName,
                   boolean superclasses)
Get the first tag of name tagName.

Parameters:
tagName - the name of the tag to get (without the 'at')
superclasses - if this is true, return tags from superclasses too.
Returns:
the first XTag with name equal to tagName

getTagAttributeValue

public String getTagAttributeValue(String tagName,
                                   String attributeName)
Returns the tag attribute value. Does not look in superclasses. If nothing is found, null is returned.

Parameters:
tagName - The name of the tag to look for (without the 'at')
attributeName - The name of the attribute to look for within the tag.
Returns:
The value of the tag attribute.

getTagAttributeValue

public String getTagAttributeValue(String tagName,
                                   String attributeName,
                                   boolean superclasses)
Returns the tag attribute value. If superclasses is true, the first occurrence is returned when walking up the class hierarchy. If nothing is found, null is returned.

Parameters:
tagName - The name of the tag to look for (without the 'at')
attributeName - The name of the attribute to look for within the tag.
superclasses - Set it to true to look in superclasses too.
Returns:
The value of the tag attribute.

getCommentText

public String getCommentText()
return description of program element

Returns:
description of program element

getFirstSentence

public String getFirstSentence()
Return the first sentence of the text of the comment for this doc item.

Returns:
First sentence

setCommentText

public void setCommentText(String commentText)
Set the text of the comment for this doc item.

Parameters:
commentText - The new comment text

hasTag

public boolean hasTag(String tagName)
Returns true if the tag exists. Does not look in superclasses.

Parameters:
tagName - The name of the tag to look for (without the 'at')
Returns:
true if the tag exists

hasTag

public boolean hasTag(String tagName,
                      boolean superclasses)
Returns true if the tag exists.

Parameters:
tagName - The name of the tag to look for (without the 'at')
superclasses - If true, look in superclasses too.
Returns:
true if the tag exists

updateTagValue

public XTag updateTagValue(String tagName,
                           String attributeName,
                           String attributeValue,
                           int tagIndex)
                    throws XJavaDocException
Utility method to set the value of a tag attribute. If the tag doesn't exist, it is created. If the attribute doesn't exist it is created. If the tag attribute exists, it is updated.

Parameters:
tagName - The new name of the tag to update (without the
tagIndex - The index of the tag to update, in case there are several tags with the same name.
attributeName - The attribute name
attributeValue - The new attribute value
Returns:
the updated tag
Throws:
XJavaDocException

addDocListener

public void addDocListener(XDocListener docListener)
Add doc listener interested in changes.

Parameters:
docListener - doc listener to register

removeDocListener

public void removeDocListener(XDocListener docListener)
remove doc listener

Parameters:
docListener -

toString

public String toString()
Returns a String representation of this doc.

Returns:
a String representation of this doc.

updateToken

public void updateToken()
update token


removeTag

public boolean removeTag(XTag tag)
Removes tag. Note that XTag objects are compared by identity.

Parameters:
tag - tag to be removed
Returns:
true if it was removed

addTag

public XTag addTag(String tagName,
                   String text)
Add a tag to the doc item.

Parameters:
tagName - The name of the tag to add
text - The value of the tag
Returns:
The created XTag
Throws:
TagValidationException - if validation is activated (in XTagFactory) and tagName is not among the registered tags.

tagChanged

public void tagChanged(XTagEvent event)
receive change notification from xtag

Specified by:
tagChanged in interface XTagListener
Parameters:
event -


Copyright © 2002-2004 XDoclet Team. All Rights Reserved.