Package com.director.core.json

Examples of com.director.core.json.JsonParser


   @Override
   public DirectTransactionResult execute(DirectAction directAction, DirectMethod directMethod, DirectTransactionData data)
         throws DirectException {
      Object[] params = directMethod.parseParameters(data);
      Object result = invokeActionMethod(action, directAction, directMethod, params);
      JsonParser parser = DirectContext.get().getConfiguration().getParser();
      return parser.buildResult(directMethod, result);
   }
View Full Code Here


            }

            transactionString = transactionString.trim();
            transactionString = transactionString.startsWith("{") ? "[" + transactionString + "]" : transactionString;

            JsonParser jsonParser = DirectContext.get().getConfiguration().getParser();
            return jsonParser.parse(transactionString, DirectTransaction[].class);

         } catch(Exception e) {
            throw new DirectException("Error while parse transaction from request", e);
         }
      }
View Full Code Here

      }

      public void format(DirectEvent[] events) {
         try {
            DirectConfiguration configuration = DirectContext.get().getConfiguration();
            JsonParser jsonParser = configuration.getParser();
            PrintWriter writer = this.response.getWriter();
            jsonParser.format(events, writer);
         } catch(IOException e) {
            throw new DirectException(e);
         }
      }
View Full Code Here

      @Override
      public void format(DirectEvent[] events) {
         try {
            this.response.setContentType("text/html");
            JsonParser jsonParser = DirectContext.get().getConfiguration().getParser();
            PrintWriter writer = this.response.getWriter();
            writer.write("<html><body><textarea>");
            jsonParser.format(events, writer);
            writer.write("</textarea></body></html>");
         } catch(IOException e) {
            throw new DirectException(e);
         }
      }
View Full Code Here

   public DirectTransactionResult execute(DirectAction directAction, DirectMethod directMethod, DirectTransactionData data) throws DirectException {
      try {
         Class actionClass = directAction.getActionClass();
         Object result = directMethod.getMethod().invoke(actionClass.newInstance(), directMethod.parseParameters(data));
         JsonParser parser = DirectContext.get().getConfiguration().getParser();
         return parser.buildResult(directMethod, result);
      } catch(InvocationTargetException e) {
         String message = "Cannot invoke the action method " + directMethod + " of the direct class " + directAction;
         throw new DirectException(message, e.getTargetException());
      } catch(Throwable e) {
         String message = "Cannot invoke the action method " + directMethod + " of the direct class " + directAction;
View Full Code Here

         if(aClass != null && Map.class.isAssignableFrom(aClass)) {
            return (T) this.formData;
         }

         JsonParser parser = DirectContext.get().getConfiguration().getParser();
         String fromMapToJson = parser.format(this.formData);
         return (T) parser.parse(fromMapToJson, type);
      }

      throw new DirectException("Cannot access to parameter with order: " + order + " with form data");
   }
View Full Code Here

   @Override
   public <T> T parseValue(String name, Type type) {
      Object value = this.formData.get(name);
      if(value instanceof String) {
         JsonParser parser = DirectContext.get().getConfiguration().getParser();
         value = parser.parse("\"" + ((String) value).replace("\"", "\\\"") + "\"", type);
      }
      return (T) value;
   }
View Full Code Here

TOP

Related Classes of com.director.core.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.