fix some compiler warnings after tweaking what it warns on

This commit is contained in:
Andy Janata 2011-12-24 19:51:49 -08:00
parent 401b3fed2e
commit ce273d533c
3 changed files with 30 additions and 29 deletions

View File

@ -1,13 +1,5 @@
package net.socialgamer.cah;
import net.socialgamer.cah.db.BlackCard;
import net.socialgamer.cah.db.WhiteCard;
import org.apache.commons.lang3.StringEscapeUtils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@ -18,6 +10,14 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.socialgamer.cah.db.BlackCard;
import net.socialgamer.cah.db.WhiteCard;
import org.apache.commons.lang3.StringEscapeUtils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
/**
* Servlet implementation class TestServlet
@ -44,23 +44,24 @@ public class TestServlet extends HttpServlet {
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
// response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
final PrintWriter out = response.getWriter();
// ServletOutputStream out = response.getOutputStream();
Session session = sessionFactory.openSession();
@SuppressWarnings("rawtypes")
List b = session.createQuery("from BlackCard order by random()").list();
for (BlackCard bc : (List<BlackCard>) b) {
final Session session = sessionFactory.openSession();
@SuppressWarnings("unchecked")
final List<BlackCard> b = session.createQuery("from BlackCard order by random()").list();
for (final BlackCard bc : b) {
out.println(StringEscapeUtils.escapeHtml4(bc.toString()));
}
out.println("\n\n\n");
@SuppressWarnings("rawtypes")
List w = session.createQuery("from WhiteCard order by random()").list();
for (WhiteCard wc : (List<WhiteCard>) w) {
@SuppressWarnings("unchecked")
final List<WhiteCard> w = session.createQuery("from WhiteCard order by random()").list();
for (final WhiteCard wc : w) {
out.println(StringEscapeUtils.escapeHtml4(wc.toString()));
}

View File

@ -10,20 +10,20 @@ import org.hibernate.Session;
public class BlackDeck {
private List<BlackCard> deck;
private List<BlackCard> dealt;
private final List<BlackCard> deck;
private final List<BlackCard> dealt;
@SuppressWarnings("unchecked")
public BlackDeck() {
Session session = HibernateUtil.instance.sessionFactory.openSession();
deck = (List<BlackCard>) session.createQuery("from BlackCard order by random()").list();
final Session session = HibernateUtil.instance.sessionFactory.openSession();
deck = session.createQuery("from BlackCard order by random()").list();
dealt = new ArrayList<BlackCard>();
}
public BlackCard getNextCard() {
// Without knowing what the implementation of List that Hibernate returns
// is, I'm going to pull from the end instead of the beginning.
BlackCard card = deck.get(deck.size() - 1);
final BlackCard card = deck.get(deck.size() - 1);
deck.remove(deck.size() - 1);
dealt.add(card);
return card;

View File

@ -3,28 +3,28 @@ package net.socialgamer.cah.data;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import net.socialgamer.cah.HibernateUtil;
import net.socialgamer.cah.db.WhiteCard;
import org.hibernate.Session;
public class WhiteDeck {
private List<WhiteCard> deck;
private List<WhiteCard> dealt;
private final List<WhiteCard> deck;
private final List<WhiteCard> dealt;
@SuppressWarnings("unchecked")
public WhiteDeck() {
Session session = HibernateUtil.instance.sessionFactory.openSession();
deck = (List<WhiteCard>) session.createQuery("from WhiteCard order by random()").list();
final Session session = HibernateUtil.instance.sessionFactory.openSession();
deck = session.createQuery("from WhiteCard order by random()").list();
dealt = new ArrayList<WhiteCard>();
}
public WhiteCard getNextCard() {
// Without knowing what the implementation of List that Hibernate returns
// is, I'm going to pull from the end instead of the beginning.
WhiteCard card = deck.get(deck.size() - 1);
final WhiteCard card = deck.get(deck.size() - 1);
deck.remove(deck.size() - 1);
dealt.add(card);
return card;