⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 songvo.java

📁 一个Java写的音乐网站应用小程序
💻 JAVA
字号:
package music.shared; 

public class SongVO implements java.io.Serializable
{
    private static final int UNKNOWN = 0;
    private static final int MPA = 1;
    private static final int MP2 = 2;
    private static final int MP3 = 3;
    private static final int MP4 = 4;
    private static final int WMA = 5;
    private static final int RAM = 6;
    private static final int WAV = 7;
    private static final int MID = 8;
    private static final int ASF = 9;
    private static final int VQF = 10;
    private static final int AIF = 11;
    private static final int AU = 12;
    private static final int VOC = 13;
    private static final int APE = 14;

    private static final int LAST_INDEX = 14; // the last index of the TYPE
    private static final String[] TYPES = new String[] {
        "unknown", "mpa", "mp2", "mp3", "mp4", "wma", "ram",
        "wav", "mid", "asf", "vqf", "aif", "au", "voc", "ape"
    };

    private int id;
    private String title;
    private int rating;
    private int type;
    private String url;
    private int downloadTimes;
    private String lyric;

    public SongVO(int id, String title, int type, String url,
        String lyric, int rating, int downloadTimes)
    {
        this.id = id;
        this.title = title;
        this.type = type;
        this.rating = rating;
        this.downloadTimes = downloadTimes;

        setUrl(url);
        setLyric(lyric);
    }

    public int getId() { return this.id; }
    public void setId(int id) { this.id = id; }

    public String getTitle() { return this.title; }
    public void setTitle(String title) { this.title = title; }

    /**
     * rating will be 1-5
     */
    public int getRating() {
        if(this.rating < 1) this.rating = 1;
        if(this.rating > 5) this.rating = 5;
        return this.rating;
    }
    public void setRating(int rating) { this.rating = rating; }

    public int getType() { return this.type; }
    public void setType(int type) { this.type = type; };

    public String getUrl() { return this.url; }
    public void setUrl(String url) {
        if(url!=null) {
            url = url.trim();
            if(url.equals("")) url = null;
        }
        this.url = url;
    }

    public int getDownloadTimes() { return this.downloadTimes; }
    public void setDownloadTimes(int downloadTimes) { this.downloadTimes = downloadTimes; }

    public String getLyric() { return this.lyric; }
    public void setLyric(String lyric) {
        if(lyric!=null) {
            lyric = lyric.trim();
            if(lyric.equals("")) lyric = null;
        }
        this.lyric = lyric;
    }

    /**
     * test if lyric has been set.
     */
    public boolean hasLyric() { return this.lyric!=null; }

    /**
     * test if url has been set. if not, download is unavailable.
     */
    public boolean hasUrl() { return this.url!=null; }

    /**
     * return the type of the file
     */
    public String getTypeName() {
        if(type<0 || type>LAST_INDEX) type = 0;
        return TYPES[type];
    }

    public void setTypeName(String typeName) {
        if(typeName==null) {
            type = 0;
            return;
        }
        typeName = typeName.toLowerCase();
        for(int i=1; i<=LAST_INDEX; i++) {
            if(typeName.equals(TYPES[i])) {
                type = i;
                return;
            }
        }
        type = 0;
    }

    public String toString() { return this.title; }

} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -