我正在确定一个等级的 j豆的价值。 如何在另一个类别中获得价值,谁能举出例子?
import java.util.ArrayList;
public class HomeBean {
String indexname="";
String lastvalue="";
String changepercentage="";
ArrayList aindexname=new ArrayList();
ArrayList alastname=new ArrayList();
ArrayList alastpercentage=new ArrayList();
public String getIndexname() {
return indexname;
}
public void setIndexname(String indexname) {
this.indexname = indexname;
System.out.println("******index name is *****"+indexname);
aindexname.add(indexname);
}
public String getLastvalue() {
return lastvalue;
}
public void setLastvalue(String lastvalue) {
this.lastvalue = lastvalue;
}
public String getChangepercentage() {
return changepercentage;
}
public void setChangepercentage(String changepercentage) {
this.changepercentage = changepercentage;
}
public ArrayList getArrayListIndexName()
{
for(int i=0;i<aindexname.size();i++)
{
System.out.println("####indexname is######"+aindexname.get(i).toString());
}
return aindexname;
}
public ArrayList getArrayListLastValue()
{
return alastname;
}
public ArrayList getArrayListChangePercentage()
{
return alastpercentage;
}
}
设定一个类别的价值
mport java.util.ArrayList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class DomTableParser
{
ArrayList listTable=new ArrayList();
public ArrayList parseXmlFile(String tableservicevalue){
//get the factory
Document doc;
StringtoDocument stdoc=new StringtoDocument();
doc=stdoc.getDocument(tableservicevalue);
//System.out.println("Information of all employees");
HomeBean bean=new HomeBean();
Element docEle = doc.getDocumentElement();
NodeList indexNode = docEle.getElementsByTagName("INDEX");
if(indexNode != null && indexNode.getLength() > 0)
{
for(int i = 0 ; i < indexNode.getLength();i++)
{
Element homeElmnt = (Element)indexNode.item(i);
DomParserTableDataSet dataSet=new DomParserTableDataSet();
String indexName = homeElmnt.getAttribute("INDEX_NAME");
String lastValue=homeElmnt.getAttribute("LAST_VALUE");
String changePercentage=homeElmnt.getAttribute("CHANGE_PERCENTAGE");
//String questgroupid=loginElmnt.getAttribute("ID");
bean.setIndexname(indexName);
bean.setLastvalue(lastValue);
bean.setChangepercentage(changePercentage);
bean.getArrayListIndexName();
dataSet.setIndexName(indexName);
dataSet.setLastValue(lastValue);
dataSet.setChangePercentage(changePercentage);
listTable.add(dataSet);
}
}
return listTable;
}
}