blob: 59296b492a6303d95f51158c8117b6007e76e9e3 (
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
|
/**
* <copyright>
*
* Copyright (c) 2005, 2006, 2007 Springsite BV (The Netherlands) 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:
* Martin Taal
* </copyright>
*
* $Id: ArrayValueNode.java,v 1.6 2007/02/01 12:35:02 mtaal Exp $
*/
package org.eclipse.emf.teneo.annotations.parser;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* An array node contains a list of child values.
*
* @author <a href="mailto:mtaal at elver.org">Martin Taal</a>
*/
class ArrayValueNode extends NamedParserNode{
/** Log it */
private final static Log log = LogFactory.getLog(ArrayValueNode.class);
/** The value */
private List children = new ArrayList();
/** Returns the list */
List getChildren() {
return children;
}
/** Translate into a list of eobjects */
Object convert(EClassResolver ecr) {
log.debug("Converting array value node");
final ArrayList result = new ArrayList();
for (Iterator it = children.iterator(); it.hasNext();) {
final Object ob = it.next();
if (ob instanceof String) {
result.add(ob);
} else if (ob instanceof ComplexNode) {
final ComplexNode cn = (ComplexNode)ob;
result.add(cn.convert(ecr));
} else if (ob instanceof ReferenceValueNode) {
final ReferenceValueNode rvn = (ReferenceValueNode)ob;
result.add(rvn.convert(ecr));
} else if (ob instanceof ArrayValueNode) {
final ArrayValueNode avn = (ArrayValueNode)ob;
result.addAll((List)avn.convert(ecr));
} else {
throw new AnnotationParserException("Type " + ob.getClass().getName() + " not supported here");
}
}
return result;
}
}
|