org.apache.maven.jxr
Class JavaCodeTransform

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

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
 

See Also:
Serialized Form

Field Summary
static String COMMENT_END
          end comment delimiter
static String COMMENT_START
          start comment delimiter
static String JAVADOC_COMMENT_END
          end javadoc comment delimiter
static String JAVADOC_COMMENT_START
          start javadoc comment delimiter
static boolean LINE_NUMBERS
          show line numbers
static String RESERVED_WORD_END
          end reserved word delimiter
static String RESERVED_WORD_START
          start reserved word delimiter
static String STRING_END
          end String delimiter
static String STRING_START
          start String delimiter
static 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 String[] VALID_URI_SCHEMES
          Description of the Field
 
Constructor Summary
JavaCodeTransform(PackageManager packageManager)
          Constructor for the JavaCodeTransform object
 
Method Summary
 String getCurrentFilename()
          Get the current filename
 String getDestfile()
          The current destination file being written
 String getFooter()
          Gets the footer attribute of the JavaCodeTransform object
 String getHeader()
          Gets the header attribute of the JavaCodeTransform object
 String getPackageRoot()
          From the current file, determine the package root based on the current path.
 String getRevision()
          The current revision of the CVS module
 String getSourceDirectory()
          The current source directory being read from.
 String getSourcefile()
          The current source file being read
 void setCurrentFilename(String filename)
          Set the current filename
 String syntaxHighlight(String line)
          Now different method of seeing if at end of input stream, closes inputs stream at end.
 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.
 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.
 String uriFilter(String line)
          Given a line of text, search for URIs and make href's out of them
 String xrLine(String line, String packageName)
          Highlight the package in this line.
 String xrLine(String line, 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 String COMMENT_START
start comment delimiter

See Also:
Constant Field Values

COMMENT_END

public static final String COMMENT_END
end comment delimiter

See Also:
Constant Field Values

JAVADOC_COMMENT_START

public static final String JAVADOC_COMMENT_START
start javadoc comment delimiter

See Also:
Constant Field Values

JAVADOC_COMMENT_END

public static final String JAVADOC_COMMENT_END
end javadoc comment delimiter

See Also:
Constant Field Values

STRING_START

public static final String STRING_START
start String delimiter

See Also:
Constant Field Values

STRING_END

public static final String STRING_END
end String delimiter

See Also:
Constant Field Values

RESERVED_WORD_START

public static final String RESERVED_WORD_START
start reserved word delimiter

See Also:
Constant Field Values

RESERVED_WORD_END

public static final String RESERVED_WORD_END
end reserved word delimiter

See Also:
Constant Field Values

STYLESHEET_FILENAME

public static final String STYLESHEET_FILENAME
stylesheet file name

See Also:
Constant Field Values

VALID_URI_SCHEMES

public static final 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 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

getHeader

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

Returns:
String

getFooter

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

Returns:
String

transform

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

transform

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

getCurrentFilename

public final String getCurrentFilename()
Get the current filename

Returns:
String

setCurrentFilename

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

Parameters:
filename - String

getPackageRoot

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

Returns:
String

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

getRevision

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

Returns:
String

getSourcefile

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

Returns:
source file name

getDestfile

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

Returns:
destination file name

getSourceDirectory

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

Returns:
source directory

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 © 2002-2012 Apache Software Foundation. All Rights Reserved.