|
1 | 1 | package com.smartdevicelink.proxy.rpc;
|
2 | 2 |
|
| 3 | +import java.util.ArrayList; |
3 | 4 | import java.util.Hashtable;
|
| 5 | +import java.util.List; |
4 | 6 |
|
5 | 7 | import com.smartdevicelink.proxy.RPCStruct;
|
6 | 8 | import com.smartdevicelink.proxy.rpc.enums.FileType;
|
@@ -41,22 +43,35 @@ public void setName( ImageFieldName name ) {
|
41 | 43 | store.remove(KEY_NAME);
|
42 | 44 | }
|
43 | 45 | }
|
44 |
| - public FileType getImageTypeSupported() { |
45 |
| - Object obj = store.get(KEY_IMAGE_TYPE_SUPPORTED); |
46 |
| - if (obj instanceof FileType) { |
47 |
| - return (FileType) obj; |
48 |
| - } else if (obj instanceof String) { |
49 |
| - FileType theCode = null; |
50 |
| - try { |
51 |
| - theCode = FileType.valueForString((String) obj); |
52 |
| - } catch (Exception e) { |
53 |
| - DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e); |
54 |
| - } |
55 |
| - return theCode; |
56 |
| - } |
57 |
| - return null; |
58 |
| - } |
59 |
| - public void setImageTypeSupported( FileType imageTypeSupported ) { |
| 46 | + @SuppressWarnings("unchecked") |
| 47 | + public List<FileType> getImageTypeSupported() { |
| 48 | + if (store.get(KEY_IMAGE_TYPE_SUPPORTED) instanceof List<?>) { |
| 49 | + List<?> list = (List<?>)store.get(KEY_IMAGE_TYPE_SUPPORTED); |
| 50 | + if (list != null && list.size() > 0) { |
| 51 | + Object obj = list.get(0); |
| 52 | + if (obj instanceof FileType) { |
| 53 | + return (List<FileType>) list; |
| 54 | + } else if (obj instanceof String) { |
| 55 | + List<FileType> newList = new ArrayList<FileType>(); |
| 56 | + for (Object hashObj : list) { |
| 57 | + String strFormat = (String)hashObj; |
| 58 | + FileType theCode = null; |
| 59 | + try { |
| 60 | + theCode = FileType.valueForString(strFormat); |
| 61 | + } catch (Exception e) { |
| 62 | + DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e); |
| 63 | + } |
| 64 | + if (theCode != null) { |
| 65 | + newList.add(theCode); |
| 66 | + } |
| 67 | + } |
| 68 | + return newList; |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + return null; |
| 73 | + } |
| 74 | + public void setImageTypeSupported( List<FileType> imageTypeSupported ) { |
60 | 75 | if (imageTypeSupported != null) {
|
61 | 76 | store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported );
|
62 | 77 | }
|
|
0 commit comments