1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 */
14package lockedregioncodeinjection;
15
16/**
17 * Represent a specific class that is used for synchronization. A pre and post method can be
18 * specified to by the user to be called right after monitor_enter and after monitor_exit
19 * respectively.
20 */
21public class LockTarget {
22    public static final LockTarget NO_TARGET = new LockTarget("", null, null);
23
24    private final String targetDesc;
25    private final String pre;
26    private final String post;
27
28    public LockTarget(String targetDesc, String pre, String post) {
29        this.targetDesc = targetDesc;
30        this.pre = pre;
31        this.post = post;
32    }
33
34    public String getTargetDesc() {
35        return targetDesc;
36    }
37
38    public String getPre() {
39        return pre;
40    }
41
42    public String getPreOwner() {
43        return pre.substring(0, pre.lastIndexOf('.'));
44    }
45
46    public String getPreMethod() {
47        return pre.substring(pre.lastIndexOf('.') + 1);
48    }
49
50    public String getPost() {
51        return post;
52    }
53
54    public String getPostOwner() {
55        return post.substring(0, post.lastIndexOf('.'));
56    }
57
58    public String getPostMethod() {
59        return post.substring(post.lastIndexOf('.') + 1);
60    }
61}
62