Skip to content

Package: ArgumentListBuilder

ArgumentListBuilder

nameinstructionbranchcomplexitylinemethod
ArgumentListBuilder()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
add(File)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
add(Path)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
add(String)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
add(URL)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
addAll(Collection)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
invoke(WsTool)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test.util;
12:
13: import com.sun.xml.ws.test.tool.WsTool;
14: import org.apache.tools.ant.types.Path;
15:
16: import java.io.File;
17: import java.net.URL;
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.List;
21:
22: /**
23: * Provide convenient methods for building up command-line arguments.
24: *
25: * <p>
26: * This class can be used in a chained-invocation style like {@link StringBuilder}.
27: *
28: * @author Kohsuke Kawaguchi
29: */
30: public final class ArgumentListBuilder {
31: private final List<String> args = new ArrayList<String>();
32:
33: public ArgumentListBuilder add(String token) {
34: args.add(token);
35: return this;
36: }
37:
38: /**
39: * Adds a file path as an argument.
40: */
41: public ArgumentListBuilder add(File path) {
42: return add(path.getAbsoluteFile().getPath());
43: }
44:
45: public ArgumentListBuilder add(URL path) {
46: return add(path.toExternalForm());
47: }
48:
49: /**
50: * Invokes the tool with arguments built so far.
51: */
52: public void invoke(WsTool tool) throws Exception {
53: tool.invoke(args.toArray(new String[args.size()]));
54: }
55:
56: public ArgumentListBuilder add(Path cp) {
57: return add(cp.toString());
58: }
59:
60: public ArgumentListBuilder addAll(Collection<String> values) {
61: args.addAll(values);
62: return this;
63: }
64:
65:
66: public String toString() {
67: return args.toString();
68: }
69: }