001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.parsers.creole.ast;
016    
017    import com.liferay.portal.parsers.creole.visitor.ASTVisitor;
018    
019    import java.util.ArrayList;
020    import java.util.List;
021    
022    /**
023     * @author Miguel Pastor
024     */
025    public class CollectionNode extends ASTNode {
026    
027            public CollectionNode() {
028                    this(0, null);
029            }
030    
031            public CollectionNode(int token) {
032                    this(token, null);
033            }
034    
035            public CollectionNode(List<ASTNode> astNodes) {
036                    this(0, astNodes);
037            }
038    
039            @Override
040            public void accept(ASTVisitor astVisitor) {
041                    astVisitor.visit(this);
042            }
043    
044            public void add(ASTNode astNode) {
045                    _astNodes.add(astNode);
046            }
047    
048            public ASTNode get(int position) {
049                    return _astNodes.get(position);
050            }
051    
052            public List<ASTNode> getASTNodes() {
053                    return _astNodes;
054            }
055    
056            public int size() {
057                    return _astNodes.size();
058            }
059    
060            protected CollectionNode(int token, List<ASTNode> astNodes) {
061                    super(token);
062    
063                    if (astNodes != null) {
064                            _astNodes = astNodes;
065                    }
066                    else {
067                            _astNodes = new ArrayList<ASTNode>();
068                    }
069            }
070    
071            private final List<ASTNode> _astNodes;
072    
073    }