public static boolean isBase64( String isValidString ){ return isArrayByteBase64( isValidString.getBytes(Charset.forName("UTF-8"))); }
public static boolean isArrayByteBase64( byte[] arrayOctect ) { int length = arrayOctect.length; if ( length == 0 ) { return false; } for ( int i=0; i < length; i++ ) { if ( Base64.isBase64( arrayOctect[i] ) == false) { return false; } } return true; }
public String locate(String name, StatementContext ctx) throws Exception { if (group.isDefined(name)) { // yeah, found template for it! StringTemplate t = group.getInstanceOf(name); t.reset(); for (Map.Entry<String, Object> entry : ctx.getAttributes().entrySet()) { t.setAttribute(entry.getKey(), entry.getValue()); } return t.toString(); } else if (treatLiteralsAsTemplates) { // no template in the template group, but we want literals to be templates final String key = new String(new Base64().encode(name.getBytes(UTF_8)), UTF_8); if (!literals.isDefined(key)) { literals.defineTemplate(key, name); } StringTemplate t = literals.lookupTemplate(key); for (Map.Entry<String, Object> entry : ctx.getAttributes().entrySet()) { t.setAttribute(entry.getKey(), entry.getValue()); } return t.toString(); } else { // no template, no literals as template, just use the literal as sql return name; } }
@Override public String locate(String name, StatementContext ctx) throws Exception { if (group.isDefined(name)) { // yeah, found template for it! StringTemplate t = group.getInstanceOf(name); t.reset(); for (Map.Entry<String, Object> entry : ctx.getAttributes().entrySet()) { t.setAttribute(entry.getKey(), entry.getValue()); } return t.toString(); } else if (treatLiteralsAsTemplates) { // no template in the template group, but we want literals to be templates final String key = new String(new Base64().encode(name.getBytes(UTF_8)), UTF_8); if (!literals.isDefined(key)) { literals.defineTemplate(key, name); } StringTemplate t = literals.lookupTemplate(key); for (Map.Entry<String, Object> entry : ctx.getAttributes().entrySet()) { t.setAttribute(entry.getKey(), entry.getValue()); } return t.toString(); } else { // no template, no literals as template, just use the literal as sql return name; } }
public static boolean isArrayByteBase64( byte[] arrayOctect ) { int length = arrayOctect.length; if ( length == 0 ) { return false; } for ( int i=0; i < length; i++ ) { if ( Base64.isBase64( arrayOctect[i] ) == false) { return false; } } return true; }
public static boolean isBase64( String isValidString ){ return isArrayByteBase64( isValidString.getBytes(Charset.forName("UTF-8"))); }