public static Byte[] decodeAsBoxed(final String data) { final byte[] primitiveArray = decode(data); final Byte[] boxedData = new Byte[primitiveArray.length]; for (int i = 0; i < primitiveArray.length; i++) { boxedData[i] = primitiveArray[i]; } return boxedData; }
/** * Same as {@link #encode(byte[], int, int)} but accepts an array of boxed * Byte values. * * @param data * The sequence of bytes to encode. Every element must be non-null. * @param off * The offset into the data array to start encoding from * @param length * The number of bytes to encode, starting from {@code off} * * @return The base64 encoded data. */ public static String encode(final Byte[] data, final int off, final int length) { final byte[] primitiveData = new byte[data.length]; for (int i = 0; i < length; i++) { primitiveData[i] = data[off + i]; } return encode(primitiveData, 0, primitiveData.length); }
private static int nextI(final String data, int i, final int finish) { while ((i < finish) && ignore(data.charAt(i))) { i++; } return i; } }
value = (Y) Base64Util.decode(jsonValue.isString().stringValue()); value = (Y) Base64Util.decodeAsBoxed(jsonValue.isString().stringValue());
if (!ignore(data.charAt(end - 1))) { break; final int bytesInLastBlock = decodeLastBlock( lastBlock, 0, data.charAt(end - 4), data.charAt(end - 3), out[outpos++] = (byte) ((decodingTable[data.charAt(i = nextI(data, i, finish))] << 2) | ((b2 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 4)); out[outpos++] = (byte) ((b2 << 4) | ((b3 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 2)); out[outpos++] = (byte) ((b3 << 6) | decodingTable[data.charAt(i = nextI(data, ++i, finish))]); i = nextI(data, i, finish); i++;
if (!ignore(data.charAt(end - 1))) { break; final int bytesInLastBlock = decodeLastBlock( lastBlock, 0, data.charAt(end - 4), data.charAt(end - 3), out[outpos++] = (byte) ((decodingTable[data.charAt(i = nextI(data, i, finish))] << 2) | ((b2 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 4)); out[outpos++] = (byte) ((b2 << 4) | ((b3 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 2)); out[outpos++] = (byte) ((b3 << 6) | decodingTable[data.charAt(i = nextI(data, ++i, finish))]); i = nextI(data, i, finish); i++;
public static Byte[] decodeAsBoxed(final String data) { final byte[] primitiveArray = decode(data); final Byte[] boxedData = new Byte[primitiveArray.length]; for (int i = 0; i < primitiveArray.length; i++) { boxedData[i] = primitiveArray[i]; } return boxedData; }
/** * Same as {@link #encode(byte[], int, int)} but accepts an array of boxed * Byte values. * * @param data * The sequence of bytes to encode. Every element must be non-null. * @param off * The offset into the data array to start encoding from * @param length * The number of bytes to encode, starting from {@code off} * * @return The base64 encoded data. */ public static String encode(final Byte[] data, final int off, final int length) { final byte[] primitiveData = new byte[data.length]; for (int i = 0; i < length; i++) { primitiveData[i] = data[off + i]; } return encode(primitiveData, 0, primitiveData.length); }
private static int nextI(final String data, int i, final int finish) { while ((i < finish) && ignore(data.charAt(i))) { i++; } return i; } }
private static String getSVGContent(final String dataUriEncodedContent, final SVGGeneratorOptions options) { final SVGContentType type = getType(dataUriEncodedContent); String s = dataUriEncodedContent.substring(type.getLength()); if (SVGContentType.XML_BASE64.equals(type)) { s = new String(Base64Util.decode(s)); } if (options.removeXmlTag) { s = removeXmlTag(s); } if (options.removeUseTags) { s = removeAllUseTags(s); } else { s = removeUseTagsById(s, options.isRemoveUseForView); } if (options.removeHrefFileNames) { s = removeAllHrefFileName(s); } return s; }
/** * Encodes the specified data-uri string in XML/Base64 format. */ public static String encodeBase64(final String dataUriDecoded) { return SVG_DATA_URI_BASE64 + Base64Util.encode(dataUriDecoded.getBytes(), 0, dataUriDecoded.length()); }
@Override public T doNotNullDemarshall(final EJValue o, final MarshallingSession ctx) { final EJObject obj = o.isObject(); if (obj != null) { final String objId = obj.get(SerializationParts.OBJECT_ID).isString().stringValue(); if (ctx.hasObject(objId)) { // noinspection unchecked return (T) ctx.getObject(Object.class, objId); } EJValue val = obj.get(SerializationParts.QUALIFIED_VALUE); if (val.isNull()) { val = o; } return ctx.recordObject(objId, delegate.demarshall(val, ctx)); } else { // This is to support one-dimensional Jackson char and byte array representations which cannot be wrapped in // an JSON object by the transfomer because they are indistinguishable from plain Strings. Class<?> componentType = type.getComponentType(); if (o.isString() != null && componentType != null) { if (componentType.equals(byte.class)) { return (T) Base64Util.decode(o.isString().stringValue()); } else if (componentType.equals(char.class)) { return (T) o.isString().stringValue().toCharArray(); } } } return null; }
@Override public T doNotNullDemarshall(final EJValue o, final MarshallingSession ctx) { final EJObject obj = o.isObject(); if (obj != null) { final String objId = obj.get(SerializationParts.OBJECT_ID).isString().stringValue(); if (ctx.hasObject(objId)) { // noinspection unchecked return (T) ctx.getObject(Object.class, objId); } EJValue val = obj.get(SerializationParts.QUALIFIED_VALUE); if (val.isNull()) { val = o; } return ctx.recordObject(objId, delegate.demarshall(val, ctx)); } else { // This is to support one-dimensional Jackson char and byte array representations which cannot be wrapped in // an JSON object by the transfomer because they are indistinguishable from plain Strings. Class<?> componentType = type.getComponentType(); if (o.isString() != null && componentType != null) { if (componentType.equals(byte.class)) { return (T) Base64Util.decode(o.isString().stringValue()); } else if (componentType.equals(char.class)) { return (T) o.isString().stringValue().toCharArray(); } } } return null; }