All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cfml.parsing.cfscript.CFArrayExpression Maven / Gradle / Ivy

There is a newer version: 2.11.0
Show newest version
package cfml.parsing.cfscript;

import java.util.ArrayList;
import java.util.List;

import org.antlr.v4.runtime.Token;

import cfml.parsing.cfscript.script.CFScriptStatement;
import cfml.parsing.util.ArrayBuilder;

public class CFArrayExpression extends CFExpression implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private ArrayList elements;
	
	public CFArrayExpression(Token t) {
		super(t);
		elements = new ArrayList();
	}
	
	public void addElement(CFExpression _e) {
		elements.add(_e);
	}
	
	@Override
	public String Decompile(int indent) {
		if (elements.size() > 0) {
			StringBuilder sb = new StringBuilder();
			sb.append('[');
			for (int i = 0; i < elements.size(); i++) {
				sb.append(elements.get(i).Decompile(0));
				sb.append(',');
			}
			sb.deleteCharAt(sb.length() - 1);
			
			sb.append(']');
			return sb.toString();
		} else {
			return "[]";
		}
	}
	
	public ArrayList getElements() {
		return elements;
	}
	
	@Override
	public List decomposeExpression() {
		return elements;
	}
	
	@Override
	public List decomposeScript() {
		return ArrayBuilder.createCFScriptStatement();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy