Line | |
---|
1 | package ise.antelope.tasks.typedefs.string;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Copyright 2003
|
---|
5 | *
|
---|
6 | * @version $Revision: 1.1 $
|
---|
7 | */
|
---|
8 | public class Substring implements StringOp {
|
---|
9 |
|
---|
10 | private int beginIndex = 0;
|
---|
11 | private int endIndex = -1;
|
---|
12 |
|
---|
13 | public void setBeginindex(int i) {
|
---|
14 | if (i < 0)
|
---|
15 | throw new IllegalArgumentException("beginindex must be <= 0");
|
---|
16 | beginIndex = i;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public void setEndindex(int i) {
|
---|
20 | if (i < 0)
|
---|
21 | throw new IllegalArgumentException("endindex must be <= 0");
|
---|
22 | endIndex = i;
|
---|
23 | }
|
---|
24 | /**
|
---|
25 | * Description of the Method
|
---|
26 | *
|
---|
27 | * @param s
|
---|
28 | * @return Description of the Returned Value
|
---|
29 | */
|
---|
30 | public String execute(String s) {
|
---|
31 | if (s == null)
|
---|
32 | return "";
|
---|
33 | if (beginIndex == endIndex)
|
---|
34 | return "";
|
---|
35 | if (endIndex == -1)
|
---|
36 | endIndex = s.length();
|
---|
37 | if (endIndex < beginIndex)
|
---|
38 | throw new IllegalArgumentException("endindex must be greater than beginindex");
|
---|
39 | return s.substring(beginIndex, endIndex);
|
---|
40 |
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.