Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Rest' - 6 code snippet(s) found

 Sample 1. Rest Web Service ( Get ) using Jersey

@Path("/employeeInfo")
public class RestWebServiceJersey {
@GET
@Path("/detail/{employeeId}")
@Produces(MediaType.APPLICATION_JSON)
public String getEmployeeInfo(@PathParam("employeeId") String employeeId) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("EmployeeName", "Sam");
jsonObj.put("EmployeeDept", "Marketing");
return jsonObj.toString();
}
}

   Like      Feedback     rest  rest web service  jersey  @path  @get  @produces  MediaType.APPLICATION_JSON  @PathParam  JSONObject  javax.json.JSONObject


 Sample 2. Rest Web Service ( Post ) using Jersey, XML

@Path("/employeeInfo")
public class RestWebServiceJersey {
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public String submitEmployeeInfo(Employee employee) {
StatusDto status = insertIntoDb(employee);
return status;
}
}

   Like      Feedback     rest  @post  @consumes  @produces  xml  rest web service  jersey  javax.ws.rs.Path  javax.ws.rs.Post  javax.ws.rs.Produces  javax.ws.rs.Consumes  javax.ws.rs.core.MediaType


 Sample 3. Code Sample / Example / Snippet of static org.hamcrest.CoreMatchers.not

  public ParameterExpression(int modifier, Type type, String name) {

super(ExpressionType.Parameter, type);

assert name != null : "name should not be null";

assert Character.isJavaIdentifierStart(name.charAt(0))

: "parameter name should be valid java identifier: "

+ name + ". The first character is invalid.";

this.modifier = modifier;

this.name = name;

}


   Like      Feedback      static org.hamcrest.CoreMatchers.not


 Sample 4. Code Sample / Example / Snippet of org.hamcrest.Matcher

    private void defineVariables(String line) {

Matcher varDefn = matchesVarDefn.matcher(line);

if (varDefn.lookingAt()) {

String var = varDefn.group(1);

String val = varDefn.group(2);

vars.define(var, val);

} else {

String[] words = splitWords.split(line);

for (String var : words) {

String value = System.getenv(var);

vars.define(var, value);

}

}

}


   Like      Feedback      org.hamcrest.Matcher


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 5. Code Sample / Example / Snippet of static org.hamcrest.CoreMatchers.is

  public static final List<Pair<String, String>> FOODMART_QUERIES =

querify(QUERIES);



@Test public void testJanino169() {

CalciteAssert.that()

.with(CalciteAssert.Config.JDBC_FOODMART)

.query(

"select "time_id" from "foodmart"."time_by_day" as "t" ")

.returnsCount(730);

}




   Like      Feedback      static org.hamcrest.CoreMatchers.is


 Sample 6. Code Sample / Example / Snippet of org.apache.ace.client.rest.util.WebResource

    public static WebResource createEntity(Client c, WebResource work, String type, String data) throws IOException {

WebResource entity = work.path(type);

try {

entity.post(data);

throw new IOException("Could not create " + type + " with data " + data);

}

catch (WebResourceException e2) {

return c.resource(e2.getResponse().getLocation());

}

}


   Like      Feedback      org.apache.ace.client.rest.util.WebResource



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner