0

私はstrutsとjavaに比較的慣れていません。私は次のコードを理解しようとしています。

 List<LabelValueBean> dbList = getCardProductList();

    ConcurrentMap<Integer, ProductItem> ret = new ConcurrentHashMap<Integer, ProductItem>();
    for (LabelValueBean lb : dbList) {
        ProductItem pi = new ProductItem();
        pi.setId(Integer.valueOf(lb.getId()));
        pi.setCode(lb.getCode());
        pi.setName(lb.getDescription());

        LabelValueBeanAuxCol[] aux = lb.getLabelvaluebeanauxcol();
        pi.setTypeProduct(Boolean.TRUE);

        if (null != aux) {
            for (LabelValueBeanAuxCol element : aux) {
                if (null != element
                        && "PRDCT_SVC_IND".equals(element.getName())) {
                    pi.setTypeProduct(Boolean.valueOf("Y".equals(element
                            .getValue())));
                }
            }
        }
        pi.setNeedSetup(Boolean.TRUE);
        ret.put(pi.getId(), pi);
    }
    return Himms2LookupUtil
            .<ConcurrentMap<Integer, ProductItem>> setValueInCache(
                    Himms2Names.CARD_SERVICE_PRODUCT_LIST, ret);
}

「PRDCT_SVC_IND」の周りのコードブロックに関連して、列の名前はどのようにlabelvaluebeanにマップされますか?
並行マップとキーと値のペアの機能については考えていますが、ここでの概念のほとんどについてはかなり確信が持てず、運が悪かったのでインターネットで検索しようとしました。コンカレントハッシュマップ、リスト(labelvaluebean)など、ここで使用されている概念の観点から、上記の行が実際に何を意味するのか(もちろん一般的に)、より明確な概要が必要です。入力をいただければ幸いです。

4

1 に答える 1

1

コードは次のことを行っています:-

1)最初の行でCardProductListを取得し、参照をdbListオブジェクトに次のように格納します。

List<LabelValueBean> dbList = getCardProductList();`

2)キー値のConcurrentMapを作成します。

3)CardProductListの反復を開始し、各CardProductListオブジェクトに対して次の操作を実行します-

a) Crates ProductItem object.
b) setting CardProduct object values (id, code, name) into ProductItem object.
d) setting ProductItem.typeProduct to TRUE.
c) getting Labelvaluebeanauxcol and store it in a LabelValueBeanAuxCol[] array instance called aux.
d) now check if aux is not null then iterates aux array and checks if(elemet is not null  AND element name IS EQUAL TO "PRDCT_SVC_IND"
    THEN
        set ProductItem.TypeProduct to True if element.value = Y
        ELSE
        set ProductItem.TypeProduct to FALE
e) set ProductItem.NeddSetup = TRUE
f) set ProductItem.id and ProductItem into ConcurrentMap.

4)ConcurrentMapをキャッシュに保存します

于 2012-06-08T05:43:28.113 に答える