/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package exemple1; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; import javax.ws.rs.Produces; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PUT; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; /** * REST Web Service * * @author 71143 */ @Path("mobile") public class Test1 { @Context private UriInfo context; /** * Creates a new instance of Test1 */ public Test1() { } @GET @Path("pro&{val1}&{val2}&{val3}&{val4}") @Produces(MediaType.TEXT_PLAIN) public String getText(@PathParam("val1") String theReceivedNameValue, @PathParam("val2") int theReceivedValue1, @PathParam("val3") int theReceivedValue2, @PathParam("val4") int theReceivedValue3) { if (theReceivedNameValue.toUpperCase().equals("AP") || theReceivedNameValue.toUpperCase().equals("GP")) { String result = "" + theReceivedValue1; int nextValue = theReceivedValue1; for (int i = 0; i < theReceivedValue3 - 1; i++) { if (theReceivedNameValue.toUpperCase().equals("AP")) { nextValue += theReceivedValue2; } else { nextValue *= theReceivedValue2; } result += ", " + nextValue; } result += "."; return "The result is " + result; } else { return "ERROR INPUT"; } } }