sidekick.ecmascript.parser
Class Comment

java.lang.Object
  extended by sidekick.ecmascript.parser.Comment

public class Comment
extends java.lang.Object

Objects of this class hold multi-line c-style comments in original source form and for javadoc comments also parsed and broken down into tags. API exists to query the tags, get the comment body and beautifying the comment body that turns plain text into more formatted html according to some wild guesses and silly heuristics.

Since:
JDK 1.4

Nested Class Summary
static class Comment.Tag
          Simple class holding a javadoc tag
 
Constructor Summary
Comment(java.lang.String comment)
          Creates an instance of Comment from the specified comment string
 
Method Summary
 boolean containsTag(java.lang.String key)
          Returns true if receiver has a javadoc tag matching specified key.
 java.lang.String getCommentBody()
          Returns the comment body.
 java.lang.String getFirstSentenceInCommentBody(int maxLength)
          Returns the first sentence of the comment body (suitable for summary lines).
 java.lang.String getHtmlifiedCommentBody()
          Returns the comment body transforming <plaintext> blocks into <pre> blocks and escaping all the < and > in there.
 java.lang.String getHtmlifiedSource()
          Deprecated.  
 java.util.List getLines()
          Returns an unmodifiable list of Strings representing the comment body lines.
 java.lang.String getOriginalSource()
          Returns the original comment string.
 java.lang.String getTag(java.lang.String key)
          Returns the first javadoc tag value in the list of tags whose key matches the specified key
 java.util.List<Comment.Tag> getTags()
          Returns an unmodifiable list of javadoc tags (instances of Comment.Tag)
 java.util.List<Comment.Tag> getTags(java.util.regex.Pattern pattern)
          Returns all javadoc tag values in the list of tags whose keys match the specified key
 java.util.List<java.lang.String> getTags(java.lang.String key)
          Returns all javadoc tag values in the list of tags whose keys match the specified key
 boolean isJavadoc()
          Returns true if receiver is a javadoc comment.
static void main(java.lang.String[] args)
           
static java.lang.String[] parseNamedTypedDescription(java.lang.String tagValue)
           
static java.lang.String[] parseTypedDescription(java.lang.String tagValue)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Comment

public Comment(java.lang.String comment)
        throws java.lang.Exception
Creates an instance of Comment from the specified comment string

Parameters:
comment - comment string
Throws:
java.lang.Exception - if parsing the comment generates a parsing error
Method Detail

isJavadoc

public boolean isJavadoc()
Returns true if receiver is a javadoc comment.

Returns:
true if receiver is a javadoc comment

getLines

public java.util.List getLines()
Returns an unmodifiable list of Strings representing the comment body lines.

Returns:
list of comment body lines

getCommentBody

public java.lang.String getCommentBody()
Returns the comment body.

Returns:
comment body

getFirstSentenceInCommentBody

public java.lang.String getFirstSentenceInCommentBody(int maxLength)
Returns the first sentence of the comment body (suitable for summary lines). In case no sentence ending char sequence is found (period followed by blank) then up to maxLength chars are returned.

Parameters:
maxLength - maximum length of returned string
Returns:
first sentence of comment body.

getHtmlifiedCommentBody

public java.lang.String getHtmlifiedCommentBody()
Returns the comment body transforming <plaintext> blocks into <pre> blocks and escaping all the < and > in there.

Returns:
comment body

getTags

public java.util.List<Comment.Tag> getTags()
Returns an unmodifiable list of javadoc tags (instances of Comment.Tag)

Returns:
list of javadoc tags

getTag

public java.lang.String getTag(java.lang.String key)
Returns the first javadoc tag value in the list of tags whose key matches the specified key

Parameters:
key - javadoc tag key
Returns:
String of the javadoc tag value

getTags

public java.util.List<java.lang.String> getTags(java.lang.String key)
Returns all javadoc tag values in the list of tags whose keys match the specified key

Parameters:
key - javadoc tag key
Returns:
List of Strings that are the javadoc tag values

getTags

public java.util.List<Comment.Tag> getTags(java.util.regex.Pattern pattern)
Returns all javadoc tag values in the list of tags whose keys match the specified key

Parameters:
pattern - javadoc tag pattern
Returns:
List of Tag instances

containsTag

public boolean containsTag(java.lang.String key)
Returns true if receiver has a javadoc tag matching specified key.

Parameters:
key - javadoc tag key
Returns:
true if receiver has a javadoc tag matching specified key

getOriginalSource

public java.lang.String getOriginalSource()
Returns the original comment string.

Returns:
comment string

getHtmlifiedSource

@Deprecated
public java.lang.String getHtmlifiedSource()
Deprecated. 

Returns a version of the comment string with the plain text portion converted to more structured html. Also deletes all the type information given with the "(CXFoo)" convention Used in the deprecated javadoc task. For ogredoc use getHtmlifiedCommentBody()

Returns:
comment string

parseNamedTypedDescription

public static java.lang.String[] parseNamedTypedDescription(java.lang.String tagValue)

parseTypedDescription

public static java.lang.String[] parseTypedDescription(java.lang.String tagValue)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)