1 | /*
|
---|
2 | * Copyright 2002,2004-2005 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 |
|
---|
18 | package org.apache.tools.ant.util.facade;
|
---|
19 |
|
---|
20 | import org.apache.tools.ant.types.Commandline;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Extension of Commandline.Argument with a new attribute that choses
|
---|
24 | * a specific implementation of the facade.
|
---|
25 | *
|
---|
26 | *
|
---|
27 | * @since Ant 1.5
|
---|
28 | */
|
---|
29 | public class ImplementationSpecificArgument extends Commandline.Argument {
|
---|
30 | private String impl;
|
---|
31 |
|
---|
32 | /** Constructor for ImplementationSpecificArgument. */
|
---|
33 | public ImplementationSpecificArgument() {
|
---|
34 | super();
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Set the implementation this argument is for.
|
---|
39 | * @param impl the implementation this command line argument is for.
|
---|
40 | */
|
---|
41 | public void setImplementation(String impl) {
|
---|
42 | this.impl = impl;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Return the parts this Argument consists of, if the
|
---|
47 | * implementation matches the chosen implementation.
|
---|
48 | * @see Commandline.Argument#getParts()
|
---|
49 | * @param chosenImpl the implementation to check against.
|
---|
50 | * @return the parts if the implemention matches or an zero length
|
---|
51 | * array if not.
|
---|
52 | */
|
---|
53 | public final String[] getParts(String chosenImpl) {
|
---|
54 | if (impl == null || impl.equals(chosenImpl)) {
|
---|
55 | return super.getParts();
|
---|
56 | } else {
|
---|
57 | return new String[0];
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|