package mobvista.dmp.datasource.age.mapreduce; import java.util.regex.Pattern; /** * Created by Administrator on 2017/2/23 0023. */ public class Util { static Pattern wellSplit = Pattern.compile("#"); static Pattern lineSplit = Pattern.compile("-"); static Pattern colonSplit = Pattern.compile(":"); static Pattern verticalLine = Pattern.compile("\\|"); static Pattern dollarSplit = Pattern.compile("\\$"); static Pattern match = Pattern.compile("^0*-0*-0*-0*-0*$"); //TODO public static int calcLabel(int age) { int label = 0; if (age <= 17) { label = 1; } else if (age >= 18 && age <= 24) { label = 2; } else if (age >= 25 && age <= 44) { label = 3; } else if (age >= 45 && age <= 59) { label = 4; } else if (age >= 60) { label = 5; } return label; } public static String getAge(int age) { String generation = ""; if (age == 1) { generation = "0-17"; } else if (age == 2) { generation = "18-24"; } else if (age == 3) { generation = "25-44"; } else if (age == 4) { generation = "45-59"; } else if (age == 5) { generation = "60+"; } return generation; } }