src/main/java/ca/phon/plugins/praat/TextGridManager.java
/**
	 * Return the default textGrid file for the given session.
	 *
	 * @param session
	 */
Return the default textGrid file for the given session.
@param session
Return the default textGrid file for the given session . @param session
public Optional<File> defaultTextGridFile(Session session) {
		List<File> textGridFiles = textGridFilesForSession(session);
		final String mediaName = FilenameUtils.getBaseName(session.getMediaLocation());
		final File mediaFile = MediaLocator.findMediaFile(project, session);
		if(mediaFile != null) {
			final File parentFolder = mediaFile.getParentFile();
			final File defaultTgFile = new File(parentFolder, mediaName + TEXTGRID_EXT);
			if(defaultTgFile.exists()) {
				return Optional.of(defaultTgFile);
			}
		}
		final String textGridFolder = textGridFolder(session.getCorpus(), session.getName());
		final File defaultTgFile = new File(textGridFolder, mediaName + TEXTGRID_EXT);
		if(textGridFiles.contains(defaultTgFile)) {
			return Optional.of(defaultTgFile);
		}
		final File backupTgFile = new File(textGridFolder, session.getName() + TEXTGRID_EXT);
		if(textGridFiles.contains(backupTgFile)) {
			return Optional.of(backupTgFile);
		}
		if(textGridFiles.size() > 0) {
			return Optional.of(textGridFiles.get(0));
		}
		return Optional.empty();
	}
public Optional < File > defaultTextGridFile ( Session session ) { List < File > textGridFiles = textGridFilesForSession ( session ) ; final String mediaName = FilenameUtils . getBaseName ( session . getMediaLocation ( ) ) ; final File mediaFile = MediaLocator . findMediaFile ( project , session ) ; if ( mediaFile != null ) { final File parentFolder = mediaFile . getParentFile ( ) ; final File defaultTgFile = new File ( parentFolder , mediaName + TEXTGRID_EXT ) ; if ( defaultTgFile . exists ( ) ) { return Optional . of ( defaultTgFile ) ; } } final String textGridFolder = textGridFolder ( session . getCorpus ( ) , session . getName ( ) ) ; final File defaultTgFile = new File ( textGridFolder , mediaName + TEXTGRID_EXT ) ; if ( textGridFiles . contains ( defaultTgFile ) ) { return Optional . of ( defaultTgFile ) ; } final File backupTgFile = new File ( textGridFolder , session . getName ( ) + TEXTGRID_EXT ) ; if ( textGridFiles . contains ( backupTgFile ) ) { return Optional . of ( backupTgFile ) ; } if ( textGridFiles . size ( ) > 0 ) { return Optional . of ( textGridFiles . get ( 0 ) ) ; } return Optional . empty ( ) ; }
Return the default textGrid file for the given session.
Return the default textGrid file for the given session .
// TextGrid sibling of media // files in __res/textgrids/<corpus>/<session>/ // finally return the first file found