Archive Recent Version
This commit is contained in:
131
src/audiobook/Book.java
Executable file
131
src/audiobook/Book.java
Executable file
@@ -0,0 +1,131 @@
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package audiobook;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents an audiobook
|
||||
* @author Kim
|
||||
*/
|
||||
public class Book extends ArrayList<Chapter> {
|
||||
private String album;
|
||||
private String artist;
|
||||
private File imageFile;
|
||||
private String name;
|
||||
private File targetFolder;
|
||||
|
||||
/**
|
||||
* Creates a new empty audiobook
|
||||
*/
|
||||
public Book() {
|
||||
name = "";
|
||||
album = "";
|
||||
artist = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Audiobook with a specified image File
|
||||
* @param imageFile
|
||||
*/
|
||||
public Book(File imageFile) {
|
||||
setImageFile(imageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>File</code> containing the cover of this audiobook.
|
||||
* Returns <code>null</code> if no cover was selected.
|
||||
*/
|
||||
public File getImageFile() {
|
||||
return imageFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image of this audiobook. Images have to be in jpeg or png format
|
||||
* @param imageFile a file containing an Image
|
||||
* @throws IllegalArgumentException If the image is not a jpg, jpeg or png Image
|
||||
*/
|
||||
public void setImageFile(File imageFile) throws IllegalArgumentException {
|
||||
if (!Files.FileActions.hasExtention(imageFile, ".jpg", ".jpeg", ".png")) {
|
||||
throw new IllegalArgumentException("Illegal Image format");
|
||||
}
|
||||
|
||||
this.imageFile = imageFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the folder the audiobook is to be stored in.
|
||||
* @return a Folder
|
||||
*/
|
||||
public File getTargetFolder() {
|
||||
return targetFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the folder the audiobook is to be stored in
|
||||
* @param folder a Folder
|
||||
*/
|
||||
public void setTargetFolder(File folder) throws IllegalArgumentException {
|
||||
if (!folder.isDirectory()) {
|
||||
throw new IllegalArgumentException("Not a Folder");
|
||||
}
|
||||
|
||||
this.targetFolder = folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the album-tag information
|
||||
* @param album a String
|
||||
*/
|
||||
public void setAlbum(String album) {
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the artist-tag information
|
||||
* @param artist aString
|
||||
*/
|
||||
public void setArtist(String artist) {
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the audiobook
|
||||
* @param name a String
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the album-tag information
|
||||
*/
|
||||
public String getAlbum() {
|
||||
return album;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the artist-tag information
|
||||
*/
|
||||
public String getArtist() {
|
||||
return artist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this audiobook
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//~ Formatted by Jindent --- http://www.jindent.com
|
||||
Reference in New Issue
Block a user