Java tutorial
/** * PureInfo Ark * @(#)RoleDef.java 1.0 2006-9-29 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.ark.auth2.model; import org.dom4j.Element; import com.pureinfo.force.exception.PureException; import com.pureinfo.force.xml.IXMLSupporter; import com.pureinfo.force.xml.XMLUtil; /** * <P> * Created on 2006-9-29 21:18:09 <BR> * Last modified on 2006-9-29 * </P> * RoleDef: user role. * * @author Why * @version 1.0, 2006-9-29 * @since Ark 1.2 */ public class RoleDef implements IXMLSupporter { private int m_nId; private String m_sName; private String m_sDesc; /** * Constructor: default */ public RoleDef() { super(); } /** * Returns the id. * * @return the id. */ public int getId() { return m_nId; } /** * Sets the id. * * @param _nId * the id to set. */ public void setId(int _nId) { m_nId = _nId; } /** * Returns the name. * * @return the name. */ public String getName() { return m_sName; } /** * Sets the name. * * @param _sName * the name to set. */ public void setName(String _sName) { m_sName = _sName; } /** * Returns the desc. * * @return the desc. */ public String getDesc() { return m_sDesc; } /** * Sets the desc. * * @param _sDesc * the desc to set. */ public void setDesc(String _sDesc) { m_sDesc = _sDesc; } //========================================================================= //implementation for IXMLSupporter /** * @see com.pureinfo.force.xml.IXMLSupporter#toXMLElement(org.dom4j.Element) */ public void toXMLElement(Element _element) throws PureException { _element.addAttribute("id", String.valueOf(m_nId)); _element.addAttribute("name", m_sName); _element.addAttribute("desc", m_sDesc); } /** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) */ public void fromXML(Element _element) throws PureException { this.setId(XMLUtil.getAttributeValueAsInt(_element, "id")); this.setName(XMLUtil.getAttributeValueTrim(_element, "name")); this.setDesc(XMLUtil.getAttributeValueTrim(_element, "desc")); } }