Package org.exoplatform.ws.frameworks.json

Examples of org.exoplatform.ws.frameworks.json.JsonParser


   public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException
   {
      try
      {
         JsonParser jsonParser = new JsonParserImpl();
         JsonHandler jsonHandler = new JsonDefaultHandler();
         jsonParser.parse(entityStream, jsonHandler);
         JsonValue jsonValue = jsonHandler.getJsonObject();
         // jsonValue can be null if stream empty
         if (jsonValue == null)
            return null;
         return new BeanBuilder().createObject(type, jsonValue);
View Full Code Here


      sourceCollection.add(javaScriptBook);
   }

   public void testCollectionArrayList() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getArrayList().get(2).equals(sourceCollection.get(2)));
   }

   public void testCollectionVector() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getVector().get(2).equals(sourceCollection.get(2)));
   }

   public void testCollectionLinkedList() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getLinkedList().get(2).equals(sourceCollection.get(2)));
   }

   public void testCollectionLinkedHashSet() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getLinkedHashSet().contains(sourceCollection.get(2)));
   }

   public void testCollectionHashSet() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getHashSet().contains(sourceCollection.get(2)));
   }

   public void testCollectionList() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getList().get(2).equals(sourceCollection.get(2)));
   }

   public void testCollectionSet() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getSet().contains(sourceCollection.get(2)));
   }

   public void testCollectionQueue() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

      assertTrue(o.getQueue().contains(sourceCollection.get(2)));
   }

   public void testCollectionCollection() throws Exception
   {
      JsonParser jsonParser = new JsonParserImpl();
      // check restore different type of Collection
      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
         "CollectionTest.txt")), handler);
      JsonValue jsonValue = handler.getJsonObject();

      JavaCollectionBean o = ObjectBuilder.createObject(JavaCollectionBean.class, jsonValue);
View Full Code Here

TOP

Related Classes of org.exoplatform.ws.frameworks.json.JsonParser

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.