@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } return Base64.decode(value); }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } return Base64.decode(value); }
/** * Decodes data from Base64 notation, automatically detecting gzip-compressed * data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { return decode(s, NO_OPTIONS); }
/** * Decodes data from Base64 notation, automatically detecting gzip-compressed * data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { return decode(s, NO_OPTIONS); }
/** * Decodes data from Base64 notation, automatically detecting gzip-compressed * data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { return decode(s, NO_OPTIONS); }
public static byte[] getIndexMaintainers(final Configuration configuration){ Preconditions.checkNotNull(configuration); return Base64.decode(configuration.get(INDEX_MAINTAINERS)); }
@VisibleForTesting static Character getCharacter(Configuration conf, String confKey) { String strValue = conf.get(confKey); if (strValue == null) { return null; } return new String(Base64.decode(strValue)).charAt(0); }
private static byte[] getKeyFromConf(Configuration conf, String base64Key, String deprecatedKey) { String encoded = conf.get(base64Key); if (encoded != null) { return Base64.decode(encoded); } String oldStyleVal = conf.get(deprecatedKey); if (oldStyleVal == null) { return null; } LOG.warn("Using deprecated configuration " + deprecatedKey + " - please use static accessor methods instead."); return Bytes.toBytes(oldStyleVal); }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } Object object = Base64.decode(value); if (object == null) { throw newIllegalDataException( "Input: [" + value + "] is not base64 encoded"); } return object; }
private static byte[] getKeyFromConf(Configuration conf, String base64Key, String deprecatedKey) { String encoded = conf.get(base64Key); if (encoded != null) { return Base64.decode(encoded); } String oldStyleVal = conf.get(deprecatedKey); if (oldStyleVal == null) { return null; } LOG.warn("Using deprecated configuration " + deprecatedKey + " - please use static accessor methods instead."); return Bytes.toBytesBinary(oldStyleVal); }
/** * Converts the given Base64 string back into a Scan instance. * * @param base64 The scan details. * @return The newly created Scan instance. * @throws IOException When reading the scan instance fails. */ static Scan convertStringToScan(String base64) throws IOException { ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(base64)); DataInputStream dis = new DataInputStream(bis); Scan scan = new Scan(); scan.readFields(dis); return scan; }
private static byte[] getKeyFromConf(Configuration conf, String base64Key, String deprecatedKey) { String encoded = conf.get(base64Key); if (encoded != null) { return Base64.decode(encoded); } String oldStyleVal = conf.get(deprecatedKey); if (oldStyleVal == null) { return null; } LOG.warn("Using deprecated configuration " + deprecatedKey + " - please use static accessor methods instead."); return Bytes.toBytes(oldStyleVal); }
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } skipBadLines = context.getConfiguration().getBoolean(ImportTsv.SKIP_LINES_CONF_KEY, true); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); }
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } skipBadLines = context.getConfiguration().getBoolean(ImportTsv.SKIP_LINES_CONF_KEY, true); logBadLines = context.getConfiguration().getBoolean(ImportTsv.LOG_BAD_LINES_CONF_KEY, false); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); }
/** * Converts the given Base64 string back into a Scan instance. * * @param base64 The scan details. * @return The newly created Scan instance. * @throws IOException When reading the scan instance fails. */ public static Scan convertStringToScan(String base64) throws IOException { byte [] decoded = Base64.decode(base64); return ProtobufUtil.toScan(ClientProtos.Scan.parseFrom(decoded)); }
/** * Converts the given Base64 string back into a UpdateProcessor instance. * * @param upClassName The updateProcessor class name. * @param base64 The updateProcessor details. * @return The newly created updateProcessor instance. * @throws java.io.IOException When reading the updateProcessor instance fails. */ static UpdateProcessor convertStringToUpdateProcessor(String upClassName, String base64) throws IOException { UpdateProcessor up = createInstance(upClassName, UpdateProcessor.class); if (base64 != null) { ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(base64)); DataInputStream dis = new DataInputStream(bis); up.readFields(dis); } return up; }
public static Scan convertStringToScan(String string) throws IOException { ClientProtos.Scan proto = ClientProtos.Scan.parseFrom(Base64.decode(string)); return ProtobufUtil.toScan(proto); }
protected T fromPB(String pb) throws Exception { return (T)clazz.getMethod("getObjectFromMessage", byte[].class).invoke( clazz.getDeclaredConstructor().newInstance(), Base64.decode(AS_PB)); }
/** * Converts the given Base64 string back into a Scan instance. * * @param base64 The scan details. * @return The newly created Scan instance. * @throws IOException When reading the scan instance fails. */ static Scan convertStringToScan(String base64) throws IOException { byte [] decoded = Base64.decode(base64); ClientProtos.Scan scan; try { scan = ClientProtos.Scan.parseFrom(decoded); } catch (InvalidProtocolBufferException ipbe) { throw new IOException(ipbe); } return ProtobufUtil.toScan(scan); }
/** * Converts base64 scans string back into a Scan array * @param base64 * @return * @throws IOException */ public static Scan[] convertStringToScanArray(final String base64) throws IOException { final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(Base64.decode(base64))); ArrayWritable aw = new ArrayWritable(Scan.class); aw.readFields(dis); Writable[] writables = aw.get(); Scan[] scans = new Scan[writables.length]; for (int i=0; i < writables.length; i++) { scans[i] = (Scan)writables[i]; } return scans; }