Package: ParsedCommand

ParsedCommand

nameinstructionbranchcomplexitylinemethod
ParsedCommand(String, String[])
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 37 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
getArguments()
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%
getCommand()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hashCode()
M: 25 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
toString()
M: 32 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.shell.internal.parsing;
13:
14: import java.util.Arrays;
15:
16: /**
17: * A <code>ParsedCommand</code> represents a command that has been parsed into the top-level command and its arguments.
18: * <p />
19: *
20: * <strong>Concurrent Semantics</strong><br />
21: *
22: * Thread-safe.
23: *
24: */
25: public final class ParsedCommand {
26:
27: private final String command;
28:
29: private final String[] arguments;
30:
31: public ParsedCommand(String command, String[] arguments) {
32: this.command = command;
33: this.arguments = arguments.clone();
34: }
35:
36: public String getCommand() {
37: return command;
38: }
39:
40: public String[] getArguments() {
41: return arguments.clone();
42: }
43:
44: public String toString() {
45: StringBuilder builder = new StringBuilder(command);
46:
47:• for (String arg : this.arguments) {
48: builder.append(" ").append(arg);
49: }
50: return builder.toString();
51: }
52:
53: @Override
54: public int hashCode() {
55: final int prime = 31;
56: int result = 1;
57: result = prime * result + Arrays.hashCode(this.arguments);
58:• result = prime * result + ((this.command == null) ? 0 : this.command.hashCode());
59: return result;
60: }
61:
62: @Override
63: public boolean equals(Object obj) {
64:• if (this == obj)
65: return true;
66:• if (obj == null)
67: return false;
68:• if (getClass() != obj.getClass())
69: return false;
70: ParsedCommand other = (ParsedCommand) obj;
71:• if (!Arrays.equals(this.arguments, other.arguments))
72: return false;
73:• if (!this.command.equals(other.command))
74: return false;
75: return true;
76: }
77:
78: }