deletet because wrongly uploaded
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ArgumentDeclaration.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3
4 /**
5  * An argument declaration.
6  * 
7  * @author Matthieu Casanova
8  */
9 public final class ArgumentDeclaration extends VariableDeclaration {
10
11   /**
12    * Create an argument.
13    * 
14    * @param name           the name
15    * @param reference      the variable is a reference ?
16    * @param initialization the initialization
17    * @param sourceStart    the start point
18    */
19   public ArgumentDeclaration(final Variable name,
20                              final boolean reference,
21                              final Expression initialization,
22                              final int sourceStart) {
23     super(name, initialization, VariableDeclaration.EQUAL, sourceStart);
24     this.reference = reference;
25   }
26
27   /**
28    * Create an argument.
29    * 
30    * @param name        the name
31    * @param reference   the variable is a reference ?
32    * @param sourceStart the start point
33    */
34   public ArgumentDeclaration(final Variable name,
35                              final boolean reference,
36                              final int sourceStart) {
37     super(name, sourceStart);
38     this.reference = reference;
39   }
40
41   /**
42    * Return the expression as String.
43    * 
44    * @return the expression
45    */
46   public String toStringExpression() {
47     if (initialization == null) {
48       if (reference) {
49         return '&' + variable.toStringExpression();
50       } else {
51         return variable.toStringExpression();
52       }
53     } else {
54       final String variableString = variable.toStringExpression();
55       final String initializationString = initialization.toStringExpression();
56       final StringBuffer buff = new StringBuffer(4 +
57                                                  variableString.length() +
58                                                  initializationString.length());
59       if (reference) {
60         buff.append('&');
61       }
62       buff.append(variableString);
63       buff.append(" = ");
64       buff.append(initializationString);
65       return buff.toString();
66     }
67   }
68 }