| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package lockedregioncodeinjection; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public class LockTarget { |
| 22 |
public static final LockTarget NO_TARGET = new LockTarget("", null, null); |
| 23 |
|
| 24 |
|
| 25 |
private final String targetDesc; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
private final String pre; |
| 30 |
private final String post; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
private final boolean scoped; |
| 36 |
|
| 37 |
public LockTarget(String targetDesc, String pre, String post, boolean scoped) { |
| 38 |
this.targetDesc = targetDesc; |
| 39 |
this.pre = pre; |
| 40 |
this.post = post; |
| 41 |
this.scoped = scoped; |
| 42 |
} |
| 43 |
|
| 44 |
public LockTarget(String targetDesc, String pre, String post) { |
| 45 |
this(targetDesc, pre, post, false); |
| 46 |
} |
| 47 |
|
| 48 |
public String getTargetDesc() { |
| 49 |
return targetDesc; |
| 50 |
} |
| 51 |
|
| 52 |
public String getPre() { |
| 53 |
return pre; |
| 54 |
} |
| 55 |
|
| 56 |
public String getPreOwner() { |
| 57 |
if (scoped) { |
| 58 |
return targetDesc.substring(1, targetDesc.length() - 1); |
| 59 |
} else { |
| 60 |
return pre.substring(0, pre.lastIndexOf('.')); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
public String getPreMethod() { |
| 65 |
return pre.substring(pre.lastIndexOf('.') + 1); |
| 66 |
} |
| 67 |
|
| 68 |
public String getPost() { |
| 69 |
return post; |
| 70 |
} |
| 71 |
|
| 72 |
public String getPostOwner() { |
| 73 |
if (scoped) { |
| 74 |
return targetDesc.substring(1, targetDesc.length() - 1); |
| 75 |
} else { |
| 76 |
return post.substring(0, post.lastIndexOf('.')); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
public String getPostMethod() { |
| 81 |
return post.substring(post.lastIndexOf('.') + 1); |
| 82 |
} |
| 83 |
|
| 84 |
public boolean getScoped() { |
| 85 |
return scoped; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public String toString() { |
| 90 |
return targetDesc + ":" + pre + ":" + post; |
| 91 |
} |
| 92 |
} |