Package com.sun.jersey.api.json

Examples of com.sun.jersey.api.json.JSONWithPadding


      "application/x-javascript", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML
  })
  @Path("/allEvents")
  public JSONWithPadding getEvents(@QueryParam("callback") @DefaultValue("event") String callback) {
    List<CalendarEvent> resultList = calendarDao.getAllEvents();
    return new JSONWithPadding(new GenericEntity<Collection<CalendarEvent>>(resultList) {}, callback);
  }
View Full Code Here


            } else {
                child = new ZChildren(path, ui.getAbsolutePath().toString(),
                        childTemplate, children);
            }
            return Response.status(Response.Status.OK).entity(
                    new JSONWithPadding(child, callback)).build();
        } else {
            Stat stat = new Stat();
            byte[] data = zk.getData(path, false, stat);

            byte[] data64;
            String dataUtf8;
            if (data == null) {
                data64 = null;
                dataUtf8 = null;
            } else if (!dataformat.equals("utf8")){
                data64 = data;
                dataUtf8 = null;
            } else {
                data64 = null;
                dataUtf8 = new String(data);
            }
            ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(),
                    data64, dataUtf8, stat.getCzxid(),
                    stat.getMzxid(), stat.getCtime(), stat.getMtime(),
                    stat.getVersion(), stat.getCversion(),
                    stat.getAversion(), stat.getEphemeralOwner(),
                    stat.getDataLength(), stat.getNumChildren(),
                    stat.getPzxid());

            return Response.status(Response.Status.OK).entity(
                    new JSONWithPadding(zstat, callback)).build();
        }
    }
View Full Code Here

                stat.getAversion(), stat.getEphemeralOwner(),
                stat.getDataLength(), stat.getNumChildren(),
                stat.getPzxid());

        return Response.status(Response.Status.OK).entity(
                new JSONWithPadding(zstat, callback)).build();
    }
View Full Code Here

                createMode);

        URI uri = ui.getAbsolutePathBuilder().path(newPath).build();

        return Response.created(uri).entity(
                new JSONWithPadding(new ZPath(newPath,
                        ui.getAbsolutePath().toString()))).build();
    }
View Full Code Here

            } else if (format.equals("xml")) {
                return Response.ok(response).type(MediaType.APPLICATION_XML)
                        .build();
            } else if (format.equals("jsonp")) {
                return Response.ok()
                        .entity(new JSONWithPadding(response, callback))
                        .type("application/x-javascript").build();
            } else {
                throw new UnsupportedFormatException();
            }
        } else {
View Full Code Here

      JSONObject errorObj = new JSONObject();
      errorObj.put("code", "500");
      errorObj.put("message", "Internal Server Error");
      errorObj.put("error", e.getMessage());
      returnString = errorObj.toString();
      return new JSONWithPadding(returnString, callback);
    }
    return new JSONWithPadding (returnString, callback);
  }
View Full Code Here

@Path("/nonJAXBResource")
public class NonJAXBBeanResource {

    @GET @Produces({"application/javascript", MediaType.APPLICATION_JSON})
    public JSONWithPadding getSimpleBeanJSONP() {
        return new JSONWithPadding(new NonJAXBBean());
    }
View Full Code Here

        changes.add(new ChangeRecordBean(false, 1,"fixing typo"));
    }

    @GET
    public JSONWithPadding getChanges(@QueryParam("callback") String callback, @QueryParam("type") int type) {
        return new JSONWithPadding(new GenericEntity<List<ChangeRecordBean>>(changes){}, callback);
    }
View Full Code Here

        return new JSONWithPadding(new GenericEntity<List<ChangeRecordBean>>(changes){}, callback);
    }

    @GET @Path("latest")
    public JSONWithPadding getLastChange(@QueryParam("callback") String callback, @QueryParam("type") int type) {
        return new JSONWithPadding(changes.get(changes.size() - 1), callback);
    }
View Full Code Here

            } else {
                child = new ZChildren(path, ui.getAbsolutePath().toString(),
                        childTemplate, children);
            }
            return Response.status(Response.Status.OK).entity(
                    new JSONWithPadding(child, callback)).build();
        } else {
            Stat stat = new Stat();
            byte[] data = zk.getData(path, false, stat);

            byte[] data64;
            String dataUtf8;
            if (data == null) {
                data64 = null;
                dataUtf8 = null;
            } else if (!dataformat.equals("utf8")) {
                data64 = data;
                dataUtf8 = null;
            } else {
                data64 = null;
                dataUtf8 = new String(data);
            }
            ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(),
                    data64, dataUtf8, stat.getCzxid(), stat.getMzxid(), stat
                            .getCtime(), stat.getMtime(), stat.getVersion(),
                    stat.getCversion(), stat.getAversion(), stat
                            .getEphemeralOwner(), stat.getDataLength(), stat
                            .getNumChildren(), stat.getPzxid());

            return Response.status(Response.Status.OK).entity(
                    new JSONWithPadding(zstat, callback)).build();
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.json.JSONWithPadding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.