Hiding fragments of the source

Warning - java2web is now obsolete. Please use its successor: code2web

back to index

Sometimes not all of the source code is relevant and you might want to hide the portions that are not relevant to what you are saying in your web page. For example;

0166    
// We have several possibilites. See which one we have imported
0167 for (String qualifiedClassName : possibilities) { 0168 int dot = qualifiedClassName.lastIndexOf("."); 0169 String packageName = qualifiedClassName.substring(0,dot); 0177 for (String qualifiedClassName : possibilities) { 0178 if (qualifiedClassName.equals("java.lang."+className)) 0179 return "java.lang."+className; 0180 }

You can do this with the following methods:

HTMLConverter

void hide( int startLine, int endLine )
void clearHiddenZones()
void hide( String zones )

The last method takes a sequence of comma-separated ranges using the syntax: "start line..end line, start line .. end line, ...". For example:

conv.highlight("2..5,88,109..125");

will hides lines from 2 through 5 inclusive, line 88 and lines 109 through 125 inclusive.

Java2Web

If you are using Java2Web, you define the zones to highlight using the --hide option and the compact syntax described above:

java2web ... --hide="2..5,88,109..125" ...

JSP Tag

If you are using the JSP tag, you use the hide attribute with the same syntax.

<j2w:convert ... hide="2..5,88,109..125" ... >

In all cases, the hidden zone is replaced with an ellipsis (...), whose style is controlled by the hiddenZoneStyle property. The default value is "hidden"

HTMLConverter   String getHiddenZoneStyle()
void setHiddenZoneStyle( String style )
Java2Web   java2web ... --hiddenZoneStyle = xxxxx ...
<j2w:convert>   <j2w:convert ... hiddenZoneStyle="style" ... >