01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.springframework.beans.factory.parsing;
18:
19: import org.springframework.util.Assert;
20:
21: /**
22: * {@link ParseState} entry representing a (possibly indexed)
23: * constructor argument.
24: *
25: * @author Rob Harrop
26: * @author Juergen Hoeller
27: * @since 2.0
28: */
29: public class ConstructorArgumentEntry implements ParseState.Entry {
30:
31: private final int index;
32:
33: /**
34: * Creates a new instance of the {@link ConstructorArgumentEntry} class
35: * representing a constructor argument with a (currently) unknown index.
36: */
37: public ConstructorArgumentEntry() {
38: this .index = -1;
39: }
40:
41: /**
42: * Creates a new instance of the {@link ConstructorArgumentEntry} class
43: * representing a constructor argument at the supplied <code>index</code>.
44: * @param index the index of the constructor argument
45: * @throws IllegalArgumentException if the supplied <code>index</code>
46: * is less than zero
47: */
48: public ConstructorArgumentEntry(int index) {
49: Assert
50: .isTrue(index >= 0,
51: "Constructor argument index must be greater than or equal to zero");
52: this .index = index;
53: }
54:
55: public String toString() {
56: return "Constructor-arg"
57: + (this .index >= 0 ? " #" + this .index : "");
58: }
59:
60: }
|