Examples of JsonDecoder


Examples of com.jaxws.json.codec.decode.JSONDecoder

    }
    //
    Message     message     = null;
    com.sun.xml.ws.encoding.ContentType   contentType    = new com.sun.xml.ws.encoding.ContentType(sContentType);
    if(contentType.getBaseType().equalsIgnoreCase(JSONContentType.JSON_MIME_TYPE)){
      JSONDecoder decoder = new JSONDecoder(this,in,packet);
      if(traceLog != null)traceLog.info("calling json to ws message converter: "+ new Date());
      try{
        message = decoder.getWSMessage();
      }catch(Exception exp){
        if(traceLog != null)traceLog.error(exp.getMessage());
        if(packet.supports(MessageContext.SERVLET_RESPONSE)){
          ((HttpServletResponse)packet.get(MessageContext.SERVLET_RESPONSE)).setStatus(400);
        }
        throwMessageCreationException(exp, traceLog);
      }
      if(traceLog != null)traceLog.info("Message decoded successfully: " + new Date());
    } else if(contentType.getBaseType().equalsIgnoreCase(FormDecoder.FORM_MULTIPART) ||
        contentType.getBaseType().equalsIgnoreCase(FormDecoder.FORM_URLENCODED)){
      FormDecoder decoder = new FormDecoder(this,in,packet, contentType);
      if(traceLog != null)traceLog.info("calling FORM data to ws message converter: "+ new Date());
      try{
        message = decoder.getWSMessage();
      }catch(Exception exp){
        if(traceLog != null)traceLog.error(exp.getMessage());
        if(packet.supports(MessageContext.SERVLET_RESPONSE)){
          ((HttpServletResponse)packet.get(MessageContext.SERVLET_RESPONSE)).setStatus(400);
        }
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

    Encoder e = new JsonEncoder(s, bao);
    w.write(r, e);
    e.flush();
   
    Object o = new GenericDatumReader<GenericRecord>(s).read(null,
        new JsonDecoder(s, new ByteArrayInputStream(bao.toByteArray())));
    assertEquals(r, o);
  }
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

    writer.write(datum, encoder);
    encoder.flush();
    byte[] data = out.toByteArray();

    reader.setSchema(schema);
    Decoder decoder = new JsonDecoder(schema, new ByteArrayInputStream(data));
    Object decoded = reader.read(null, decoder);
    assertEquals("Decoded data does not match.", datum, decoded);

    decoded = reader.read(decoded, decoder);
    assertEquals("Decoded data does not match.", datum, decoded);
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

    assertEquals("Encoded data does not match.", json, encoded);

    DatumReader<Object> reader = new GenericDatumReader<Object>();
    reader.setSchema(schema);
    Object decoded =
      reader.read(null, new JsonDecoder(schema,new ByteArrayInputStream(data)));
     
    assertEquals("Decoded data does not match.", datum, decoded);
  }
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

                if(keyFormat.equals("readable")) {
                    Object keyObject;
                    String keySerializerName = keySerializerDef.getName();
                    if(isAvroSchema(keySerializerName)) {
                        Schema keySchema = Schema.parse(keySerializerDef.getCurrentSchemaInfo());
                        JsonDecoder decoder = new JsonDecoder(keySchema, keyString);
                        GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(keySchema);
                        keyObject = datumReader.read(null, decoder);
                    } else if(keySerializerName.equals(DefaultSerializerFactory.JSON_SERIALIZER_TYPE_NAME)) {
                        JsonReader jsonReader = new JsonReader(new StringReader(keyString));
                        keyObject = jsonReader.read();
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

                // before we do the actual parsing with the schema
                String avroString = (String) obj;
                // From here on, this is just normal avro parsing.
                Schema latestSchema = Schema.parse(serializerDef.getCurrentSchemaInfo());
                try {
                    JsonDecoder decoder = new JsonDecoder(latestSchema, avroString);
                    GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(latestSchema);
                    obj = datumReader.read(null, decoder);
                } catch(IOException io) {
                    errorStream.println("Error parsing avro string " + avroString);
                    io.printStackTrace();
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

                if(line.toLowerCase().startsWith("get")) {

                    System.out.println("Enter key:");
                    line = reader.readLine();

                    JsonDecoder decoder = new JsonDecoder(keySchema, line);
                    GenericDatumReader<Object> datumReader = null;
                    Object key = null;
                    try {
                        datumReader = new GenericDatumReader<Object>(keySchema);
                        key = datumReader.read(null, decoder);
                    } catch(IOException e) {}
                    if(key == null) {
                        System.err.println("Error parsing key ");
                        continue;
                    }

                    System.out.println("Value - " + client.get(key));
                } else if(line.toLowerCase().startsWith("put")) {

                    String keyString = null;
                    String valueString = null;

                    System.out.println("Enter key:");
                    line = reader.readLine();
                    keyString = line;

                    System.out.println("Enter value:");
                    line = reader.readLine();
                    valueString = line;

                    JsonDecoder keyDecoder = new JsonDecoder(keySchema, keyString);
                    JsonDecoder valueDecoder = new JsonDecoder(valueSchema, valueString);

                    GenericDatumReader<Object> datumReader = null;
                    Object key = null;
                    Object value = null;
                    try {
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

  protected Decoder createDecoder() throws IOException {
    switch(codecType) {
      case BINARY:
        return new BinaryDecoder(getOrCreateInputStream());
      case JSON:
        return new JsonDecoder(schema, getOrCreateInputStream());
    }
    return null;
  }
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

     */
    @SuppressWarnings("unchecked")
    public static Properties readSingleClientConfigAvro(String configAvro) {
        Properties props = new Properties();
        try {
            JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIG_AVRO_SCHEMA, configAvro);
            GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIG_AVRO_SCHEMA);
            Map<Utf8, Utf8> flowMap = (Map<Utf8, Utf8>) datumReader.read(null, decoder);
            for(Utf8 key: flowMap.keySet()) {
                props.put(key.toString(), flowMap.get(key).toString());
            }
View Full Code Here

Examples of org.apache.avro.io.JsonDecoder

     */
    @SuppressWarnings("unchecked")
    public static Map<String, Properties> readMultipleClientConfigAvro(String configAvro) {
        Map<String, Properties> mapStoreToProps = Maps.newHashMap();
        try {
            JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIGS_AVRO_SCHEMA, configAvro);
            GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIGS_AVRO_SCHEMA);

            Map<Utf8, Map<Utf8, Utf8>> storeConfigs = (Map<Utf8, Map<Utf8, Utf8>>) datumReader.read(null,
                                                                                                    decoder);
            // Store config props to return back
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.