1 package com.mvnforum.jaxb.dao; 2 3 import java.util.Collection ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 7 import javax.xml.bind.JAXBException; 8 9 import com.mvnforum.jaxb.db.Mvnforum; 10 import com.mvnforum.jaxb.db.MvnforumType; 11 import com.mvnforum.jaxb.db.ObjectFactory; 12 import com.mvnforum.jaxb.db.RankType; 13 import com.mvnforum.jaxb.db.MvnforumType.RankListType; 14 import com.mvnforum.jaxb.util.XMLUtil; 15 16 public class RankListDAO { 17 18 public RankListType getRankListType(Collection rankTypes) throws JAXBException { 19 ObjectFactory objectFactory = XMLUtil.getObjectFactory(); 20 MvnforumType.RankListType rankListType = objectFactory.createMvnforumTypeRankListType(); 21 for (Iterator iter = rankTypes.iterator(); iter.hasNext(); ) { 22 rankListType.getRank().add(iter.next()); 23 } 24 return rankListType; 25 } 26 27 public RankType getRankType (int rankMinPosts, int rankLevel, String rankTitle, String rankImage, int rankType, int rankOption) throws JAXBException { 28 ObjectFactory objectFactory = XMLUtil.getObjectFactory(); 29 RankType rank = objectFactory.createRankType(); 30 rank.setRankMinPosts(rankMinPosts); 31 rank.setRankLevel(rankLevel); 32 rank.setRankTitle(rankTitle); 33 rank.setRankImage(rankImage); 34 rank.setRankType(rankType); 35 rank.setRankOption(rankOption); 36 return rank; 37 } 38 39 public List importRankType () throws JAXBException { 40 Mvnforum mvnforum = XMLUtil.getMvnforum(); 41 RankListType rankListType = mvnforum.getRankList(); 42 return rankListType.getRank(); 43 } 44 45 } 46 | Popular Tags |