View Javadoc

1   package cz.cuni.amis.pogamut.sposh.elements;
2   
3   /**
4    * This class represents reference to some other element. The reference consists from
5    * <ul>
6    * <li>name of referenced element - action, sense, AP or C</li>
7    * <li>list of argument</li>
8    * <ul>
9    */
10  public final class PrimitiveCall {
11  
12  	private final String name;
13  	private final Arguments parameters;
14  
15  	/**
16  	 * Create reference without arguments
17  	 * 
18  	 * @param name Name of the referenced element.
19  	 */
20  	protected PrimitiveCall(String name) {
21  		this.name = name;
22  		this.parameters = new Arguments();
23  	}
24  
25      /**
26       * Copy constructor.
27       * @param original Original primitive call from which we take the data.
28       */
29  	protected PrimitiveCall(PrimitiveCall original) {
30  		this.name = original.getName();
31  		this.parameters = new Arguments(original.getParameters());
32  	}
33      
34      /**
35       * Create reference to element.
36       * @param name Name of referenced element.
37       * @param arguments Arguments passed to the referenced element. 
38       */
39  	protected PrimitiveCall(String name, Arguments arguments) {
40  		this.name = name;
41  		this.parameters = new Arguments(arguments);
42  	}
43  
44      /**
45       * @return Name of referenced element
46       */
47  	public String getName() {
48  		return name;
49  	}
50  
51  	/**
52  	 * @return unmodifiable list of parameters in correct order.
53  	 */
54  	public Arguments getParameters() {
55  		return parameters;
56  	}
57  
58  	@Override
59  	public String toString() {
60  		StringBuilder sb = new StringBuilder(name);
61  		if (!parameters.isEmpty()) {
62  			sb.append('(');
63  			sb.append(parameters.toString());
64  			sb.append(')');
65  		}
66  		return sb.toString();
67  	}
68  }