org.apache.maven.jxr

Class JavaCodeTransform

public class JavaCodeTransform extends Object implements 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
 
Field Summary
static StringCOMMENT_END
end comment delimeter
static StringCOMMENT_START
start comment delimeter
static StringJAVADOC_COMMENT_END
end javadoc comment delimeter
static StringJAVADOC_COMMENT_START
start javadoc comment delimeter
static booleanLINE_NUMBERS
show line numbers
static StringRESERVED_WORD_END
end reserved word delimeter
static StringRESERVED_WORD_START
start reserved word delimeter
static StringSTRING_END
end String delimeter
static StringSTRING_START
start String delimeter
static StringSTYLESHEET_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 String[]VALID_URI_SCHEMES
Description of the Field
Constructor Summary
JavaCodeTransform(PackageManager packageManager)
Constructor for the JavaCodeTransform object
Method Summary
StringgetCurrentFilename()
Get the current filename
StringgetDestfile()
The current dest file being written
StringgetFooter()
Gets the footer attribute of the JavaCodeTransform object
StringgetHeader()
Gets the header attribute of the JavaCodeTransform object
StringgetPackageRoot()
From the current file, determine the package root based on the current path.
StringgetRevision()
The current revision of the CVS module
StringgetSourceDirectory()
The current source directory being read from.
StringgetSourcefile()
The current source file being read
voidsetCurrentFilename(String filename)
Set the current filename
StringsyntaxHighlight(String line)
Now different method of seeing if at end of input stream, closes inputs stream at end.
voidtransform(Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding, String outputEncoding, String javadocLinkDir, String revision, boolean showHeader, boolean showFooter)
This is the public method for doing all transforms of code.
voidtransform(String sourcefile, String destfile, Locale locale, String inputEncoding, String outputEncoding, String javadocLinkDir, String revision)
This is the public method for doing all transforms of code.
StringuriFilter(String line)
Given a line of text, search for URIs and make href's out of them
StringxrLine(String line, String packageName, ClassType classType)
Cross Reference the given line with JXR returning the new content.
StringxrLine(String line, String packageName)
Highlight the package in this line.

Field Detail

COMMENT_END

public static final String COMMENT_END
end comment delimeter

COMMENT_START

public static final String COMMENT_START
start comment delimeter

JAVADOC_COMMENT_END

public static final String JAVADOC_COMMENT_END
end javadoc comment delimeter

JAVADOC_COMMENT_START

public static final String JAVADOC_COMMENT_START
start javadoc comment delimeter

LINE_NUMBERS

public static final boolean LINE_NUMBERS
show line numbers

RESERVED_WORD_END

public static final String RESERVED_WORD_END
end reserved word delimeter

RESERVED_WORD_START

public static final String RESERVED_WORD_START
start reserved word delimeter

STRING_END

public static final String STRING_END
end String delimeter

STRING_START

public static final String STRING_START
start String delimeter

STYLESHEET_FILENAME

public static final String STYLESHEET_FILENAME
stylesheet file name

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

VALID_URI_SCHEMES

public static final String[] VALID_URI_SCHEMES
Description of the Field

Constructor Detail

JavaCodeTransform

public JavaCodeTransform(PackageManager packageManager)
Constructor for the JavaCodeTransform object

Parameters: packageManager PackageManager for this project

Method Detail

getCurrentFilename

public final String getCurrentFilename()
Get the current filename

Returns: String

getDestfile

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

Returns: destination file name

getFooter

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

Returns: String

getHeader

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

Returns: String

getPackageRoot

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

Returns: String

getRevision

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

Returns: String

getSourceDirectory

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

Returns: source directory

getSourcefile

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

Returns: source file name

setCurrentFilename

public final void setCurrentFilename(String filename)
Set the current filename

Parameters: filename String

syntaxHighlight

public final String syntaxHighlight(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

transform

public final void transform(Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding, String outputEncoding, String javadocLinkDir, String revision, boolean showHeader, boolean showFooter)
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: IOException

transform

public final void transform(String sourcefile, String destfile, Locale locale, String inputEncoding, String outputEncoding, String javadocLinkDir, String revision)
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: IOException

uriFilter

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

Parameters: line String

Returns: String

xrLine

public final String xrLine(String line, 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 String xrLine(String line, String packageName)
Highlight the package in this line.

Parameters: line input line packageName package name

Returns: input line with linked package

Copyright © {inceptionYear}-2008 Apache Software Foundation. All Rights Reserved.