blob: 9b85f6523ba2444790ce0ee00af5769b4f87bd24 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.templateengine.process;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* ProcessParameter is responsible for construting the Process Parameter the given configuration element.
*/
public class ProcessParameter {
public static final byte SIMPLE = 1;
public static final byte SIMPLE_ARRAY = 2;
public static final byte COMPLEX = 3;
public static final byte COMPLEX_ARRAY = 4;
private static final String ELEM_NAME = "name"; //$NON-NLS-1$
private static final String ELEM_BASE_TYPE = "baseType"; //$NON-NLS-1$
private static final String ELEM_SIMPLE = "simple"; //$NON-NLS-1$
private static final String ELEM_SIMPLE_ARRAY = "simpleArray"; //$NON-NLS-1$
private static final String ELEM_COMPLEX = "complex"; //$NON-NLS-1$
private static final String ELEM_COMPLEX_ARRAY = "complexArray"; //$NON-NLS-1$
private static final String ELEM_EXTERNAL = "external"; //$NON-NLS-1$
private static final String ELEM_NULLABLE = "nullable"; //$NON-NLS-1$
private String name;
private byte type;
private ProcessParameter[] complexChildren;
private boolean external;
private boolean nullable;
/**
* Constructor to extract the parameter info.
* @param element
*/
public ProcessParameter(IConfigurationElement element) {
this.name = element.getAttribute(ELEM_NAME);
String elemName = element.getName();
if (elemName.equals(ELEM_SIMPLE)) {
type = SIMPLE;
} else if (elemName.equals(ELEM_SIMPLE_ARRAY)) {
type = SIMPLE_ARRAY;
} else if (elemName.equals(ELEM_COMPLEX)) {
type = COMPLEX;
IConfigurationElement[] children = element.getChildren();
complexChildren = new ProcessParameter[children.length];
for(int i=0; i<children.length; i++) {
complexChildren[i] = new ProcessParameter(children[i]);
}
} else if (elemName.equals(ELEM_COMPLEX_ARRAY)) {
type = COMPLEX_ARRAY;
IConfigurationElement baseType = element.getChildren(ELEM_BASE_TYPE)[0];
IConfigurationElement[] children = baseType.getChildren();
complexChildren = new ProcessParameter[children.length];
for(int i=0; i<children.length; i++) {
complexChildren[i] = new ProcessParameter(children[i]);
}
} else {
throw new IllegalArgumentException();
}
external = Boolean.valueOf(element.getAttribute(ELEM_EXTERNAL)).booleanValue();
nullable = Boolean.valueOf(element.getAttribute(ELEM_NULLABLE)).booleanValue();
}
/**
* Return the Element name.
*/
public String getName() {
return name;
}
/**
* Returns the Element Type.
*/
public byte getType() {
return type;
}
/**
* @return the complexChildren
*/
public ProcessParameter[] getComplexChildren() {
return complexChildren;
}
/**
* Checks whether the element in external.
*/
public boolean isExternal() {
return external;
}
/**
* @return the nullable
*/
public boolean isNullable() {
return nullable;
}
}
|