001package com.hfg.setting; 002 003 004import java.util.List; 005 006import com.hfg.exception.UnimplementedMethodException; 007import com.hfg.util.collection.CollectionUtil; 008import com.hfg.util.collection.OrderedMap; 009import com.hfg.xml.XMLTag; 010 011//------------------------------------------------------------------------------ 012/** 013 * Base class for XML-serializable map settings. 014 * 015 * @author J. Alex Taylor, hairyfatguy.com 016 */ 017//------------------------------------------------------------------------------ 018// com.hfg XML/HTML Coding Library 019// 020// This library is free software; you can redistribute it and/or 021// modify it under the terms of the GNU Lesser General Public 022// License as published by the Free Software Foundation; either 023// version 2.1 of the License, or (at your option) any later version. 024// 025// This library is distributed in the hope that it will be useful, 026// but WITHOUT ANY WARRANTY; without even the implied warranty of 027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 028// Lesser General Public License for more details. 029// 030// You should have received a copy of the GNU Lesser General Public 031// License along with this library; if not, write to the Free Software 032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 033// 034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 035// jataylor@hairyfatguy.com 036//------------------------------------------------------------------------------ 037 038public abstract class MapSettingImpl extends SettingImpl 039{ 040 //--------------------------------------------------------------------------- 041 public MapSettingImpl(String inName) 042 { 043 super(inName); 044 } 045 046 //--------------------------------------------------------------------------- 047 public MapSettingImpl(String inName, Object inValue) 048 { 049 super(inName, inValue); 050 } 051 052 //--------------------------------------------------------------------------- 053 public MapSettingImpl(XMLTag inXMLTag) 054 { 055 super(inXMLTag); 056 List<XMLTag> valueSubtags = inXMLTag.getSubtagsByName(SettingXML.VALUE); 057 if (CollectionUtil.hasValues(valueSubtags)) 058 { 059 setObjectValue(new OrderedMap<>(20)); 060 for (XMLTag subtag : valueSubtags) 061 { 062 putStringValue(subtag.getAttributeValue(SettingXML.NAME_ATT), subtag.getUnescapedContent()); 063 } 064 } 065 } 066 067 //--------------------------------------------------------------------------- 068 protected abstract void putStringValue(String inKey, String inValue); 069 070 //--------------------------------------------------------------------------- 071 protected void setValueFromString(String inValue) 072 { 073 throw new UnimplementedMethodException(); 074 } 075 076}