-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkipTextHandler.java
More file actions
100 lines (88 loc) · 2.74 KB
/
SkipTextHandler.java
File metadata and controls
100 lines (88 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package EDU.bmrb.starlibj;
import java.lang.*;
import java.util.*;
public class SkipTextHandler
{
/** This constructor initializes the handler to have no skipped
* values yet
*/
public SkipTextHandler( )
{
skipTexts = new Vector();
skipLineNums = new Vector();
}
public SkipTextHandler( SkipTextHandler copyMe )
{
skipTexts = new Vector( copyMe.skipTexts );
skipLineNums = new Vector( copyMe.skipLineNums );
}
/** This <b>is</b> implemented in this class. See the parent
* class "StarNode" for an explanation
*/
public void setSkipTexts( Vector texts, Vector ints )
{
if( texts != null )
skipTexts.addAll(0,texts);
if( ints != null )
skipLineNums.addAll(0,ints);
}
/** for debugging */
public void dumpSkipTexts( )
{
int i;
int subLen;
System.err.println( "::::DUMP OF SkipTextHandler::::" );
if( skipTexts == null )
System.err.println( "NULL" );
for( i = 0 ; i < skipTexts.size(); i++ )
{
subLen = ((StringBuffer) skipTexts.elementAt(i)).length();
if( subLen > 500 )
subLen = 500;
System.err.println( "index " + String.valueOf(i) + ": line " +
((Integer) skipLineNums.elementAt(i)).toString() +
" : " );
System.err.println( "\t" +
((StringBuffer) skipTexts.elementAt(i)).substring( 0, subLen ) );
System.err.println( "=====================================" );
}
}
/** This <b>is</b> implemented in this class. See the parent
* class "StarNode" for an explanation
*/
public StringBuffer getSkipText( int i )
{
return (StringBuffer) skipTexts.elementAt( i );
}
/** This <b>is</b> implemented in this class. See the parent
* class "StarNode" for an explanation
*/
public int getNumSkipTexts( )
{
return skipTexts.size();
}
/** This <b>is</b> implemented in this class. See the parent
* class "StarNode" for an explanation
*/
public int getSkipTextBetween( int line1,
int line2,
StringBuffer retString )
{
int i, sz;
String tmpString;
int retVal = -1;
sz = skipLineNums.size();
for( i = 0 ; i < sz ; i++ )
{ if( ((Integer)skipLineNums.elementAt(i)).intValue() >= line1 &&
((Integer)skipLineNums.elementAt(i)).intValue() <= line2 )
{ retVal = ((Integer)skipLineNums.elementAt(i)).intValue();
tmpString = ((StringBuffer) skipTexts.elementAt(i)).toString();
retString.replace( 0, tmpString.length(), tmpString );
break;
}
}
return retVal;
}
protected Vector skipTexts;
protected Vector skipLineNums;
}