public String deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { JsonToken localJsonToken = paramJsonParser.getCurrentToken(); if (localJsonToken == JsonToken.VALUE_STRING) return paramJsonParser.getText(); if (localJsonToken == JsonToken.VALUE_EMBEDDED_OBJECT) { Object localObject = paramJsonParser.getEmbeddedObject(); if (localObject == null) return null; if ((localObject instanceof byte[])) return Base64Variants.getDefaultVariant().encode((byte[])(byte[])localObject, false); return localObject.toString(); } if (localJsonToken.isScalarValue()) return paramJsonParser.getText(); throw paramDeserializationContext.mappingException(this._valueClass); }
public String deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { JsonToken localJsonToken = paramJsonParser.getCurrentToken(); if (localJsonToken == JsonToken.VALUE_STRING) return paramJsonParser.getText(); if (localJsonToken == JsonToken.VALUE_EMBEDDED_OBJECT) { Object localObject = paramJsonParser.getEmbeddedObject(); if (localObject == null) return null; if ((localObject instanceof byte[])) return Base64Variants.getDefaultVariant().encode((byte[])localObject, false); return localObject.toString(); } if (localJsonToken.isScalarValue()) return paramJsonParser.getText(); throw paramDeserializationContext.mappingException(this._valueClass, localJsonToken); }
@Test public void testByteArray() { String encode = Base64Variants.getDefaultVariant().encode("byte array".getBytes()); checkByteArray(typeFromJson("\"" + encode + "\""), encode); }
public char[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { JsonToken localJsonToken1 = paramJsonParser.getCurrentToken(); if (localJsonToken1 == JsonToken.VALUE_STRING) { char[] arrayOfChar1 = paramJsonParser.getTextCharacters(); int i = paramJsonParser.getTextOffset(); int j = paramJsonParser.getTextLength(); char[] arrayOfChar2 = new char[j]; System.arraycopy(arrayOfChar1, i, arrayOfChar2, 0, j); return arrayOfChar2; } if (paramJsonParser.isExpectedStartArrayToken()) { StringBuilder localStringBuilder = new StringBuilder(64); while (true) { JsonToken localJsonToken2 = paramJsonParser.nextToken(); if (localJsonToken2 == JsonToken.END_ARRAY) break; if (localJsonToken2 != JsonToken.VALUE_STRING) throw paramDeserializationContext.mappingException(Character.TYPE); String str = paramJsonParser.getText(); if (str.length() != 1) throw JsonMappingException.from(paramJsonParser, "Can not convert a JSON String of length " + str.length() + " into a char element of char array"); localStringBuilder.append(str.charAt(0)); } return localStringBuilder.toString().toCharArray(); } if (localJsonToken1 == JsonToken.VALUE_EMBEDDED_OBJECT) { Object localObject = paramJsonParser.getEmbeddedObject(); if (localObject == null) return null; if ((localObject instanceof char[])) return (char[])(char[])localObject; if ((localObject instanceof String)) return ((String)localObject).toCharArray(); if ((localObject instanceof byte[])) return Base64Variants.getDefaultVariant().encode((byte[])(byte[])localObject, false).toCharArray(); } throw paramDeserializationContext.mappingException(this._valueClass); }
public Base64Variant getBase64Variant() { return Base64Variants.getDefaultVariant(); }
public String getValueAsText() { return Base64Variants.getDefaultVariant().encode(this._data, false); }
public String toString() { return Base64Variants.getDefaultVariant().encode(this._data, true); }
public byte[] getBinaryValue() throws IOException { return getBinaryValue(Base64Variants.getDefaultVariant()); }
@Test public void testBinary() { String encode = Base64Variants.getDefaultVariant().encode("binary blob".getBytes()); checkBinary(readFromJson("\"" + encode + "\"", FieldType.BINARY), encode.getBytes()); }
public final char[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { JsonToken localJsonToken1 = paramJsonParser.getCurrentToken(); if (localJsonToken1 == JsonToken.VALUE_STRING) { char[] arrayOfChar1 = paramJsonParser.getTextCharacters(); int i = paramJsonParser.getTextOffset(); int j = paramJsonParser.getTextLength(); char[] arrayOfChar2 = new char[j]; System.arraycopy(arrayOfChar1, i, arrayOfChar2, 0, j); return arrayOfChar2; } if (paramJsonParser.isExpectedStartArrayToken()) { StringBuilder localStringBuilder = new StringBuilder(64); while (true) { JsonToken localJsonToken2 = paramJsonParser.nextToken(); if (localJsonToken2 == JsonToken.END_ARRAY) break; if (localJsonToken2 != JsonToken.VALUE_STRING) throw paramDeserializationContext.mappingException(Character.TYPE); String str = paramJsonParser.getText(); if (str.length() != 1) throw JsonMappingException.from(paramJsonParser, "Can not convert a JSON String of length " + str.length() + " into a char element of char array"); localStringBuilder.append(str.charAt(0)); } return localStringBuilder.toString().toCharArray(); } if (localJsonToken1 == JsonToken.VALUE_EMBEDDED_OBJECT) { Object localObject = paramJsonParser.getEmbeddedObject(); if (localObject == null) return null; if ((localObject instanceof char[])) return (char[])localObject; if ((localObject instanceof String)) return ((String)localObject).toCharArray(); if ((localObject instanceof byte[])) return Base64Variants.getDefaultVariant().encode((byte[])localObject, false).toCharArray(); } throw paramDeserializationContext.mappingException(this._valueClass); }
/** * Method called during deserialization if Base64 encoded content * needs to be decoded. Default version just returns default Jackson * uses, which is modified-mime which does not add linefeeds (because * those would have to be escaped in Json strings). */ public Base64Variant getBase64Variant() { return Base64Variants.getDefaultVariant(); }