com.borland.jbuilder.runtime.jsp
Class JspSourceBridge

java.lang.Object
  |
  +--com.borland.jbuilder.runtime.jsp.JspSourceBridge

public abstract class JspSourceBridge
extends java.lang.Object

The JspSourceBridge is used by the debugger to translate JSP file names and line numbers into their Java equivalents and vice versa. The translation is JSP engine-specific; subclasses must implement the particulars for the server they support.

JPDA produces a Java file name with no path, so the fully-qualified class name is also needed to uniquely identify the file. Together, these two values form what is referred to in this class as a "Java path"; e.g. "com/whatever/Jsp1.java". Note that this is not a valid absolute path, which is needed to reference the actual generated Java file for translation.

The forward slash is used for all path separators.


Field Summary
protected  ServerDescriptor descriptor
           
protected  JBProject project
           
static int UNMAPPED_LINE
           
 
Constructor Summary
JspSourceBridge(JBProject jbProject, ServerDescriptor serverDescriptor)
           
 
Method Summary
protected abstract  java.lang.String deriveJavaPattern(java.lang.String jspFile)
          Returns JSP engine-specific Java class name for a given JSP file.
protected abstract  java.lang.String deriveJspFile(java.lang.String className, java.lang.String javaFile)
          Returns JSP file, which is probably somewhere in the project tree, that generated a given Java class in a given Java file.
 void foundJspFile(Url jspUrl, java.lang.String className, java.lang.String javaFile)
          Callback method for debugger when it encounters a Java class in a file that (it thinks) matches a JSP file being debugged (one with a line breakpoint).
 Url getJavaFile(java.lang.String className, java.lang.String javaFile)
          Given a Java class name and source file generated for a JSP, returns a URL for the actual location of that file, if it exists.
 int getJavaLine(Url jspUrl, int jspLine)
          Given a JSP file and line number in that file, returns the corresponding line number in the generated Java file.
 java.lang.String getJavaPattern(Url jspUrl)
          Given a URL for a JSP file, returns a pattern to match the fully-qualified generated class name, with as much detail as possible; at a minimum it must include the actual package name.
 Url getJspFile(java.lang.String className, java.lang.String javaFile)
          Given a Java class name and source file, returns a URL for the JSP file that generated that Java class, if that class is from a JSP.
 int getJspLine(java.lang.String className, java.lang.String javaFile, int javaLine)
          Given a Java class name, source file, and line number in that file, returns the corresponding line number in the JSP that generated the class.
 int[] getJspLines(java.lang.String className, java.lang.String javaFile, int[] javaLines)
          Given a Java class name, source file, and lines number in that file, returns the corresponding lines number in the JSP that generated the class.
protected abstract  java.lang.String locateJavaFile(java.lang.String className, java.lang.String javaFile)
          Returns the actual location of the given generated-for-JSP Java file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNMAPPED_LINE

public static final int UNMAPPED_LINE

project

protected JBProject project

descriptor

protected ServerDescriptor descriptor
Constructor Detail

JspSourceBridge

public JspSourceBridge(JBProject jbProject,
                       ServerDescriptor serverDescriptor)
Method Detail

deriveJavaPattern

protected abstract java.lang.String deriveJavaPattern(java.lang.String jspFile)
Returns JSP engine-specific Java class name for a given JSP file. The generated name usually includes the full path of the JSP file in some way, as part of the package or class name.
Parameters:
jspFile - absolute path of JSP file
Returns:
String containing pattern for equivalent Java source

deriveJspFile

protected abstract java.lang.String deriveJspFile(java.lang.String className,
                                                  java.lang.String javaFile)
Returns JSP file, which is probably somewhere in the project tree, that generated a given Java class in a given Java file. If the given class could not be from a JSP, return null. Note that the className parameter may not be needed.
Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
Returns:
name of JSP that generated the class; null if class cannot be from a JSP

locateJavaFile

protected abstract java.lang.String locateJavaFile(java.lang.String className,
                                                   java.lang.String javaFile)
Returns the actual location of the given generated-for-JSP Java file. The file is probably located in under the docBase's work directory, perhaps in a directory using the hostname, port number, and context name; e.g. c:/MyJava/myproject/work/localhost_8080/myproject_Jsp1.java. Note that the className parameter may not be needed.
Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
Returns:
absolute path to where actual JSP-Java file would be found.

getJavaPattern

public java.lang.String getJavaPattern(Url jspUrl)
Given a URL for a JSP file, returns a pattern to match the fully-qualified generated class name, with as much detail as possible; at a minimum it must include the actual package name. Asterisks are allowed in the class name portion -- e.g. com.this.that.whatever.*NameOfJspFile* -- but such a pattern should differentiate between a JSP file and a similarly named bean -- e.g. the classes for Jsp1.jsp and Jsp1Bean.java -- if the JSP engine happens to generate JSPs in the same package as the bean (Tomcat does not do this).

This pattern is used by the debugger to request notification from JPDA when a class that looks like one for the JSP is prepared.

Parameters:
jspUrl - Url object that references JSP file
Returns:
String containing pattern for equivalent Java source

foundJspFile

public void foundJspFile(Url jspUrl,
                         java.lang.String className,
                         java.lang.String javaFile)
Callback method for debugger when it encounters a Java class in a file that (it thinks) matches a JSP file being debugged (one with a line breakpoint). This association is recorded so that the reverse -- "What JSP file is the source for Java file X?" -- can be ascertained.

Only the first association between a particular Java file and JSP is recorded. Subsequent calls for the same Java file are ignored.

Parameters:
jspUrl - Url object that references JSP file
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
See Also:
getJspFile(java.lang.String, java.lang.String)

getJspFile

public Url getJspFile(java.lang.String className,
                      java.lang.String javaFile)
Given a Java class name and source file, returns a URL for the JSP file that generated that Java class, if that class is from a JSP. If the association was previously found by the debugger, the result is known. Otherwise, the Java class information must be examined to determine if the class could have come from a JSP, using the JSP engine-specific naming conventions. If so, the JSP file name must be derived; if not, return null to indicate the class (probably) did not come from a JSP. If the JSP file does not or no longer exists, return null as well.

This method is called by the debugger when it encounters a new class during debugging, after it determined that it is not a plain Java class in the project or one of the project's libraries.

Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
Returns:
Url for JSP that generated the class; null if class is not from a JSP or that JSP cannot be found.
See Also:
foundJspFile(com.borland.primetime.vfs.Url, java.lang.String, java.lang.String)

getJavaFile

public Url getJavaFile(java.lang.String className,
                       java.lang.String javaFile)
Given a Java class name and source file generated for a JSP, returns a URL for the actual location of that file, if it exists.
Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
Returns:
URL for actual JSP-Java file; null if the file does not exist

getJspLine

public int getJspLine(java.lang.String className,
                      java.lang.String javaFile,
                      int javaLine)
Given a Java class name, source file, and line number in that file, returns the corresponding line number in the JSP that generated the class.
Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
javaLine - line number in Java file
Returns:
corresponding line number in JSP file, or UNMAPPED_LINE if there is no JSP file for the Java class

getJspLines

public int[] getJspLines(java.lang.String className,
                         java.lang.String javaFile,
                         int[] javaLines)
Given a Java class name, source file, and lines number in that file, returns the corresponding lines number in the JSP that generated the class.
Parameters:
className - fully-qualified class name (possibly inner class)
javaFile - name of Java file that contains the class (no path)
javaLine - lines number in Java file
Returns:
corresponding lines number in JSP file, or zero line number if there is no JSP file for the Java class

getJavaLine

public int getJavaLine(Url jspUrl,
                       int jspLine)
Given a JSP file and line number in that file, returns the corresponding line number in the generated Java file.
Parameters:
jspUrl - Url object that references JSP file
jspLine - line number in JSP file
Returns:
corresponding line number in Java file, or UNMAPPED_LINE if there no Java file has been mapped for the JSP