57 * {@link #updateCachedDatas(Object,List)}. |
57 * {@link #updateCachedDatas(Object,List)}. |
58 * @param rank Rank of the given <var>item</var> in the |
58 * @param rank Rank of the given <var>item</var> in the |
59 * <var>rawDatas</var> list iterator. |
59 * <var>rawDatas</var> list iterator. |
60 * @param item The raw data object for which an index must be determined. |
60 * @param item The raw data object for which an index must be determined. |
61 **/ |
61 **/ |
62 protected abstract SnmpOid getIndex(Object context, List rawDatas, |
62 protected abstract SnmpOid getIndex(Object context, List<?> rawDatas, |
63 int rank, Object item); |
63 int rank, Object item); |
64 |
64 |
65 /** |
65 /** |
66 * The data for the entry corresponding to the given <var>item</var>. |
66 * The data for the entry corresponding to the given <var>item</var>. |
67 * <br>This method is called by {@link #updateCachedDatas(Object,List)}. |
67 * <br>This method is called by {@link #updateCachedDatas(Object,List)}. |
73 * <var>rawDatas</var> list iterator. |
73 * <var>rawDatas</var> list iterator. |
74 * @param item The raw data object from which the entry data must be |
74 * @param item The raw data object from which the entry data must be |
75 * extracted. |
75 * extracted. |
76 * @return By default <var>item</var> is returned. |
76 * @return By default <var>item</var> is returned. |
77 **/ |
77 **/ |
78 protected Object getData(Object context, List rawDatas, |
78 protected Object getData(Object context, List<?> rawDatas, |
79 int rank, Object item) { |
79 int rank, Object item) { |
80 return item; |
80 return item; |
81 } |
81 } |
82 |
82 |
83 /** |
83 /** |
93 * hook for subclassed. |
93 * hook for subclassed. |
94 * @param rawDatas The table datas from which the cached data will be |
94 * @param rawDatas The table datas from which the cached data will be |
95 * computed. |
95 * computed. |
96 * @return the computed cached data. |
96 * @return the computed cached data. |
97 **/ |
97 **/ |
98 protected SnmpCachedData updateCachedDatas(Object context, List rawDatas) { |
98 protected SnmpCachedData updateCachedDatas(Object context, List<?> rawDatas) { |
99 final int size = ((rawDatas == null)?0:rawDatas.size()); |
99 final int size = ((rawDatas == null)?0:rawDatas.size()); |
100 if (size == 0) return null; |
100 if (size == 0) return null; |
101 |
101 |
102 final long time = System.currentTimeMillis(); |
102 final long time = System.currentTimeMillis(); |
103 final Iterator it = rawDatas.iterator(); |
103 final Iterator<?> it = rawDatas.iterator(); |
104 final TreeMap<SnmpOid, Object> map = |
104 final TreeMap<SnmpOid, Object> map = |
105 new TreeMap<SnmpOid, Object>(SnmpCachedData.oidComparator); |
105 new TreeMap<>(SnmpCachedData.oidComparator); |
106 for (int rank=0; it.hasNext() ; rank++) { |
106 for (int rank=0; it.hasNext() ; rank++) { |
107 final Object item = it.next(); |
107 final Object item = it.next(); |
108 final SnmpOid index = getIndex(context, rawDatas, rank, item); |
108 final SnmpOid index = getIndex(context, rawDatas, rank, item); |
109 final Object data = getData(context, rawDatas, rank, item); |
109 final Object data = getData(context, rawDatas, rank, item); |
110 if (index == null) continue; |
110 if (index == null) continue; |