this is my random code, i put the tags like [5an] x 10 but the code generate one random for the 10 tags. Example : my input :
[5an]-[5an]-[5an] [5an]-[5an]-[5an] the output : [xM24A]-[xM24A]-[xM24A] [xM24A]-[xM24A]-[xM24A]
please help me with this code
public static boolean a(final String s) { return Pattern.compile("^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)(\.[A-Za-z]{2,})$").matcher(s).matches(); }
public static Object a(final HashMap hashMap, final String s, final Object o) {
if (hashMap == null || hashMap.isEmpty() || !hashMap.containsKey(s)) {
return o;
}
if (hashMap.get(s) != null && hashMap.get(s).getClass() != null && hashMap.get(s).getClass().isAssignableFrom(o.getClass())) {
return hashMap.get(s);
}
return o;
}
public static List b(final String s) {
final ArrayList<String> list = new ArrayList<String>();
final Matcher matcher = Pattern.compile("\\[(.*?)\\]").matcher(s);
while (matcher.find()) {
final String group;
final String replaceAll = (group = matcher.group(1)).replaceAll("[0-9]", "");
if ("a".equalsIgnoreCase(replaceAll) || "an".equalsIgnoreCase(replaceAll) || "al".equalsIgnoreCase(replaceAll) || "au".equalsIgnoreCase(replaceAll) || "anl".equalsIgnoreCase(replaceAll) || "anu".equalsIgnoreCase(replaceAll) || "n".equalsIgnoreCase(replaceAll)) {
list.add(group);
}
}
return list;
}
public static String a(final String s, final g g, final c c, final List list, final String s2, final String s3, final String s4, final String s5, final String s6, final String s7) {
String a = "";
if (s != null && !"".equals(s) && g != null) {
String s8 = StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(s, "[ip]", g.d()), "[rdns]", g.e()), "[domain]", s5), "[mail_date]", s3), "[message_id]", s4), "[auto_reply_email]", s6), "[rcpt]", s7);
if (!"".equals(s2)) {
s8 = StringUtils.replace(s8, "[return_path]", s2);
}
if (c != null) {
s8 = StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(s8, "[email_id]", String.valueOf(c.a())), "[email]", c.b()), "[email_fname]", c.d()), "[email_lname]", c.e());
}
a = a(s8, list);
}
return a;
}
public static String a(String replace, final List list) {
if (replace != null && !"".equals(replace) && list != null && !list.isEmpty()) {
for (int i = 0; i < list.size(); ++i) {
if (replace.contains(list.get(i))) {
replace = StringUtils.replace(replace, "[" + list.get(i) + "]", d(list.get(i)));
}
}
}
return replace;
}
public static String c(final String s) {
try {
final String[] split;
if ((split = s.split("\\.")).length > 2) {
String string = "";
if (split.length > 3) {
string = split[split.length - 3] + ".";
}
return string + split[split.length - 2] + "." + split[split.length - 1];
}
}
catch (Exception ex) {
return s;
}
return s;
}
public static String d(String replaceAll) {
final int a = a((Object)replaceAll.replaceAll("[^0-9]", ""));
replaceAll = (replaceAll = replaceAll.replaceAll("[0-9]", ""));
switch (replaceAll) {
case "a": {
return a(a, true, true, false, false);
}
case "al": {
return a(a, true, true, false, false).toLowerCase();
}
case "au": {
return a(a, true, true, false, false).toUpperCase();
}
case "an": {
return a(a, true, true, true, false);
}
case "anl": {
return a(a, true, true, true, false).toLowerCase();
}
case "anu": {
return a(a, true, true, true, false).toUpperCase();
}
case "n": {
return a(a, false, false, true, false);
}
default: {
return "";
}
}
}
public static String a(final int n, final boolean b, final boolean b2, final boolean b3, final boolean b4) {
String s = "";
if (b) {
s += "abcdefghijklmnopqrstuvwxyz";
if (b2) {
s += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
}
if (b3) {
s += "1234567890";
}
final StringBuilder sb = new StringBuilder();
final Random random = new Random();
while (sb.length() < n) {
sb.append(s.charAt((int)(random.nextFloat() * s.length())));
}
return sb.toString();
}
public static String e(final String s) {
final Random random = new Random();
final StringBuilder sb = new StringBuilder(s.length());
char[] charArray;
for (int length = (charArray = s.toCharArray()).length, i = 0; i < length; ++i) {
final char c = charArray[i];
sb.append(random.nextBoolean() ? Character.toLowerCase(c) : Character.toUpperCase(c));
}
return sb.toString();
}
Aucun commentaire:
Enregistrer un commentaire