001 /*
002 * Apache License
003 * Version 2.0, January 2004
004 * http://www.apache.org/licenses/
005 *
006 * Copyright 1996-2008 by Sven Homburg
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 */
014
015 package org.chenillekit.tapestry.core.bindings;
016
017 import java.util.ArrayList;
018 import java.util.List;
019
020 import org.apache.tapestry5.Binding;
021 import org.apache.tapestry5.internal.bindings.AbstractBinding;
022 import org.apache.tapestry5.ioc.Location;
023
024 /**
025 * Binding type for collection values.
026 * This binding called by expression "list:".
027 *
028 * @version $Id: ListBinding.java 594 2009-12-05 15:17:26Z mlusetti $
029 */
030 public class ListBinding extends AbstractBinding
031 {
032 private final List<Binding> _bindings;
033 private final boolean _invariant;
034
035 public ListBinding(Location location, List<Binding> bindings, boolean invariant)
036 {
037 super(location);
038
039 _bindings = bindings;
040 _invariant = invariant;
041 }
042
043 public Object get()
044 {
045 List<Object> values = new ArrayList<Object>(_bindings.size());
046 for (Binding binding : _bindings)
047 values.add(binding.get());
048
049 return values.toArray();
050 }
051
052 @Override
053 public boolean isInvariant()
054 {
055 return this._invariant;
056 }
057
058 @Override
059 public Class<Object[]> getBindingType()
060 {
061 return Object[].class;
062 }
063 }