English 中文(简体)
• 如何从 j的豆类中获取价值
原标题:How to get the value from bean for another class in java
  • 时间:2010-11-25 13:42:27
  •  标签:
  • java

我正在确定一个等级的 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;
    }




}
最佳回答
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签