001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.intergral.fusiondebug.server.type.coll; 020 021import lucee.intergral.fusiondebug.server.type.FDNodeValueSupport; 022import lucee.intergral.fusiondebug.server.util.FDCaster; 023import lucee.runtime.type.Array; 024import lucee.runtime.type.Collection; 025import lucee.runtime.type.Collection.Key; 026 027import com.intergral.fusiondebug.server.FDMutabilityException; 028import com.intergral.fusiondebug.server.IFDStackFrame; 029 030public class FDCollectionNode extends FDNodeValueSupport { 031 032 private Collection coll; 033 private Key key; 034 035 /** 036 * Constructor of the class 037 * @param coll 038 * @param key 039 */ 040 public FDCollectionNode(IFDStackFrame frame,Collection coll, Key key) { 041 super(frame); 042 this.coll=coll; 043 this.key=key; 044 } 045 046 @Override 047 public String getName() { 048 if(coll instanceof Array) return "["+key.getString()+"]"; 049 return key.getString(); 050 } 051 052 @Override 053 protected Object getRawValue() { 054 return coll.get(key,null); 055 } 056 057 public boolean isMutable() { 058 return true; 059 } 060 061 public void set(String value) throws FDMutabilityException { 062 coll.setEL(key, FDCaster.unserialize(value)); 063 } 064}