/** * Write a warning to the logging and the {@link jwbroek.cuelib.CueSheet} associated with the * {@link jwbroek.cuelib.LineOfInput}. * * @param input The {@link jwbroek.cuelib.LineOfInput} the warning pertains to. * @param warning The warning to write. */ private static void addWarning(final LineOfInput input, final String warning) { CueParser.logger.warning(warning); input.getAssociatedSheet().addWarning(input, warning); }
/** * Get the last {@link jwbroek.cuelib.FileData} element. If none exist, an empty one is created and a warning * added. * * @param input * @return The last {@link jwbroek.cuelib.FileData} element. If none exist, an empty one is created and a warning * added. */ private static FileData getLastFileData(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "getLastFileData(LineOfInput)", input); List<FileData> fileDataList = input.getAssociatedSheet().getFileData(); if (fileDataList.size() == 0) { fileDataList.add(new FileData(input.getAssociatedSheet())); addWarning(input, WARNING_NO_FILE_SPECIFIED); } FileData result = fileDataList.get(fileDataList.size() - 1); CueParser.logger.exiting(CueParser.class.getCanonicalName(), "getLastFileData(LineOfInput)", result); return result; }
/** * Parse the non-standard REM COMMENT command. * <p/> * REM COMMENT [comment] * * @param input */ private static void parseRemComment(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseRemComment(LineOfInput)", input); Matcher matcher = PATTERN_REM_COMMENT.matcher(input.getInput()); if (matcher.find()) { String comment = matcher.group(2); if (comment.charAt(0) == '"' && comment.charAt(comment.length() - 1) == '"') { comment = comment.substring(1, comment.length() - 1); } input.getAssociatedSheet().setComment(comment); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseRemComment(LineOfInput)"); }
/** * Parse the non-standard REM GENRE command. * <p/> * REM GENRE [genre] * * @param input */ private static void parseRemGenre(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseRemGenre(LineOfInput)", input); Matcher matcher = PATTERN_REM_GENRE.matcher(input.getInput()); if (matcher.find()) { String genre = matcher.group(2); if (genre.charAt(0) == '"' && genre.charAt(genre.length() - 1) == '"') { genre = genre.substring(1, genre.length() - 1); } input.getAssociatedSheet().setGenre(genre); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseRemGenre(LineOfInput)"); }
/** * Parse the non-standard REM DISCID command. * <p/> * REM DISCID [discid] * * @param input */ private static void parseRemDiscid(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseRemDiscid(LineOfInput)", input); Matcher matcher = PATTERN_REM_DISCID.matcher(input.getInput()); if (matcher.find()) { String discid = matcher.group(2); if (discid.charAt(0) == '"' && discid.charAt(discid.length() - 1) == '"') { discid = discid.substring(1, discid.length() - 1); } input.getAssociatedSheet().setDiscid(discid); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseRemDiscid(LineOfInput)"); }
/** * Parse the CDTEXTFILE command. * <p/> * CDTEXTFILE [filename] * File that contains cd text data. Not mandatory. * * @param input */ private static void parseCdTextFile(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseCdTextFile(LineOfInput)", input); Matcher cdTextFileMatcher = PATTERN_CDTEXTFILE.matcher(input.getInput()); if (startsWith(input, "CDTEXTFILE") && cdTextFileMatcher.matches()) { if (input.getAssociatedSheet().getCdTextFile() != null) { CueParser.logger.warning(WARNING_DATUM_APPEARS_TOO_OFTEN); input.getAssociatedSheet().addWarning(input, WARNING_DATUM_APPEARS_TOO_OFTEN); } // If the file name is enclosed in quotes, remove those. String file = cdTextFileMatcher.group(1); if (file.length() > 0 && file.charAt(0) == '"' && file.charAt(file.length() - 1) == '"') { file = file.substring(1, file.length() - 1); } input.getAssociatedSheet().setCdTextFile(file); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseCdTextFile(LineOfInput)"); }
/** * Parse the non-standard REM DATE command. * <p/> * REM DATE [year] * * @param input */ private static void parseRemDate(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseRemDate(LineOfInput)", input); Matcher matcher = PATTERN_REM_DATE.matcher(input.getInput()); if (matcher.find()) { int year = Integer.parseInt(matcher.group(2)); if (year < 1 || year > 9999) { addWarning(input, WARNING_INVALID_YEAR); } input.getAssociatedSheet().setYear(year); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseRemDate(LineOfInput)"); }
/** * Parse the CATALOG command. * <p/> * CATALOG [media-catalog-number] * CD catalog number. Code follows UPC/EAN rules. * Usually the first command, but this is not required. Not a mandatory command. * * @param input */ private static void parseCatalog(final LineOfInput input) { CueParser.logger.entering(CueParser.class.getCanonicalName(), "parseCatalog(LineOfInput)", input); if (startsWith(input, "CATALOG")) { String catalogNumber = input.getInput().substring("CATALOG".length()).trim(); if (!PATTERN_CATALOG_NUMBER.matcher(catalogNumber).matches()) { addWarning(input, WARNING_INVALID_CATALOG_NUMBER); } if (input.getAssociatedSheet().getCatalog() != null) { addWarning(input, WARNING_DATUM_APPEARS_TOO_OFTEN); } input.getAssociatedSheet().setCatalog(catalogNumber); } else { addWarning(input, WARNING_UNPARSEABLE_INPUT); } CueParser.logger.exiting(CueParser.class.getCanonicalName(), "parseCatalog(LineOfInput)"); }
input.getAssociatedSheet().getFileData().add(new FileData(input.getAssociatedSheet() , file , fileMatcher.group(2).toUpperCase()
List<TrackData> trackDataList = input.getAssociatedSheet().getAllTrackData();
if (input.getAssociatedSheet().getFileData().size() == 0 || getLastFileData(input).getTrackData().size() == 0 ) { if (input.getAssociatedSheet().getPerformer() != null) { addWarning(input, WARNING_DATUM_APPEARS_TOO_OFTEN); input.getAssociatedSheet().setPerformer(performer); } else {
if (input.getAssociatedSheet().getFileData().size() == 0 || getLastFileData(input).getTrackData().size() == 0 ) { if (input.getAssociatedSheet().getSongwriter() != null) { addWarning(input, WARNING_DATUM_APPEARS_TOO_OFTEN); input.getAssociatedSheet().setSongwriter(songwriter); } else {
if (input.getAssociatedSheet().getFileData().size() == 0 || getLastFileData(input).getTrackData().size() == 0 ) { if (input.getAssociatedSheet().getTitle() != null) { addWarning(input, WARNING_DATUM_APPEARS_TOO_OFTEN); input.getAssociatedSheet().setTitle(title); } else {