Java tutorial
/** * PureInfo Quake * @(#)Notice.java 1.0 Nov 10, 2005 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.srm.config.notice.model; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.dom4j.Element; import com.pureinfo.force.exception.PureException; import com.pureinfo.force.xml.IXMLSupporter; /** * <P> * Created on Nov 10, 2005 2:18:56 PM <BR> * Last modified on Nov 10, 2005 * </P> * * @author Freeman.Hu * @version 1.0, Nov 10, 2005 * @since Quake 1.0 */ public class Notice implements IXMLSupporter { public static final String ATTRIBUTE_NAME = "name"; public static final String ELEMENT_ITEM = "item"; private String m_sName; private Map m_items = new HashMap(); public Notice() { } public Notice(String _sName) { m_sName = _sName; } public Map getItems() { return m_items; } public NoticeItem getItem(String _sName) { return (NoticeItem) m_items.get(_sName); } public void setItems(Map _nItems) { m_items = _nItems; } public String getName() { return m_sName; } public void setName(String _nName) { m_sName = _nName; } /** * @see com.pureinfo.force.xml.IXMLSupporter#toXMLElement(org.dom4j.Element) */ public void toXMLElement(Element _element) throws PureException { _element.addAttribute(ATTRIBUTE_NAME, m_sName); for (Iterator iter = m_items.values().iterator(); iter.hasNext();) { NoticeItem item = (NoticeItem) iter.next(); item.toXMLElement(_element.addElement(ELEMENT_ITEM)); } } /** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) */ public void fromXML(Element _element) throws PureException { m_sName = _element.attributeValue(ATTRIBUTE_NAME); m_items = new HashMap(); for (Iterator iter = _element.elementIterator(ELEMENT_ITEM); iter.hasNext();) { NoticeItem item = new NoticeItem(); item.fromXML((Element) iter.next()); m_items.put(item.getName(), item); } } }