org.apache.maven.jxr
Class JavaCodeTransform

java.lang.Object
  extended by org.apache.maven.jxr.JavaCodeTransform
All Implemented Interfaces:
java.io.Serializable

public class JavaCodeTransform
extends java.lang.Object
implements java.io.Serializable

Syntax highlights java by turning it into html. A codeviewer object is created and then keeps state as lines are passed in. Each line passed in as java test, is returned as syntax highlighted html text. Users of the class can set how the java code will be highlighted with setter methods. Only valid java lines should be passed in since the object maintains state and may not handle illegal code gracefully. The actual system is implemented as a series of filters that deal with specific portions of the java code. The filters are as follows:

  htmlFilter
     |__
        multiLineCommentFilter -> uriFilter
           |___
              inlineCommentFilter
                 |___
                    stringFilter
                       |___
                          keywordFilter
                             |___
                                uriFilter
                                   |___
                                      jxrFilter
                                         |___
                                            importFilter
 

See Also:
Serialized Form

Field Summary
static java.lang.String COMMENT_END
          end comment delimeter
static java.lang.String COMMENT_START
          start comment delimeter
static java.lang.String JAVADOC_COMMENT_END
          end javadoc comment delimeter
static java.lang.String JAVADOC_COMMENT_START
          start javadoc comment delimeter
static boolean LINE_NUMBERS
          show line numbers
static java.lang.String RESERVED_WORD_END
          end reserved word delimeter
static java.lang.String RESERVED_WORD_START
          start reserved word delimeter
static java.lang.String STRING_END
          end String delimeter
static java.lang.String STRING_START
          start String delimeter
static java.lang.String STYLESHEET_FILENAME
          stylesheet file name
static char[] VALID_URI_CHARS
          Specify the only characters that are allowed in a URI besides alpha and numeric characters.
static java.lang.String[] VALID_URI_SCHEMES
          Description of the Field
 
Constructor Summary
JavaCodeTransform(PackageManager packageManager)
          Constructor for the JavaCodeTransform object
 
Method Summary
 java.lang.String getCurrentFilename()
          Get the current filename
 java.lang.String getDestfile()
          The current dest file being written
 java.lang.String getFooter()
          Gets the footer attribute of the JavaCodeTransform object
 java.lang.String getHeader()
          Gets the header attribute of the JavaCodeTransform object
 java.lang.String getPackageRoot()
          From the current file, determine the package root based on the current path.
 java.lang.String getRevision()
          The current revision of the CVS module
 java.lang.String getSourceDirectory()
          The current source directory being read from.
 java.lang.String getSourcefile()
          The current source file being read
 void setCurrentFilename(java.lang.String filename)
          Set the current filename
 java.lang.String syntaxHighlight(java.lang.String line)
          Now different method of seeing if at end of input stream, closes inputs stream at end.
 void transform(java.io.Reader sourceReader, java.io.Writer destWriter, java.util.Locale locale, java.lang.String inputEncoding, java.lang.String outputEncoding, java.lang.String javadocLinkDir, java.lang.String revision, boolean showHeader, boolean showFooter)
          This is the public method for doing all transforms of code.
 void transform(java.lang.String sourcefile, java.lang.String destfile, java.util.Locale locale, java.lang.String inputEncoding, java.lang.String outputEncoding, java.lang.String javadocLinkDir, java.lang.String revision)
          This is the public method for doing all transforms of code.
 java.lang.String uriFilter(java.lang.String line)
          Given a line of text, search for URIs and make href's out of them
 java.lang.String xrLine(java.lang.String line, java.lang.String packageName)
          Highlight the package in this line.
 java.lang.String xrLine(java.lang.String line, java.lang.String packageName, ClassType classType)
          Cross Reference the given line with JXR returning the new content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_NUMBERS

public static final boolean LINE_NUMBERS
show line numbers

See Also:
Constant Field Values

COMMENT_START

public static final java.lang.String COMMENT_START
start comment delimeter

See Also:
Constant Field Values

COMMENT_END

public static final java.lang.String COMMENT_END
end comment delimeter

See Also:
Constant Field Values

JAVADOC_COMMENT_START

public static final java.lang.String JAVADOC_COMMENT_START
start javadoc comment delimeter

See Also:
Constant Field Values

JAVADOC_COMMENT_END

public static final java.lang.String JAVADOC_COMMENT_END
end javadoc comment delimeter

See Also:
Constant Field Values

STRING_START

public static final java.lang.String STRING_START
start String delimeter

See Also:
Constant Field Values

STRING_END

public static final java.lang.String STRING_END
end String delimeter

See Also:
Constant Field Values

RESERVED_WORD_START

public static final java.lang.String RESERVED_WORD_START
start reserved word delimeter

See Also:
Constant Field Values

RESERVED_WORD_END

public static final java.lang.String RESERVED_WORD_END
end reserved word delimeter

See Also:
Constant Field Values

STYLESHEET_FILENAME

public static final java.lang.String STYLESHEET_FILENAME
stylesheet file name

See Also:
Constant Field Values

VALID_URI_SCHEMES

public static final java.lang.String[] VALID_URI_SCHEMES
Description of the Field


VALID_URI_CHARS

public static final char[] VALID_URI_CHARS
Specify the only characters that are allowed in a URI besides alpha and numeric characters. Refer RFC2396 - http://www.ietf.org/rfc/rfc2396.txt

Constructor Detail

JavaCodeTransform

public JavaCodeTransform(PackageManager packageManager)
Constructor for the JavaCodeTransform object

Parameters:
packageManager - PackageManager for this project
Method Detail

syntaxHighlight

public final java.lang.String syntaxHighlight(java.lang.String line)
Now different method of seeing if at end of input stream, closes inputs stream at end.

Parameters:
line - String
Returns:
filtered line of code

getHeader

public java.lang.String getHeader()
Gets the header attribute of the JavaCodeTransform object

Returns:
String

getFooter

public final java.lang.String getFooter()
Gets the footer attribute of the JavaCodeTransform object

Returns:
String

transform

public final void transform(java.io.Reader sourceReader,
                            java.io.Writer destWriter,
                            java.util.Locale locale,
                            java.lang.String inputEncoding,
                            java.lang.String outputEncoding,
                            java.lang.String javadocLinkDir,
                            java.lang.String revision,
                            boolean showHeader,
                            boolean showFooter)
                     throws java.io.IOException
This is the public method for doing all transforms of code.

Parameters:
sourceReader - Reader
destWriter - Writer
locale - String
inputEncoding - String
outputEncoding - String
javadocLinkDir - String
revision - String
showHeader - boolean
showFooter - boolean
Throws:
java.io.IOException

transform

public final void transform(java.lang.String sourcefile,
                            java.lang.String destfile,
                            java.util.Locale locale,
                            java.lang.String inputEncoding,
                            java.lang.String outputEncoding,
                            java.lang.String javadocLinkDir,
                            java.lang.String revision)
                     throws java.io.IOException
This is the public method for doing all transforms of code.

Parameters:
sourcefile - String
destfile - String
locale - String
inputEncoding - String
outputEncoding - String
javadocLinkDir - String
revision - String
Throws:
java.io.IOException

getCurrentFilename

public final java.lang.String getCurrentFilename()
Get the current filename

Returns:
String

setCurrentFilename

public final void setCurrentFilename(java.lang.String filename)
Set the current filename

Parameters:
filename - String

getPackageRoot

public final java.lang.String getPackageRoot()
From the current file, determine the package root based on the current path.

Returns:
String

uriFilter

public final java.lang.String uriFilter(java.lang.String line)
Given a line of text, search for URIs and make href's out of them

Parameters:
line - String
Returns:
String

getRevision

public final java.lang.String getRevision()
The current revision of the CVS module

Returns:
String

getSourcefile

public final java.lang.String getSourcefile()
The current source file being read

Returns:
source file name

getDestfile

public final java.lang.String getDestfile()
The current dest file being written

Returns:
destination file name

getSourceDirectory

public final java.lang.String getSourceDirectory()
The current source directory being read from.

Returns:
source directory

xrLine

public final java.lang.String xrLine(java.lang.String line,
                                     java.lang.String packageName,
                                     ClassType classType)
Cross Reference the given line with JXR returning the new content.

Parameters:
line - String
packageName - String
classType - ClassType
Returns:
String

xrLine

public final java.lang.String xrLine(java.lang.String line,
                                     java.lang.String packageName)
Highlight the package in this line.

Parameters:
line - input line
packageName - package name
Returns:
input line with linked package