How to get IBA values in a HashMap in Windchill

public static HashMap getIBAValueMap(IBAHolder ibaHolder) throws Exception { 
        HashMap ibaValueMap = new HashMap();
        ibaHolder = IBAValueHelper.service.refreshAttributeContainer(ibaHolder, null, WTContext.getContext().getLocale(), null);
        //Logger logger = LogR.getLogger(Util.class.getName()); logger.info("Testing message");

DefaultAttributeContainer defaultattributecontainer = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();        
        if (defaultattributecontainer != null){
            AbstractValueView aabstractvalueview[] = defaultattributecontainer.getAttributeValues();
            for (int i = 0; i < aabstractvalueview.length; i++) {
                String name = aabstractvalueview[i].getDefinition().getName();
                String value = null;
                if(aabstractvalueview[i] instanceof URLValueDefaultView) {
                   URLValueDefaultView urlv = (URLValueDefaultView) aabstractvalueview[i];
                   value = "" + urlv.getDescription() + "";
                }
                else {
                    value = IBAValueUtility.getLocalizedIBAValueDisplayString(aabstractvalueview[i], WTContext.getContext().getLocale());
                }

Object eValue = (Object) ibaValueMap.get(name);
                if(eValue == null){
                    ibaValueMap.put(name, value);
                } else {
                    ArrayList al = new ArrayList();
                    if(eValue instanceof ArrayList){
                        al = (ArrayList)eValue;
                        al.add(value);
                    } else {
                        al.add(eValue);
                        al.add(value);
                    }     
                    ibaValueMap.put(name, al);
                }
            }           
        }
        return ibaValueMap;
    }

你可能感兴趣的:(How to get IBA values in a HashMap in Windchill)