org.makumba.devel
Class LineViewer

java.lang.Object
  extended by org.makumba.devel.LineViewer
All Implemented Interfaces:
SourceViewer
Direct Known Subclasses:
errorViewer, javaViewer, jspViewer, logicViewer, mddViewer

public abstract class LineViewer
extends Object
implements SourceViewer

a viewer that shows everything per line

Version:
$Id: LineViewer.java 5153 2010-05-18 21:37:50Z rosso_nero $
Author:
Stefan Baebler, Rudolf Mayer

Field Summary
protected  String additionalCodeStyleClasses
           
protected  String additionalHeaderInfo
          Store other info to be displayed in the header
protected  Error caughtError
           
protected  String contextPath
           
protected  File dir
           
protected  boolean hideLineNumbers
           
protected  Hashtable<String,String> importedClasses
           
protected  String[] importedPackages
          Default packages to be known.
protected  String jspClasspath
           
protected  String jspSourceViewExtension
           
protected  String logicPath
           
protected static String PARAM_HIDE_LINES
           
protected  Throwable parseError
           
protected  boolean printHeaderFooter
           
protected  boolean printLineNumbers
           
protected  Reader reader
           
protected  String realPath
           
protected  HttpServletRequest request
           
protected  boolean searchCompiledJSPClasses
           
protected  boolean searchJavaClasses
           
protected  boolean searchJSPPages
           
protected  boolean searchMDD
           
protected  String servletPath
           
protected  String title
           
protected  String virtualPath
           
 
Constructor Summary
LineViewer(boolean printLineNumbers, HttpServletRequest request)
           
LineViewer(boolean printLineNumbers, HttpServletRequest request, ServletContext servletContext)
           
 
Method Summary
protected  void addImportedPackages(HashSet<String> newPackages)
           
 Class<?> findClass(String className)
           
 Class<?> findClassSimple(String s)
          Searches for Java Classes with the given name FIXME: still needed?
 String findCompiledJSP(String s)
          Find the path to the compiled JSP file from the name of a compiled JSP class
 String findCompiledJSPClassName(String compiledJSPDirectory, String jspPageName)
          Find the path to the compiled JSP file from the name of the original JSP page
 String findPage(String s)
          Finds a JSP page with the given name.
 void footer(PrintWriter printWriter)
          Write the page footer to the given writer.
 String formatClassLink(Class<?> c, String methodName, String displayName)
           
 String formatClassLink(String qualifiedClassName, String className, Integer lineNumber)
           
 String formatJSPLink(String jspPage, String token, Integer lineNumber)
           
 String formatMakumbaLink(String token)
           
 String formatMDDLink(String mddName)
           
 String formatSunTaglibLink(String token)
           
 File getDirectory()
          if this resource is actually a directory, returns not null
 String getLineTag(String s)
           
 StringTokenizer getLineTokenizer(String s)
           
 Reader getReader()
           
 String htmlEscape(String s)
          Escapes a string to HTML-conform format.
protected  void intro(PrintWriter printWriter)
          Write the page header to the given writer.
static void main(String[] args)
           
 String parseLine(String s)
          Processes one line of code, and adds links for MDDs JSP pages Java Classes from JSP pages generated Java classes Subclasses that want to provide any additional formatting (syntax highlighting, etc) should extend this method, apply their formatting and before/afterwards call this method.
 void parseText(PrintWriter writer)
          parse the text and write the output
protected  void printFileRelations(PrintWriter writer)
           
 void printLine(PrintWriter printWriter, String s, String toPrint)
           
 void printPageBegin(PrintWriter writer)
          Write the beginning of the page to the given writer.
protected  void printPageBeginAdditional(PrintWriter printWriter)
           
 void printPageEnd(PrintWriter writer)
           
protected  String printVersionControlLink()
          Prints a link to the page CVS/SVN for the file currently viewed.
(package private)  void readFromURL(URL u)
           
 void setSearchLevels(boolean searchJSPPages, boolean searchCompiledJSPClasses, boolean searchJavaClasses, boolean searchMDD)
          Sets the amount of links to other files the viewer is trying to find. changing some of these parameters can significantely speed up the viewing process.
protected  void writeAdditionalLinks(PrintWriter writer)
           
protected  void writeLineNumber(PrintWriter writer, int n, boolean initialVisibility)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_HIDE_LINES

protected static final String PARAM_HIDE_LINES
See Also:
Constant Field Values

realPath

protected String realPath

additionalHeaderInfo

protected String additionalHeaderInfo
Store other info to be displayed in the header


virtualPath

protected String virtualPath

contextPath

protected String contextPath

reader

protected Reader reader

printLineNumbers

protected boolean printLineNumbers

dir

protected File dir

title

protected String title

searchJSPPages

protected boolean searchJSPPages

searchCompiledJSPClasses

protected boolean searchCompiledJSPClasses

searchJavaClasses

protected boolean searchJavaClasses

searchMDD

protected boolean searchMDD

jspSourceViewExtension

protected String jspSourceViewExtension

jspClasspath

protected String jspClasspath

request

protected HttpServletRequest request

servletPath

protected String servletPath

logicPath

protected String logicPath

additionalCodeStyleClasses

protected String additionalCodeStyleClasses

hideLineNumbers

protected boolean hideLineNumbers

importedPackages

protected String[] importedPackages
Default packages to be known. Use JavaParseData.getImportedPackages() to add more


importedClasses

protected Hashtable<String,String> importedClasses

caughtError

protected Error caughtError

printHeaderFooter

protected boolean printHeaderFooter

parseError

protected Throwable parseError
Constructor Detail

LineViewer

public LineViewer(boolean printLineNumbers,
                  HttpServletRequest request)

LineViewer

public LineViewer(boolean printLineNumbers,
                  HttpServletRequest request,
                  ServletContext servletContext)
Method Detail

addImportedPackages

protected void addImportedPackages(HashSet<String> newPackages)

getDirectory

public File getDirectory()
if this resource is actually a directory, returns not null

Specified by:
getDirectory in interface SourceViewer

getReader

public Reader getReader()

readFromURL

void readFromURL(URL u)
           throws IOException
Throws:
IOException

parseText

public void parseText(PrintWriter writer)
               throws IOException
parse the text and write the output

Specified by:
parseText in interface SourceViewer
Throws:
IOException

writeLineNumber

protected void writeLineNumber(PrintWriter writer,
                               int n,
                               boolean initialVisibility)

printPageEnd

public void printPageEnd(PrintWriter writer)
                  throws IOException
Parameters:
writer -
Throws:
IOException

printPageBegin

public void printPageBegin(PrintWriter writer)
                    throws IOException
Write the beginning of the page to the given writer.

Throws:
IOException

printFileRelations

protected void printFileRelations(PrintWriter writer)

intro

protected void intro(PrintWriter printWriter)
              throws IOException
Write the page header to the given writer.

Throws:
IOException

printPageBeginAdditional

protected void printPageBeginAdditional(PrintWriter printWriter)
                                 throws IOException
Throws:
IOException

printVersionControlLink

protected String printVersionControlLink()
Prints a link to the page CVS/SVN for the file currently viewed.


writeAdditionalLinks

protected void writeAdditionalLinks(PrintWriter writer)

footer

public void footer(PrintWriter printWriter)
            throws IOException
Write the page footer to the given writer.

Throws:
IOException

printLine

public void printLine(PrintWriter printWriter,
                      String s,
                      String toPrint)
               throws IOException
Throws:
IOException

getLineTag

public String getLineTag(String s)

setSearchLevels

public void setSearchLevels(boolean searchJSPPages,
                            boolean searchCompiledJSPClasses,
                            boolean searchJavaClasses,
                            boolean searchMDD)
Sets the amount of links to other files the viewer is trying to find. changing some of these parameters can significantely speed up the viewing process.

Parameters:
searchJSPPages - whether to search for .jsp files.
searchCompiledJSPClasses - wheter to search for compiled jsp files, i.e. files with the extension _jsp.java
searchJavaClasses - wheter to search for java source files.
searchMDD - whether to search for Makumba Data Definitions, .mdd files (and Inlcuded Data Defitions, .idd).

parseLine

public String parseLine(String s)
Processes one line of code, and adds links for Subclasses that want to provide any additional formatting (syntax highlighting, etc) should extend this method, apply their formatting and before/afterwards call this method. This method is rather time-consuming, and subclasses interested in providing links just to a part of the above should use the setSearchLevels method to specify for what types of files are searched for.

Parameters:
s - the unformatted code line.
Returns:
The formatted code line.

formatJSPLink

public String formatJSPLink(String jspPage,
                            String token,
                            Integer lineNumber)
Parameters:
jspPage -
result -
token -

formatClassLink

public String formatClassLink(String qualifiedClassName,
                              String className,
                              Integer lineNumber)
Parameters:
className -
token -
Returns:

formatMDDLink

public String formatMDDLink(String mddName)
Parameters:
token -
Returns:

formatMakumbaLink

public String formatMakumbaLink(String token)
Parameters:
result -
token -

formatSunTaglibLink

public String formatSunTaglibLink(String token)
Parameters:
token -
Returns:

getLineTokenizer

public StringTokenizer getLineTokenizer(String s)
Parameters:
s -
Returns:

findPage

public String findPage(String s)
Finds a JSP page with the given name.

Parameters:
s - The page to search for
Returns:
The page found, null otherwise

findClassSimple

public Class<?> findClassSimple(String s)
Searches for Java Classes with the given name FIXME: still needed?

Parameters:
s - The class name to search for
Returns:
The class, if found, null otherwise.

findCompiledJSP

public String findCompiledJSP(String s)
Find the path to the compiled JSP file from the name of a compiled JSP class


findCompiledJSPClassName

public String findCompiledJSPClassName(String compiledJSPDirectory,
                                       String jspPageName)
Find the path to the compiled JSP file from the name of the original JSP page


htmlEscape

public String htmlEscape(String s)
Escapes a string to HTML-conform format.

Parameters:
s - The string to escape
Returns:
The given, with &, < and > escaped.

findClass

public Class<?> findClass(String className)
Parameters:
token -
Returns:

formatClassLink

public String formatClassLink(Class<?> c,
                              String methodName,
                              String displayName)

main

public static void main(String[] args)