List of usage examples for java.util LinkedList set
public E set(int index, E element)
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ????// ww w .j a v a 2 s . c o m * @param menuBean */ @SuppressWarnings("unchecked") private static void addLvl3Menu(Map<String, Object> menuBean) { List<Object> menuLvl1List = allMenuBean.getDataList(); for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> tmpMenuBeanLvl1 = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) tmpMenuBeanLvl1.get(Constants.MENU_CHILDREN); if (menuLvl2List == null) { continue; } for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> tmpMenuBeanLvl2 = (Map<String, Object>) menuLvl2List.get(j); //????? ????? if (tmpMenuBeanLvl2.get(Constants.MENU_ID).toString().trim() .equals(menuBean.get(Constants.MENU_PARENT_ID).toString().trim())) { if (!tmpMenuBeanLvl2.containsKey(Constants.MENU_CHILDREN)) { LinkedList<Object> menuLvl3List = new LinkedList<Object>(); menuLvl3List.add(menuBean); tmpMenuBeanLvl2.put(Constants.MENU_CHILDREN, menuLvl3List); } else { LinkedList<Object> menuLvl3List = (LinkedList<Object>) tmpMenuBeanLvl2 .get(Constants.MENU_CHILDREN); menuLvl3List.add(menuBean); tmpMenuBeanLvl2.put(Constants.MENU_CHILDREN, menuLvl3List); } menuLvl2List.set(j, tmpMenuBeanLvl2); } } tmpMenuBeanLvl1.put(Constants.MENU_CHILDREN, menuLvl2List); menuLvl1List.set(i, tmpMenuBeanLvl1); } allMenuBean.setDataList(menuLvl1List); }
From source file:fNIRs.FNIRsStats.java
public static void oldOutputANOVAs(GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // get all condition-group sequences: ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data.getAllSelectedTDSs(groupNames, conditions); chunkData(allTDSs, numChunks); // COMMENT THIS LATER // calculate required widths for printed names and condition numbers: int nameWidth = longestLength(groupNames); // length of longest name int conditionWidth = // number of digits in the largest condition number String.valueOf(Collections.max(conditions)).length(); // make sure the fields will be wide enough to hold the ANOVA values, // which will, in the widest case, consist of a 1 followed by a . and // precision 0s: // AM I USING "PRECISION" RIGHT? int idFieldWidth = nameWidth + conditionWidth + 2; if (idFieldWidth < precision + 2) { // for the "1." // if not, increase the condition width so the total field width is // large enough: idFieldWidth = precision + 2;// w w w. j a v a2 s. co m } String idFieldFormat = "%-" + idFieldWidth + "s"; // output the first row, containing identifying information for each // group-condition combination: // first, output proper-width placeholder for the identifier column: System.out.printf("%" + idFieldWidth + "s ", ""); // TOO HACKY?? // then, output all tds identifiers: for (GroupedChannels.TaggedDataSequence tds : allTDSs) { System.out.printf(idFieldFormat + " ", tds.getGroupName() + " c" + tds.getCondition()); } System.out.println(); // print newline // output ANOVA values line by line: OneWayAnova myANOVA = new OneWayAnova(); for (GroupedChannels.TaggedDataSequence first : allTDSs) { // output tds identifier in first column: System.out.printf(idFieldFormat + " ", first.getGroupName() + " c" + first.getCondition()); // create Collection to send to the ANOVA object: LinkedList<double[]> dataSets = new LinkedList<double[]>(); // convert first's data sequence to an array, then add it to // dataSets dataSets.add(toPrimitiveDoubleArray(first.getData())); dataSets.add(null); // placeholder for second's data sequence for (GroupedChannels.TaggedDataSequence second : allTDSs) { // convert and add second's data sequence to position one in // dataSets: dataSets.set(1, toPrimitiveDoubleArray(second.getData())); double result = -1; // not a valid ANOVA value so we know if // something went wrong try { result = myANOVA.anovaPValue(dataSets); } catch (Exception ex) { System.out.println(); localError("unknown problem calculating ANOVA: " + ex.getMessage()); } System.out.printf("%-" + idFieldWidth + "." + precision + "f ", result); // dataSets.remove(1); // remove second's data from dataSets } System.out.println(); // print newline } }
From source file:fNIRs.FNIRsStats.java
public static void writeANOVAs(File outFile, GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // open file for writing with a nice print stream object: PrintWriter ostream = makePWriter(outFile); // OKAY VAR NAME? // get all condition-group sequences: ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data.getAllSelectedTDSs(groupNames, conditions); // chunkData(allTDSs, numChunks); // COMMENT THIS LATER int idFieldWidth = getIdFieldWidth(groupNames, conditions, precision); String idFieldFormat = "%-" + idFieldWidth + "s"; // format string String separator = " , "; // what goes between columns of output // output the first row, containing identifying information for each // group-condition combination: // first, output spaces to take the place of the identifier column: ostream.printf("%" + idFieldWidth + "s" + separator, ""); // TOO HACKY?? // then, output all tds identifiers: for (GroupedChannels.TaggedDataSequence tds : allTDSs) { ostream.printf(idFieldFormat + separator, tds.getGroupName() + " c" + tds.getCondition()); }/*from w w w . java 2 s . c om*/ ostream.println(); // print newline // output ANOVA values line by line: OneWayAnova myANOVA = new OneWayAnova(); // this object will do the // ANOVAs for (GroupedChannels.TaggedDataSequence first : allTDSs) { // output tds identifier in first column: ostream.printf(idFieldFormat + separator, first.getGroupName() + " c" + first.getCondition()); // create Collection to send to the ANOVA object: LinkedList<double[]> dataSets = new LinkedList<double[]>(); // convert first's data sequence to an array, then add it to // dataSets dataSets.add(toPrimitiveDoubleArray(first.getData())); dataSets.add(null); // placeholder for second's data sequence for (GroupedChannels.TaggedDataSequence second : allTDSs) { // convert and add second's data sequence to position one in // dataSets: dataSets.set(1, toPrimitiveDoubleArray(second.getData())); double result = -1; // not a valid ANOVA value so we know if // something went wrong try { result = myANOVA.anovaPValue(dataSets); // if (first == second) { // if the two TDSs are the same // TDS, // result = 1; // then the ANOVA value should be 1, even // though a divide-by-zero // } } catch (Exception ex) { ostream.println(); System.out.println("foo"); localError("unknown problem calculating ANOVA: " + ex.getMessage()); System.out.println( "---------------------------------------------------------------------------------------------------------------------------------------"); for (double[] set : dataSets) { printDoubleAry(set); System.out.println("---------------------------------------"); } } if (result != result) { // if result is NaN System.out.println("NaN on " + first.getGroupName() + " c" + first.getCondition() + " and " + second.getGroupName() + " c" + second.getCondition()); } // AGAIN, SEE IF "PRECISON" == "NUMBER OF DECIMAL PLACES" ostream.printf("%-" + idFieldWidth + "." + precision + "f" + separator, result); } ostream.println(); // print newline } ostream.close(); }
From source file:fNIRs.FNIRsStats.java
public static void oldWriteANOVAs(File outFile, GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // open file for writing with a nice print stream object: PrintWriter ostream = makePWriter(outFile); // OKAY VAR NAME? // get all condition-group sequences: ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data.getAllSelectedTDSs(groupNames, conditions); // chunkData(allTDSs, numChunks); // COMMENT THIS LATER // calculate required widths for printed names and condition numbers: int nameWidth = longestLength(groupNames); // length of longest name int conditionWidth = // number of digits in the largest condition number String.valueOf(Collections.max(conditions)).length(); // make sure the fields will be wide enough to hold the ANOVA values, // which will consist of a 0 or 1 followed by a . and precision 0s: int idFieldWidth = nameWidth + 2 + conditionWidth; // 2 == " c".length() if (idFieldWidth < precision + 2) { // 2 == "1.".length() // if not, increase the condition width so the total field width is // large enough: // System.out.println("ANOVA values are wider than identifiers."); idFieldWidth = precision + 2;//w w w. j a v a 2 s .c o m } String idFieldFormat = "%-" + idFieldWidth + "s"; // format string // output the first row, containing identifying information for each // group-condition combination: // first, output proper-width placeholder for the identifier column: ostream.printf("%" + idFieldWidth + "s ", ""); // TOO HACKY?? // then, output all tds identifiers: for (GroupedChannels.TaggedDataSequence tds : allTDSs) { ostream.printf(idFieldFormat + " ", tds.getGroupName() + " c" + tds.getCondition()); // ostream.printf(idFieldFormat + " ", // tds.getGroupName(), // tds.getCondition()); } ostream.println(); // print newline // output ANOVA values line by line: OneWayAnova myANOVA = new OneWayAnova(); for (GroupedChannels.TaggedDataSequence first : allTDSs) { // output tds identifier in first column: ostream.printf(idFieldFormat + " ", first.getGroupName() + " c" + first.getCondition()); // create Collection to send to the ANOVA object: LinkedList<double[]> dataSets = new LinkedList<double[]>(); // convert first's data sequence to an array, then add it to // dataSets dataSets.add(toPrimitiveDoubleArray(first.getData())); dataSets.add(null); // placeholder for second's data sequence for (GroupedChannels.TaggedDataSequence second : allTDSs) { // convert and add second's data sequence to position one in // dataSets: dataSets.set(1, toPrimitiveDoubleArray(second.getData())); double result = -1; // not a valid ANOVA value so we know if // something went wrong try { result = myANOVA.anovaPValue(dataSets); // if (first == second) { // if the two TDSs are the same // TDS, // result = 1; // then the ANOVA value should be 1, even // though a divide-by-zero // } } catch (Exception ex) { ostream.println(); localError("unknown problem calculating ANOVA: " + ex.getMessage()); } if (result != result) { // if result is NaN System.out.println("NaN on " + first.getGroupName() + " c" + first.getCondition() + " and " + second.getGroupName() + " c" + second.getCondition()); } ostream.printf("%-" + idFieldWidth + "." + precision + "f ", result); } ostream.println(); // print newline } ostream.close(); }
From source file:fNIRs.FNIRsStats.java
public static void outputANOVAs(GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // get all condition-group sequences: ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data.getAllSelectedTDSs(groupNames, conditions); chunkData(allTDSs, numChunks); // COMMENT THIS LATER int idFieldWidth = getIdFieldWidth(groupNames, conditions, precision); // create a format string for the group/condition combination identifier // fields in the output: String idFieldFormat = "%-" + idFieldWidth + "s"; // format string String separator = " , "; // what goes between columns of output // output the first row, containing identifying information for each // group-condition combination: // first, output proper-width placeholder for the identifier column: System.out.printf("%" + idFieldWidth + "s" + separator, ""); // TOO // HACKY??//from ww w .j av a 2 s . com // then, output all tds identifiers: for (GroupedChannels.TaggedDataSequence tds : allTDSs) { System.out.printf(idFieldFormat + separator, tds.getGroupName() + " c" + tds.getCondition()); // System.out.printf(idFieldFormat + " ", // tds.getGroupName(), // tds.getCondition()); } System.out.println(); // print newline // output ANOVA values line by line: OneWayAnova myANOVA = new OneWayAnova(); for (GroupedChannels.TaggedDataSequence first : allTDSs) { // output tds identifier in first column: System.out.printf(idFieldFormat + separator, first.getGroupName() + " c" + first.getCondition()); // create Collection to send to the ANOVA object: LinkedList<double[]> dataSets = new LinkedList<double[]>(); // convert first's data sequence to an array, then add it to // dataSets dataSets.add(toPrimitiveDoubleArray(first.getData())); dataSets.add(null); // placeholder for second's data sequence for (GroupedChannels.TaggedDataSequence second : allTDSs) { // convert and add second's data sequence to position one in // dataSets: // dataSets.add(second.getData().toArray()); dataSets.set(1, toPrimitiveDoubleArray(second.getData())); double result = -1; // so it'll be obvious something's wrong // later if this doesn't get changed try { result = myANOVA.anovaPValue(dataSets); } catch (Exception ex) { System.out.println(); localError("unknown problem calculating ANOVA: " + ex.getMessage()); } System.out.printf("%-" + idFieldWidth + "." + precision + "f" + separator, result); // dataSets.remove(1); // remove second's data from dataSets } System.out.println(); // print newline } }
From source file:com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkProfile.java
private boolean addItem(LinkedList<ItemInfo> items, ItemInfo itemInfo) { boolean added = false; int idx = items.indexOf(itemInfo); if (idx != -1) { // HACK: Always swap existing ItemInfos with our new one, since it will // more up-to-date information ItemInfo existing = items.set(idx, itemInfo); assert (existing != null); return (true); }//w ww .jav a2 s . c o m if (itemInfo.hasCurrentPrice()) assert (itemInfo.getCurrentPrice() > 0) : "Negative current price for " + itemInfo; // If we have room, shove it right in // We'll throw it in the back because we know it hasn't been used yet if (items.size() < AuctionMarkConstants.ITEM_ID_CACHE_SIZE) { items.addLast(itemInfo); added = true; // Otherwise, we can will randomly decide whether to pop one out } else if (this.rng.nextBoolean()) { items.pop(); items.addLast(itemInfo); added = true; } return (added); }
From source file:se.trixon.pacoma.collage.Page.java
/** * * @return Representation of the page in ASCII art *///from ww w . j a va 2 s .c o m @Override public String toString() { /* Returns something like: [62 52] [125 134-- ------] [62 87] [62 47] [62 66] [125 132-- [62 45] [62 46] ------] [62 49] ------] [62 78] ------] [62 49] [62 45] [125 102-- ------] [62 49] [62 65] [125 135-- [62 85] [62 53] [125 91-- [125 89-- [62 64] ------] */ LinkedList<String> lines = new LinkedList<>(); int n = 0; boolean end = false; while (!end) { lines.add(""); end = true; for (Column col : mColumns) { String[] cells = col.toString().split("\\n"); int w = 0; for (String s : cells) { w = Math.max(w, s.length()); } if (col != mColumns.getLast()) { w += 1; } String cell = StringUtils.repeat(" ", w); if (n < cells.length) { cell = cells[n] + StringUtils.repeat(" ", w - cells[n].length()); if (n < cells.length - 1) { end = false; } } lines.set(lines.size() - 1, lines.getLast() + cell); } n++; } return String.join("\n", lines); }
From source file:gov.nih.nci.caadapter.ui.mapping.sdtm.SDTMMapFileTransformer.java
public void startTransform() { // _mappedData _csvDataFromFile Iterate over the keys in the map Iterator it = _mappedData.keySet().iterator(); while (it.hasNext()) { // Get key Object key = it.next();/*from w ww .j a va 2 s .c o m*/ if (_csvDataFromFile.containsKey(key)) { String _tmp = (String) _csvDataFromFile.get(key); StringTokenizer _str = new StringTokenizer(_tmp.toString(), "&"); while (_str.hasMoreTokens()) { LinkedList<String> _new = new LinkedList<String>(); // dummy list initialized for (int j = 0; j < defineXMLList.size(); j++) { _new.add(""); } // to retrieve the data from the csv file EmptyStringTokenizer _emp = new EmptyStringTokenizer(_str.nextToken(), ","); // to get all the fields for the segment // StringBuffer _md = (StringBuffer) _mappedData.get(key); // for (int j=0; j<_mappedData.size(); j++){ Iterator it1 = _mappedData.keySet().iterator(); while (it1.hasNext()) { // Get key Object key1 = it1.next(); StringBuffer _md = (StringBuffer) _mappedData.get(key1); StringTokenizer _strT = new StringTokenizer(_md.toString(), ","); while (_strT.hasMoreTokens()) { StringTokenizer s = new StringTokenizer(_strT.nextToken(), "?"); int pos_ = new Integer(s.nextToken().substring(0, 1)).intValue(); String _sRef = s.nextToken(); // System.out.println(pos_+" for is "+_sRef); _new.set(defineXMLList.indexOf(_sRef), _emp.getTokenAt(pos_ - 1)); } } System.out.println(_new); } } } }
From source file:fi.ni.IFC_ClassModel.java
/** * Map entries.//from ww w . jav a 2 s . c o m */ @SuppressWarnings("unchecked") private void mapEntries() { for (Map.Entry<Long, IFC_X3_VO> entry : linemap.entrySet()) { IFC_X3_VO vo = entry.getValue(); // Initialize the object_buffer try { Thing thing = object_buffer.get(vo.getLine_num()); if (thing == null) { @SuppressWarnings("rawtypes") Class cls = Class.forName("fi.ni.ifc2x3." + entities.get(vo.name).getName()); @SuppressWarnings("rawtypes") Constructor ct = cls.getConstructor(); thing = (Thing) ct.newInstance(); thing.i.drum_setLine_number(vo.getLine_num()); object_buffer.put(vo.getLine_num(), (Thing) thing); } } catch (Exception e) { e.printStackTrace(); } for (int i = 0; i < vo.list.size(); i++) { Object o = vo.list.get(i); if (String.class.isInstance(o)) { String s = (String) o; if (s.length() < 1) continue; if (s.charAt(0) == '#') { Object or = linemap.get(toLong(s.substring(1))); vo.list.set(i, or); } } if (LinkedList.class.isInstance(o)) { LinkedList<Object> tmp_list = (LinkedList<Object>) o; for (int j = 0; j < tmp_list.size(); j++) { Object o1 = tmp_list.get(j); if (String.class.isInstance(o1)) { String s = (String) o1; if (s.length() < 1) continue; if (s.charAt(0) == '#') { Object or = linemap.get(toLong(s.substring(1))); if (or == null) { System.err.println("Reference to non-existing line in the IFC file."); tmp_list.set(j, "-"); } else tmp_list.set(j, or); } } else if (LinkedList.class.isInstance(o1)) { LinkedList<Object> tmp2_list = (LinkedList<Object>) o1; for (int j2 = 0; j2 < tmp2_list.size(); j2++) { Object o2 = tmp2_list.get(j2); if (String.class.isInstance(o2)) { String s = (String) o2; if (s.length() < 1) continue; if (s.charAt(0) == '#') { Object or = linemap.get(toLong(s.substring(1))); if (or == null) { System.err.println("Reference to non-existing line in the IFC file."); tmp_list.set(j, "-"); } else tmp_list.set(j, or); } } } } } } } } }
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ???/*from w w w . ja v a2s . com*/ * @param degree */ @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> setOperatorMenuWithDegree(String degree, String contextPath) { String sql = "select VALUE_ID FROM TBL_ROLE_FUNC_MAP ,TBL_ROLE_INF WHERE ROLE_ID = KEY_ID and KEY_ID = " + degree; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<Object> funcMapList = commQueryDAO.findBySQLQuery(sql); List<Object> menuLvl1List = allMenuBean.getDataList(); LinkedHashMap<String, Object> menuIndexMap = new LinkedHashMap<String, Object>(); //????? for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> menuLvl1Map = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) menuLvl1Map.get(Constants.MENU_CHILDREN); for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> menuLvl2Map = (Map<String, Object>) menuLvl2List.get(j); LinkedList<Object> menuLvl3List = (LinkedList<Object>) menuLvl2Map.get(Constants.MENU_CHILDREN); for (int k = 0, l = menuLvl3List.size(); k < l; k++) { Map<String, Object> menuLvl3Map = (Map<String, Object>) menuLvl3List.get(k); for (int a = 0, b = funcMapList.size(); a < b; a++) { if (StringUtils.trim(funcMapList.get(a).toString()) .equals(StringUtils.trim(menuLvl3Map.get(Constants.MENU_ID).toString()))) { if (!menuIndexMap.containsKey(menuLvl1Map.get(Constants.MENU_ID).toString())) { Map<String, Object> menuLvl1HashMap = new LinkedHashMap<String, Object>(); menuLvl1HashMap.put(Constants.MENU_ID, menuLvl1Map.get(Constants.MENU_ID)); menuLvl1HashMap.put(Constants.MENU_TEXT, menuLvl1Map.get(Constants.MENU_TEXT)); menuLvl1HashMap.put(Constants.MENU_CLS, menuLvl1Map.get(Constants.MENU_CLS)); menuLvl1HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL1_FUNC); menuLvl1HashMap.put(Constants.TOOL_BAR_TYPE, Constants.TOOL_BAR_BUTTON); menuLvl1HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENU); Map<String, Object> menuLvl2HashMap = new LinkedHashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); // menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); // menuLvl2HashMap.put(Constants.TOOLBAR_ICON, menuLvl2Map.get(Constants.TOOLBAR_ICON)); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); LinkedList<Object> menuLvl2Child = new LinkedList<Object>(); menuLvl2Child.add(menuLvl2HashMap); menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } else { Map<String, Object> menuLvl1HashMap = (Map<String, Object>) menuIndexMap .get(menuLvl1Map.get(Constants.MENU_ID).toString()); LinkedList<Object> menuLvl2Child = (LinkedList<Object>) menuLvl1HashMap .get(Constants.MENU_CHILDREN); boolean hasMenu = false; for (int c = 0, d = menuLvl2Child.size(); c < d; c++) { Map<String, Object> menuLvl2HashMap = (Map<String, Object>) menuLvl2Child .get(c); if (StringUtils.trim(menuLvl2HashMap.get(Constants.MENU_ID).toString()).equals( StringUtils.trim(menuLvl2Map.get(Constants.MENU_ID).toString()))) { LinkedList<Object> menuLvl3Child = (LinkedList<Object>) menuLvl2HashMap .get(Constants.MENU_CHILDREN); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.set(c, menuLvl2HashMap); hasMenu = true; break; } } if (!hasMenu) { Map<String, Object> menuLvl2HashMap = new HashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); // menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); // menuLvl2HashMap.put(Constants.TOOLBAR_ICON, menuLvl2Map.get(Constants.TOOLBAR_ICON)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.add(menuLvl2HashMap); } menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } } } } } } return menuIndexMap; }