protected List<Data> createOutData( List<Category> categories, List<Board> boards, List<Message> messages) { Vector<Data> alldata = new Vector<Data>(); HashMap<String, String> board2Categories = new HashMap<String, String>(); for (Iterator iter = categories.iterator(); iter.hasNext(); ) { Category cat = (Category) iter.next(); Data data = new Data(); data.id = cat.id; data.type = Type.CATEGORY; data.title = cat.name; alldata.add(data); } int boardStartIndex = alldata.size(); for (Iterator iter = boards.iterator(); iter.hasNext(); ) { Board board = (Board) iter.next(); Data data = new Data(); data.id = board.id; data.type = Type.BOARD; data.title = board.name; data.content = board.description; data.parentid = (board.parenttype == Type.CATEGORY) ? board.category : board.parent; data.parenttype = board.parenttype; alldata.add(data); board2Categories.put(data.type + data.id, data.parenttype + data.parentid); } int boardEndIndex = alldata.size(); for (int i = boardStartIndex; i < boardEndIndex; i++) { Data boardData = alldata.get(i); if (Type.CATEGORY == boardData.parenttype) boardData.ancestors = boardData.parenttype + boardData.parentid; else boardData.ancestors = getBoardAncestors(board2Categories, boardData.parentid); } for (Iterator iter = messages.iterator(); iter.hasNext(); ) { Message msg = (Message) iter.next(); Data data = new Data(); data.id = msg.id; data.type = msg.isfirst ? Type.TOPIC : Type.REPLY; data.title = msg.title; data.content = msg.content; data.parentid = msg.isfirst ? msg.board : msg.topic; data.parenttype = msg.isfirst ? Type.BOARD : Type.TOPIC; data.ancestors = getMessageAncestors(board2Categories, msg); data.time = msg.time; data.userid = msg.userid; data.username = msg.username; data.useremail = msg.useremail; data.attachmentdelim = getAttachmentDelim(msg.id, data.ATTACH_DELIM); data.attachments = getAttachmentList(msg.id, data.attachmentdelim); data.attachmentnames = getAttachmentNames(msg.id, data.attachmentdelim); alldata.add(data); } return alldata; }
public MethodPropertyContext(Method getter) { synchronized (cache) { Data previous = cache.get(getter); if (previous != null) { this.data = previous; return; } this.data = new Data(); data.genericType = getter.getGenericReturnType(); data.type = getter.getReturnType(); // Compute collection element type if (Collection.class.isAssignableFrom(getType())) { data.elementType = TypeUtils.ensureBaseType( TypeUtils.getSingleParameterization( Collection.class, getter.getGenericReturnType(), getter.getReturnType())); } else if (Map.class.isAssignableFrom(getType())) { Type[] types = TypeUtils.getParameterization(Map.class, getter.getGenericReturnType()); data.keyType = TypeUtils.ensureBaseType(types[0]); data.valueType = TypeUtils.ensureBaseType(types[1]); } cache.put(getter, data); } }