免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1156 | 回复: 3
打印 上一主题 下一主题

请教:这段代码不太明白,请高手指教,谢谢! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-19 14:45 |只看该作者 |倒序浏览
package Base.DataBean;

import java.util.Hashtable;

public class DefaultDataBean
{

    Hashtable Attribe;
    String innerStr;
    Hashtable htCount;

    public DefaultDataBean()
    {
        Attribe = null;
        innerStr = "";
        htCount = new Hashtable();
        Attribe = new Hashtable();
        innerStr = "---initialized---";
    }

    public String getInnerStr()
    {
        return innerStr;
    }

    public int getAttributeSize(Object name)
    {
        if(Attribe == null)
            return 0;
        Hashtable obj = (Hashtable)Attribe.get(name);
        if(obj == null)
            return 0;
        else
            return obj.size();
    }

    public Object getAttribute(Object name, int index)
    {
        if(Attribe == null)
            return null;
        Hashtable obj = (Hashtable)Attribe.get(name);
        if(obj == null)
            return null;
        else
            return obj.get(new Integer(index));
    }

    public Object getAttribute(Object name)
    {
        return getAttribute(name, 0);
    }

    public String getAttributeStr(Object name, int index)
    {
        String str = (String)getAttribute(name, index);
        if(str == null)
            str = new String("";
        return str;
    }

    public String getAttributeStr(Object name)
    {
        return getAttributeStr(name, 0);
    }

    public boolean putAttribute(Object name, Object val, int index)
    {
        innerStr = "---Call  putAttribute---";
        if(Attribe == null)
            return false;
        Hashtable obj = (Hashtable)Attribe.get(name);
        if(obj == null)
            obj = new Hashtable();
        obj.put(new Integer(index), val);
        Attribe.put(name, obj);
        return true;
    }

    public boolean putAttribute(Object name, Object val)
    {
        return putAttribute(name, val, 0);
    }

    public int getCount(String name)
    {
        Integer iCount = null;
        iCount = (Integer)htCount.get(name);
        if(iCount != null)
            return iCount.intValue();
        else
            return 0;
    }

    public void setCount(String name, int val)
    {
        htCount.put(name, new Integer(val));
    }
}

论坛徽章:
0
2 [报告]
发表于 2005-05-19 15:28 |只看该作者

请教:这段代码不太明白,请高手指教,谢谢!

你哪个地方没看明白?

论坛徽章:
0
3 [报告]
发表于 2005-05-20 10:24 |只看该作者

请教:这段代码不太明白,请高手指教,谢谢!

我是一个新手,看起很吃力.能给我说一下这段代码的功能,能做些什么

论坛徽章:
0
4 [报告]
发表于 2005-05-20 14:47 |只看该作者

请教:这段代码不太明白,请高手指教,谢谢!

这是一个很容用的Java bean.从代码看不出是做什么业务逻辑的。
大致就是定义了一个DataBean,然后提供了方法可以访问和修改它的一个火多个属性
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP