Java tutorial
/** * PureInfo Quake * @(#)RPMSValidatorAction.java 1.0 2007-1-18 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.srm.srm2rpms.action; import java.util.Iterator; import java.util.List; import org.apache.struts.action.ActionForward; import org.dom4j.Element; import com.pureinfo.ark.interaction.list.SearchAction; import com.pureinfo.ark.interaction.list.SearchForm; import com.pureinfo.force.exception.PureException; import com.pureinfo.force.io.ClassResourceUtil; import com.pureinfo.force.xml.XMLUtil; /** * <P> * Created on 2007-1-18 09:56:40<BR> * Last modified on 2007-1-18 * </P> * RPMSValidatorAction: RPMS validator action. * * @author Administrator * @version 1.0, 2007-1-18 * @since SRM 2.2 */ public class RPMSValidatorAction extends SearchAction { private String m_sTitle; private String m_sScenery; private String m_sHeadTable; /** * Constructor: default */ public RPMSValidatorAction() { super(); } /** * @see com.pureinfo.ark.interaction.ActionBase#beforeExecution() */ protected ActionForward beforeExecution() throws PureException { String sId = request.getRequiredParameter("id", "validator id"); String sFileName = ClassResourceUtil.mapFullPath("srm2rpms-validator.cfg.xml", true); Element element = XMLUtil.fileToElement(sFileName); List list = element.elements(); try { Iterator itrList = list.iterator(); while (itrList.hasNext()) { element = (Element) itrList.next(); if (sId.equals(element.attributeValue("id"))) { m_sTitle = element.attributeValue("title"); m_sScenery = element.attributeValue("scenery"); m_sHeadTable = element.elementText("hint"); String sCondition = element.elementTextTrim("condition"); ((SearchForm) form).getQueryFilter().addCondition(sCondition); return super.beforeExecution(); } } // endwhile } finally { list.clear(); } throw new PureException(PureException.INVALID_REQUEST, "validator not found: id=" + sId); } /** * @see com.pureinfo.ark.interaction.list.SearchAction#getTitle() */ public String getTitle() throws PureException { return (m_sTitle != null && m_sTitle.length() > 0) ? m_sTitle : super.getTitle(); } /** * @see com.pureinfo.ark.interaction.list.SearchAction#getScenery() */ protected String getScenery() { return (m_sScenery != null && m_sScenery.length() > 0) ? m_sScenery : super.getScenery(); } /** * @see com.pureinfo.ark.interaction.list.SearchAction#getHeadTable() */ public String getHeadTable() throws PureException { return m_sHeadTable; } }