package br.com.alura.gerenciador.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.InetSocketAddress;
import java.rmi.ServerException;
import java.util.Collection;
import java.util.concurrent.Executor;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import br.com.alura.gerenciador.Empresa;
import br.com.alura.gerenciador.dao.EmpresaDAO;
public class BuscaEmpresa<HttpServletRequest, HttpServletResponse> extends HttpServer {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
{
PrintWriter writer = resp.getWriter();
writer.println("<html>");
writer.println("<body>");
writer.println("Resultado da busca:<br/>");
String filtro = req.getParameter("filtro");
Collection<Empresa> empresas = new EmpresaDAO()
.buscaPorSimilaridade(filtro);
writer.println("<ul>");
for (Empresa empresa : empresas) {
writer.println("<li>" + empresa.getId() + ": " + empresa.getNome() + "</li>");
}
writer.println("</ul>");
writer.println("</body>");
writer.println("</html>");
}
}
@Override
public void bind(InetSocketAddress arg0, int arg1) throws IOException {
// TODO Auto-generated method stub
}
@Override
public HttpContext createContext(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public HttpContext createContext(String arg0, HttpHandler arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public InetSocketAddress getAddress() {
// TODO Auto-generated method stub
return null;
}
@Override
public Executor getExecutor() {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeContext(String arg0) throws IllegalArgumentException {
// TODO Auto-generated method stub
}
@Override
public void removeContext(HttpContext arg0) {
// TODO Auto-generated method stub
}
@Override
public void setExecutor(Executor arg0) {
// TODO Auto-generated method stub
}
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop(int arg0) {
// TODO Auto-generated method stub
}
}