Java - Rest

Learning how to use a REST system as a web service.

Cars / Class

package ws;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import model.Cars;
import model.Inventory;

/**
 * REST Web Service
 *
 * @author Steven Bartsch
 */

@Path("generic")
public class CarsResource{

    @Context
    private UriInfo context;
    private CarsXML cars;

    public CarsResource(){
        //loads cars into memory
        cars = new CarsXML();
    }

    @GET
    @Produces("application/json")
    @Path("cars")
    public Inventory getCars(){
        Inventory inv = new Inventory();  
        inv.setList(cars.getCars());      
        return inv;
    }

    @GET
    @Produces("application/json")
    @Path("id/{id}")
    public Cars getCarById(@PathParam("id") int id){
        for (Cars c : cars.getCars())
            if (c.getId() == id)
                return c;
        System.out.println("Client used getCarById");
        return new Cars();
    }

    @GET
    @Produces("application/json")
    @Path("model/{model}")
    public Inventory getModels(@PathParam("model") String model){
        Inventory inv = new Inventory();        
        for (Cars c : cars.getCars())
            if (c.getModel().equals(model))
                inv.getInventory().add(c);
        return inv;
    }

    @GET
    @Produces("application/json")
    @Path("type/{type}")
    public Inventory getTypes(@PathParam("type") String type){
        Inventory inv = new Inventory();        
        for (Cars c : cars.getCars())
            if (c.getType().equals(type))
                inv.getInventory().add(c);
        return inv;
    }

    @GET
    @Produces("application/json")
    @Path("price/{from}:{to}")
    public Inventory getPriceRanges(@PathParam("from") int from, @PathParam("to") int to){
        Inventory inv = new Inventory();        
        for (Cars c : cars.getCars())
            if (c.getPrice() >= from && c.getPrice() <= to)
                inv.getInventory().add(c);
        return inv;
    }

    @POST
    @Path("add")
    @Consumes("application/json")
    public void add(Cars car){
        System.out.println("Client used add car");
        System.out.print(car);
        cars.add(car);
    }

    @DELETE
    @Path("delete/{id}")
    @Consumes("application/json")
    public void delete(@PathParam("id")String id){
        System.out.println(Integer.parseInt(id));
        cars.delete(Integer.parseInt(id));
    }

    @PUT
    @Consumes("application/json")
    @Path("update/{id}/{price}")
    public void update(@PathParam("id") String id, @PathParam("price") String price){
        System.out.println("UPDATE: Grabbed paramters id, price: " + id + ", " + price);
        cars.update(Integer.parseInt(id), Integer.parseInt(price));
    }
}