Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 75371 invoked from network); 1 Apr 2011 13:54:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Apr 2011 13:54:05 -0000 Received: (qmail 37486 invoked by uid 500); 1 Apr 2011 13:54:04 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 37391 invoked by uid 500); 1 Apr 2011 13:54:04 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 37383 invoked by uid 99); 1 Apr 2011 13:54:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 13:54:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fxbird1978@163.com designates 123.125.50.133 as permitted sender) Received: from [123.125.50.133] (HELO m50-133.163.com) (123.125.50.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 13:53:59 +0000 Received: from fxbird-think (unknown [113.235.34.252]) by smtp3 (Coremail) with SMTP id DdGowKD7H5ra2JVN4ksiAA--.534S2; Fri, 01 Apr 2011 21:53:31 +0800 (CST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Commons Users List" Subject: Re: [digester] why addCallMethod doesn't work? References: Date: Fri, 01 Apr 2011 21:53:28 +0800 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Kurt Xu" Message-ID: In-Reply-To: User-Agent: Opera Mail/11.01 (Win32) X-CM-TRANSID: DdGowKD7H5ra2JVN4ksiAA--.534S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3Cw1UAry7Cw1DXr4DGFyxuFg_yoWktr4rpr ZxAFZFy34Fyw17Jr4v9rWrZr1avrW7tFyjqw47Jan7Aa4qyFy7Ar13t3yj9ayavrW0g3ya yw1FqF17Ww4jkrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U9Z2fUUUUU= X-CM-SenderInfo: pi0ex2jgrzlmi6rwjhhfrp/1tbiVx0U7U0vH21mQwAAsG Hello Simone: Just below in method setTable is woring. = d.addCallMethod(pattern, "setType", 1); d.addCallParam(pattern, 0, type); other part is ok. Thanks. Kurt On Fri, 01 Apr 2011 21:05:08 +0800, Simone Tripodi = wrote: > Holy cow, Kurt!!! :D > can you be more precise and highlight which is the part that doesn't > work? For what I see, there's one assCallParam() set in your Digetser > and that's for the Handler > Simo > > http://people.apache.org/~simonetripodi/ > http://www.99soft.org/ > > > > 2011/4/1 Kurt Xu : >> >> Hi all digester users & developers: >> >> Today I use addCallMethod but it doesn't work as before. >> >> the xml is below: >> >> >> >> >> >> >> >> > statisticsType=3D"=E5=A4=84=E7=90=86=E6=97=A5"/> >> >> >> > class=3D"com.mytest.siamon.util.DefaultSiamonHandler"/> >>
>> >> > column=3D"PrimaryKey1"/> >>
>> >> > column=3D"WriterId"/> >> > column=3D"Content"/> >> >> >>
>>
>>
>>
>> >> there's a code about Mutable and Constant that they both can show u= p = >> under >> Main or Sub, the former represents a mutable property and the latter >> represents a constant property in out business logic. But the questi= on = >> is >> when TextTable element shows up, I want to set TableMap(XXXTable rela= ted >> class, pojo)'s type as "txt" through addCallMethod. I research on = >> official >> sample but it is not right in my code, it looks just the same as the = = >> sample. >> >> related java file: >> >> 1)ClassItem.java >> package com.siamon.model.config; >> >> import java.util.ArrayList; >> import java.util.List; >> >> public class ClassItem { >> >> private String method; >> private String name; >> private List tableMapList=3Dnew ArrayList(); >> >> public ClassItem(String name, String method, List = >> tableMapList) >> { >> this.name =3D name; >> this.method =3D method; >> this.tableMapList =3D tableMapList; >> } >> >> >> public ClassItem() { >> } >> >> public String getMethod() { >> return method; >> } >> >> public void setMethod(String method) { >> this.method =3D method; >> } >> >> public String getName() { >> return name; >> } >> >> public void setName(String name) { >> this.name =3D name; >> } >> >> >> public void addTableMap(TableMap tm){ >> getTableMapList().add(tm); >> } >> >> public List getTableMapList() { >> return tableMapList; >> } >> } >> >> 2)Project.java >> package com.siamon.model; >> >> import com.siamon.model.config.Functionality; >> >> import java.util.ArrayList; >> import java.util.List; >> >> public class Project { >> private String name; >> private List functionalities=3Dnew >> ArrayList(); >> >> public void addFunctionality(Functionality func){ >> functionalities.add(func); >> } >> >> public String getName() { >> return name; >> } >> >> public void setName(String name) { >> this.name =3D name; >> } >> >> public List getFunctionalities() { >> return functionalities; >> } >> >> >> } >> >> 3)ConstantProp.java >> package com.siamon.model.config; >> >> public class ConstantProp { >> private String column; >> private String value; >> >> public String getColumn() { >> return column; >> } >> >> public void setColumn(String column) { >> this.column =3D column; >> } >> >> public String getValue() { >> return value; >> } >> >> public void setValue(String value) { >> this.value =3D value; >> } >> >> @Override >> public String toString() { >> return "ConstantProp [ " + >> "column=3D'" + column + '\'' + >> ", value=3D'" + value + '\'' + >> " ] "; >> } >> } >> >> 4)MutableProp.java >> package com.siamon.model.config; >> >> public class MutableProp { >> private String property; >> private int argIndex; >> private String column; >> private String value; >> >> public String getProperty() { >> return property; >> } >> >> public void setProperty(String property) { >> this.property =3D property; >> } >> >> public int getArgIndex() { >> return argIndex; >> } >> >> public void setArgIndex(int argIndex) { >> this.argIndex =3D argIndex; >> } >> >> public String getColumn() { >> return column; >> } >> >> public void setColumn(String column) { >> this.column =3D column; >> } >> >> public String getValue() { >> return value; >> } >> >> public void setValue(String value) { >> this.value =3D value; >> } >> >> @Override >> public String toString() { >> return "MutableProp [ " + >> "property=3D'" + property + '\'' + >> ", argIndex=3D" + argIndex + >> ", column=3D'" + column + '\'' + >> ", value=3D'" + value + '\'' + >> " ] "; >> } >> } >> >> 5)TableMap.java >> package com.siamon.model.config; >> >> import java.util.ArrayList; >> import java.util.List; >> >> public class TableMap { >> private String type; >> private String = >> handler=3D"com.nhstcorp.siamon.util.DefaultSiamonHandler"; >> private List constantPropList=3Dnew >> ArrayList(); >> private List mutablePropList=3Dnew = >> ArrayList(); >> >> public String getType() { >> return type; >> } >> >> public void setType(String type) { >> this.type =3D type; >> } >> >> public List getMutablePropList() { >> return mutablePropList; >> } >> >> public List getConstantPropList() { >> return constantPropList; >> } >> >> public void addMutableProp(MutableProp prop){ >> getMutablePropList().add(prop); >> } >> >> public void addConstantProp(ConstantProp prop){ >> getConstantPropList().add(prop); >> } >> >> public String getHandler() { >> return handler; >> } >> >> public void setHandler(String handler) { >> this.handler =3D handler; >> } >> } >> >> 6)Functionality.java >> package com.siamon.model.config; >> >> import java.util.*; >> >> public class Functionality { >> >> private String url; >> private String description; >> private String actionName; >> private String actionMethod; >> private String kpiCategoryId; >> private String contentType; >> private String statisticsType; >> private List classItems=3Dnew ArrayList(); >> private String projectName; >> >> public Functionality(String projectName, String kpiCategoryId, Str= ing >> contentType, String statisticsType) { >> this.projectName =3D projectName; >> this.kpiCategoryId =3D kpiCategoryId; >> this.contentType =3D contentType; >> this.statisticsType =3D statisticsType; >> } >> >> public Functionality() { >> } >> >> public String getUrl() { >> return url; >> } >> >> public void setUrl(String url) { >> this.url =3D url; >> } >> >> public String getDescription() { >> return description; >> } >> >> public void setDescription(String description) { >> this.description =3D description; >> } >> >> public String getActionName() { >> return actionName; >> } >> >> public void setActionName(String actionName) { >> this.actionName =3D actionName; >> } >> >> public String getActionMethod() { >> return actionMethod; >> } >> >> public void setActionMethod(String actionMethod) { >> this.actionMethod =3D actionMethod; >> } >> >> public String getKpiCategoryId() { >> return kpiCategoryId; >> } >> >> public void setKpiCategoryId(String kpiCategoryId) { >> this.kpiCategoryId =3D kpiCategoryId; >> } >> >> public String getContentType() { >> return contentType; >> } >> >> public void setContentType(String contentType) { >> this.contentType =3D contentType; >> } >> >> public String getStatisticsType() { >> return statisticsType; >> } >> >> public void setStatisticsType(String statisticsType) { >> this.statisticsType =3D statisticsType; >> } >> >> public List getClassItems() { >> return classItems; >> } >> >> public void setClassItems(List classItems) { >> this.classItems =3D classItems; >> } >> >> public String getProjectName() { >> return projectName; >> } >> >> public void setProjectName(String projectName) { >> this.projectName =3D projectName; >> } >> >> public ClassItem findClassItem(String clazz,String method){ >> for (ClassItem ci:classItems){ >> if (ci.getName().equals(clazz) && = >> ci.getMethod().equals(method)){ >> return ci; >> } >> } >> >> return null; >> } >> >> public void addClassItem(ClassItem ci){ >> getClassItems().add(ci); >> } >> } >> >> >> 7)parser method >> private Project parseProject2(URL url) throws IOException, = >> SAXException { >> Digester d =3D new Digester(); >> >> String pathFunc =3D "Project/Functionality"; >> String pathClass =3D pathFunc + "/Class"; >> >> >> d.addObjectCreate("Project", Project.class); >> d.addSetProperties("Project"); >> >> d.addObjectCreate(pathFunc, Functionality.class); >> d.addSetNext(pathFunc, "addFunctionality"); >> d.addSetProperties(pathFunc); >> d.addSetProperties(pathFunc + "/BasicInfo"); >> >> d.addObjectCreate(pathClass, ClassItem.class); >> d.addSetNext(pathClass, "addClassItem"); >> >> String pathTextTable =3D pathClass + "/TextTable"; >> d.addSetProperties(pathClass); >> d.addObjectCreate(pathTextTable, TableMap.class); >> d.addSetNext(pathTextTable,"addTableMap"); >> >> >> setTable(d, pathClass,"TextTable","txt"); >> >> d.parse(url); >> Project project =3D (Project) d.getRoot(); >> >> System.out.println(); >> >> return project; >> } >> >> private void setTable(Digester d, String pathClass, String tableEle= m, >> String type){ >> String pattern=3DpathClass + "/"+tableElem; >> >> d.addObjectCreate(pattern+"/Main/Constant",ConstantProp.class)= ; >> d.addSetNext(pattern+"/Main/Constant", "addConstantProp"); >> d.addSetProperties(pattern+ "/Main/Constant"); >> >> d.addObjectCreate(pattern+"/Main/Mutable",MutableProp.class); >> d.addSetNext(pattern + "/Main/Mutable", "addMutableProp"); >> d.addSetProperties(pattern+ "/Main/Mutable"); >> >> d.addObjectCreate(pattern+"/Sub/Constant",ConstantProp.class);= >> d.addSetNext(pattern+"/Sub/Constant", "addConstantProp"); >> d.addSetProperties(pattern+ "/Sub/Constant"); >> >> d.addObjectCreate(pattern+"/Sub/Mutable",MutableProp.class); >> d.addSetNext(pattern + "/Sub/Mutable", "addMutableProp"); >> d.addSetProperties(pattern+ "/Sub/Mutable"); >> >> >> d.addSetProperties(pathClass + "/Handler", "class", "handler")= ; >> d.addCallMethod(pattern, "setType", 1); >> d.addCallParam(pattern, 0, type); >> >> d.addSetProperties(pattern + "/Handler", "class", "handler"); >> } >> >> that's all source, the issue is the method setTable can't setType f= or = >> a >> TableMap class successfully. It looks very normal, nothing seem = >> wrong,but >> just doesn't work. I also attach the source to the email, don't know = if = >> it's >> allowed. >> >> Thanks a lot >> Kurt >> >> ---------------------------------------------------------------------= >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >> For additional commands, e-mail: user-help@commons.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > -- = Using Opera's revolutionary email client: http://www.opera.com/mail/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org