Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package libepg.epg.section.descriptor.contentdescriptor; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.ANIME; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.CINEMA; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.DOCUMENTARY; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.DRAMA; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.HOBBY; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.INFORMATION; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.MUSIC; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.NEWS; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.STAGE; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.USER_NIBBLE; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.VARIETY; import static libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_1.WELFARE; import org.apache.commons.collections4.keyvalue.MultiKey; /** * ? () */ public enum NIBBLE_LEVEL_2 { /** * ?? */ REGULAR_GENERAL(NEWS, 0x0, "??", "Regular/General"), /** * */ WEATHER(NEWS, 0x1, "", "Weather"), /** * */ SPECIAL_TOPIC_DOCUMENTARY(NEWS, 0x2, "", "Special topic/documentary"), /** * */ POLITICS_DIET(NEWS, 0x3, "", "Politics/diet"), /** * ? */ ECONOMY_MARKET(NEWS, 0x4, "?", "Economy/market"), /** * */ OVERSEAS(NEWS, 0x5, "", "Overseas"), /** * */ COMMENTARY(NEWS, 0x6, "", "Commentary"), /** * */ DISCUSSION_MEETING(NEWS, 0x7, "", "Discussion/meeting"), /** * ? */ SPECIAL_NEWS_REPORT(NEWS, 0x8, "?", "Special news report"), /** * */ LOCAL(NEWS, 0x9, "", "Local"), /** * */ TRAFFIC(NEWS, 0xa, "", "Traffic"), /** * ??? */ OTHERS_NEWS(NEWS, 0xf, "???", "Others"), /** * ? */ SPORTS_NEWS(NIBBLE_LEVEL_1.SPORTS, 0x0, "?", "Sports news"), /** * ? */ BASEBALL(NIBBLE_LEVEL_1.SPORTS, 0x1, "?", "Baseball"), /** * */ SOCCER(NIBBLE_LEVEL_1.SPORTS, 0x2, "", "soccer"), /** * */ GOLF(NIBBLE_LEVEL_1.SPORTS, 0x3, "", "Golf"), /** * ????? */ OTHER_BALL_GAMES(NIBBLE_LEVEL_1.SPORTS, 0x4, "?????", "Other ball games"), /** * */ SUMO_FIGHTING_SPORTS(NIBBLE_LEVEL_1.SPORTS, 0x5, "", "Sumo/fighting sports"), /** * */ OLYMPIC_INTERNATIONAL_GAMES(NIBBLE_LEVEL_1.SPORTS, 0x6, "", "Olympic/international games"), /** * */ MARATHON_FIELD_AND_TRACK_SWIMMING(NIBBLE_LEVEL_1.SPORTS, 0x7, "", "Marathon/field and track/swimming"), /** * ? */ MOTOR_SPORTS(NIBBLE_LEVEL_1.SPORTS, 0x8, "?", "Motor sports"), /** * ? */ MARINE_WINTER_SPORTS(NIBBLE_LEVEL_1.SPORTS, 0x9, "?", "Marine/winter sports"), /** * */ HORSE_RACE_PUBLIC_SPORTS(NIBBLE_LEVEL_1.SPORTS, 0xa, "", "Horse race/public sports"), /** * ??? */ OTHERS_SPORTS(NIBBLE_LEVEL_1.SPORTS, 0xf, "???", "Others"), /** * */ SHOW_BUSINESS_TABLOID_SHOW(INFORMATION, 0x0, "", "Show business/tabloid show"), /** * */ FASHION(INFORMATION, 0x1, "", "Fashion"), /** * ???? */ LIFE_RESIDENCE(INFORMATION, 0x2, "????", "Life/residence"), /** * ? */ HEALTH_MEDICAL_CARE(INFORMATION, 0x3, "?", "Health/medical care"), /** * */ SHOPPING_CATALOG_SHOPPING(INFORMATION, 0x4, "", "Shopping/catalog shopping"), /** * ? */ GOURMET_COOKING_SHOW(INFORMATION, 0x5, "?", "Gourmet/cooking show"), /** * */ EVENTS(INFORMATION, 0x6, "", "Events"), /** * ?? */ PROMOTION_INFORMATION(INFORMATION, 0x7, "??", "Promotion/information"), /** * ??? */ OTHERS_INFORMATION(INFORMATION, 0xf, "???", "Others"), /** * */ JAPANESE_DRAMA(DRAMA, 0x0, "", "Japanese drama"), /** * */ OVERSEAS_DRAMA(DRAMA, 0x1, "", "Overseas drama"), /** * */ HISTORICAL_DRAMA(DRAMA, 0x2, "", "Historical drama"), /** * ??? */ OTHERS_DRAMA(DRAMA, 0xf, "???", "Others"), /** * ? */ JAPANESE_ROCK_POPS(MUSIC, 0x0, "?", "Japanese rock/pops"), /** * ? */ OVERSEAS_ROCK_POPS(MUSIC, 0x1, "?", "Overseas rock/pops"), /** * */ CLASSICAL_OPERA(MUSIC, 0x2, "", "Classical/opera"), /** * */ JAZZ_FUSION(MUSIC, 0x3, "", "Jazz/fusion"), /** * */ JAPANESE_POPULAR_SONG_ENKA(MUSIC, 0x4, "", "Japanese popular song/ballad /***/(Enka)"), /** * */ LIVE_SHOW_CONCERT(MUSIC, 0x5, "", "Live show/concert"), /** * */ RANKING_REQUEST_SHOW(MUSIC, 0x6, "", "Ranking/Request show"), /** * ?? */ KARAOKE_SINGING_CONTEST(MUSIC, 0x7, "??", "Karaoke/singing contest"), /** * */ FOLK_JAPANESE_MUSIC(MUSIC, 0x8, "", "Folk/Japanese music"), /** * */ CHILDREN_S_SONG(MUSIC, 0x9, "", "Children's song"), /** * ? */ ETHNIC_WORLD_MUSIC(MUSIC, 0xa, "?", "Ethnic/world music"), /** * ??? */ OTHERS_MUSIC(MUSIC, 0xf, "???", "Other"), /** * */ QUIZ(VARIETY, 0x0, "", "Quiz"), /** * */ GAME(VARIETY, 0x1, "", "Game"), /** * ? */ TALK_SHOW(VARIETY, 0x2, "?", "Talk show"), /** * ?? */ COMEDY(VARIETY, 0x3, "??", "Comedy"), /** * ? */ MUSICAL_VARIETY_SHOW(VARIETY, 0x4, "?", "Musical variety show"), /** * ? */ TRAVEL_VARIETY_SHOW(VARIETY, 0x5, "?", "Travel variety show"), /** * ?? */ COOKING_VARIETY_SHOW(VARIETY, 0x6, "??", "Cooking variety show"), /** * ??? */ OTHERS_VARIETY(VARIETY, 0xf, "???", "Other"), /** * */ OVERSEAS_MOVIE(CINEMA, 0x0, "", "Overseas movie"), /** * */ JAPANESE_MOVIE(CINEMA, 0x1, "", "Japanese movie"), /** * */ ANIMATION_MOVIE(CINEMA, 0x2, "", "Animation movie"), /** * ??? */ OTHERS_CINEMA(CINEMA, 0xf, "???", "Other"), /** * */ JAPANESE_ANIMATION(ANIME, 0x0, "", "Japanese animation"), /** * */ OVERSEAS_ANIMATION(ANIME, 0x1, "", "Overseas animation"), /** * */ SPECIAL_EFFECTS_PROGRAM(ANIME, 0x2, "", "Special effects program"), /** * ??? */ OTHERS_ANIME(ANIME, 0xf, "???", "Other"), /** * */ SOCIAL_TOPICAL_NEWS(DOCUMENTARY, 0x0, "", "Social/topical news"), /** * ? */ HISTORY_TRAVEL(DOCUMENTARY, 0x1, "?", "History/travel"), /** * */ NATURE_ANIMAL_ENVIRONMENT(DOCUMENTARY, 0x2, "", "Nature/animal/environment"), /** * */ UNIVERSE_SCIENCE_SCIENCE_OF_MEDICINE(DOCUMENTARY, 0x3, "", "Universe/science/science of medicine"), /** * ?? */ CULTURE_TRADITIONAL_CULTURE(DOCUMENTARY, 0x4, "??", "Culture/traditional culture"), /** * */ LITERATURE_LIBERAL_ARTS(DOCUMENTARY, 0x5, "", "Literature/liberal arts"), /** * ? */ SPORTS(DOCUMENTARY, 0x6, "?", "Sports"), /** * */ GENERAL_DOCUMENTARY(DOCUMENTARY, 0x7, "", "General documentary"), /** * */ INTERVIEW_DISCUSSION(DOCUMENTARY, 0x8, "", "Interview/discussion"), /** * ??? */ OTHERS_DOCUMENTARY(DOCUMENTARY, 0xf, "???", "Other"), /** * ? */ MODERN_PLAY(STAGE, 0x0, "?", "Modern play"), /** * */ MUSICAL(STAGE, 0x1, "", "Musical"), /** * ? */ DANCE_BALLET(STAGE, 0x2, "?", "Dance/ballet"), /** * ? */ RAKUGO_ENTERTAINMENT(STAGE, 0x3, "?", "Comic monologue /***/(Rakugo)/ entertainment"), /** * ? */ KABUKI_CLASSICAL_PLAY(STAGE, 0x4, "?", "Kabuki/classical play"), /** * ??? */ OTHERS_STAGE(STAGE, 0xf, "???", "Other"), /** * */ TRAVEL_FISHING_OUTDOORS(HOBBY, 0x0, "", "Travel/fishing/outdoors"), /** * */ GARDENING_PET_HANDICRAFT(HOBBY, 0x1, "", "Gardening/pet/ handicraft"), /** * */ MUSIC_ART_ARTIFICE(HOBBY, 0x2, "", "Music/art/ artifice"), /** * ? */ JAPANESE_GO_SHOGI(HOBBY, 0x3, "?", "Japanese go/chess /***/(Shogi)"), /** * ? */ MAHJONG_PACHINKO(HOBBY, 0x4, "?", "Mah-jong/Pachinko"), /** * ? */ AUTOMOBILE_MOTORCYCLE(HOBBY, 0x5, "?", "Automobile/motorcycle"), /** * */ COMPUTER_TV_GAME(HOBBY, 0x6, "", "Computer/TV game"), /** * */ CONVERSATION_LANGUAGE(HOBBY, 0x7, "", "Conversation/language"), /** * ?? */ INFANTS_PRIMARY_SCHOOL_STUDENTS(HOBBY, 0x8, "??", "Infants/primary school students"), /** * */ JUNIOR_SENIOR_HIGH_SCHOOL_STUDENTS(HOBBY, 0x9, "", "Junior/senior high school students"), /** * ? */ COLLEGE_PREPARATORY_STUDENTS(HOBBY, 0xa, "?", "College/preparatory students"), /** * */ LIFELONG_EDUCATION_QULIFICATION(HOBBY, 0xb, "", "Lifelong education/qulification"), /** * ? */ EDUCATIONAL_PROBLEM(HOBBY, 0xc, "?", "Educational problem"), /** * ??? */ OTHERS_HOBBY(HOBBY, 0xf, "???", "Other"), /** * */ AGED_PERSONS(WELFARE, 0x0, "", "Aged persons"), /** * */ HANDICAPPED_PERSON(WELFARE, 0x1, "", "Handicapped person"), /** * ? */ SOCIAL_WELFARE(WELFARE, 0x2, "?", "Social welfare"), /** * */ VOLUNTEERS(WELFARE, 0x3, "", "Volunteers"), /** * */ SIGN_LANGUAGE(WELFARE, 0x4, "", "Sign language"), /** * */ CAPTION(WELFARE, 0x5, "", "Texts /***/(caption)"), /** * */ AUDIO_COMMENTARY(WELFARE, 0x6, "", "Audio commentary"), /** * ??? */ OTHERS_WELFARE(WELFARE, 0xf, "???", "Other"), /** * BS/? */ BS_OR_TERRESTRIAL_DIGITAL_BROADCASTING_FOR_THE_PROGRAM_INCLUDED_INFORMATION(USER_NIBBLE, 0x0, "BS/?", "BS / terrestrial digital broadcasting for the program included information"), /** * CS ? */ BROADBAND_CS_DIGITAL_BROADCASTING_FOR_THE_EXTENSION(USER_NIBBLE, 0x1, "CS ?", "Broadband CS digital broadcasting for the extension"), /** * ? */ SATELLITE_DIGITAL_AUDIO_BROADCASTING_FOR_EXPANSION(USER_NIBBLE, 0x2, "?", "Satellite digital audio broadcasting for expansion"), /** * ? */ SERVER_TYPE_PROGRAM_SUPPLIED_INFORMATION(USER_NIBBLE, 0x3, "?", "Server type program supplied information"), /** * IP ? */ IP_BROADCAST_PROGRAM_SUPPLIED_INFORMATION(USER_NIBBLE, 0x4, "IP ?", "IP broadcast program supplied information"); //?? private static final Map<MultiKey<Integer>, NIBBLE_LEVEL_2> rev = new HashMap<>(); static { { for (NIBBLE_LEVEL_2 nibble2 : NIBBLE_LEVEL_2.values()) { MultiKey<Integer> key = new MultiKey(nibble2.getParentNibble().getCode(), nibble2.getCode()); if (!rev.containsKey(key)) { rev.put(key, nibble2); } else { MessageFormat msg = new MessageFormat( "????????????={0} ?????????={1}"); Object[] parameters = { Integer.toHexString(nibble2.getCode()), nibble2 }; throw new IllegalArgumentException(msg.format(parameters)); } } } } ; /** * ?????? * * @param parentCode * @param code * @return ????null */ public static synchronized NIBBLE_LEVEL_2 reverseLookUp(int parentCode, int code) { MultiKey<Integer> key = new MultiKey(parentCode, code); return rev.get(key); } private final NIBBLE_LEVEL_1 parentNibble; private final int code; private final String nibble_en; private final String nibble_jp; private NIBBLE_LEVEL_2(NIBBLE_LEVEL_1 parentNibble, int code, String nibble_jp, String nibble_en) { this.parentNibble = parentNibble; if (this.parentNibble == null) { throw new NullPointerException("? ()?null??"); } this.code = code; if ((this.code < 0) || (this.code > 0xf)) { MessageFormat msg = new MessageFormat( "?0x00xF??={0}"); Object[] parameters = { Integer.toHexString(this.code) }; throw new IllegalArgumentException(msg.format(parameters)); } this.nibble_en = nibble_en; if ((this.nibble_en == null) || (this.nibble_en.equals(""))) { MessageFormat msg = new MessageFormat("()?null????"); Object[] parameters = { Integer.toHexString(this.code) }; throw new IllegalArgumentException(msg.format(parameters)); } this.nibble_jp = nibble_jp; if ((this.nibble_jp == null) || (this.nibble_jp.equals(""))) { MessageFormat msg = new MessageFormat("()?null????"); Object[] parameters = { Integer.toHexString(this.code) }; throw new IllegalArgumentException(msg.format(parameters)); } } public NIBBLE_LEVEL_1 getParentNibble() { return parentNibble; } public int getCode() { return code; } public String getNibble_en() { return nibble_en; } public String getNibble_jp() { return nibble_jp; } @Override public String toString() { return "NIBBLE_LEVEL_2{" + "parentNibble=" + parentNibble + ", code=" + code + ", nibble_jp=" + nibble_jp + ", nibble_en=" + nibble_en + '}'; } }