01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.tools.ant.types.selectors;
20:
21: /**
22: * This selector has one other selectors whose meaning it inverts. It
23: * actually relies on NoneSelector for its implementation of the
24: * isSelected() method, but it adds a check to ensure there is only one
25: * other selector contained within.
26: *
27: * @since 1.5
28: */
29: public class NotSelector extends NoneSelector {
30:
31: /**
32: * Default constructor.
33: */
34: public NotSelector() {
35: }
36:
37: /**
38: * Constructor that inverts the meaning of its argument.
39: * @param other the selector to invert
40: * @since Ant 1.7
41: */
42: public NotSelector(FileSelector other) {
43: this ();
44: appendSelector(other);
45: }
46:
47: /**
48: * @return a string representation of the selector
49: */
50: public String toString() {
51: StringBuffer buf = new StringBuffer();
52: if (hasSelectors()) {
53: buf.append("{notselect: ");
54: buf.append(super .toString());
55: buf.append("}");
56: }
57: return buf.toString();
58: }
59:
60: /**
61: * Makes sure that there is only one entry, sets an error message if
62: * not.
63: */
64: public void verifySettings() {
65: if (selectorCount() != 1) {
66: setError("One and only one selector is allowed within the "
67: + "<not> tag");
68: }
69: }
70:
71: }
|