Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTargetArgParser.java
41161 views
1
/*
2
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
package nsk.share.aod;
24
25
import nsk.share.*;
26
import java.util.*;
27
28
public class AODTargetArgParser extends ArgumentParser {
29
30
public static final String agentsNumberParam = "agentsNumber";
31
32
public static final String socketPortParam = "port";
33
34
private int expectedAgentsNumber;
35
36
private int port;
37
38
private static List<String> supportedOptions;
39
40
static {
41
supportedOptions = new ArrayList<String>();
42
supportedOptions.add(agentsNumberParam);
43
supportedOptions.add(socketPortParam);
44
}
45
46
public AODTargetArgParser(String[] args) {
47
super(args);
48
}
49
50
protected boolean checkOption(String option, String value) {
51
if (super.checkOption(option, value))
52
return true;
53
54
if (!supportedOptions.contains(option))
55
return false;
56
57
if (option.equals(agentsNumberParam)) {
58
expectedAgentsNumber = Integer.parseInt(value);
59
if (expectedAgentsNumber < 0)
60
throw new TestBug("Invalid value of '" + option + "'");
61
} else if (option.equals(socketPortParam)) {
62
port = Integer.parseInt(value);
63
if (port <= 0 || port > 65535)
64
throw new TestBug("Invalid value of '" + option + "':" + port +" (it is expected to be in the range [1..65535]");
65
}
66
67
return true;
68
}
69
70
public int getExpectedAgentsNumber() {
71
if (!options.containsKey(agentsNumberParam))
72
throw new TestBug("Number of expected agents isn't specified");
73
74
return expectedAgentsNumber;
75
}
76
77
public int getPort() {
78
if (!options.containsKey(socketPortParam))
79
return -1;
80
81
return port;
82
}
83
}
84
85