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

📄 cd.java

📁 CD Manager光盘资料管家婆源代码
💻 JAVA
字号:
package com.galaxyworkstation.model;

import java.io.IOException;
import java.util.Date;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;


/**
 * 该类模拟了一张光盘,一张光盘属于某个光盘架
 * @author 李奕
 * @version 1.0
 * @see Album
 */
public class CD {
	private String ID;
	private String name;
	private Date createDate;
	private String description;
	int fileCount;
	int folderCount;
	private long albumID;

	/**
	 * 默认构造函数
	 */
	public CD(){
		this.name = "新建光盘";
		this.createDate = new Date();
		this.ID = new Long(createDate.getTime()).toString();
		this.description = "";
		this.albumID = 0;
		fileCount = folderCount = 0;
	}
	
	/**
	 * 构造函数
	 * @param name 光盘的名字
	 * @param description 光盘的描述
	 * @param belongAlbum 所属的光盘架
	 */
	public CD(String name, String description, Album belongAlbum) {
		this.name = name;
		this.createDate = new Date();
		this.ID = new Long(createDate.getTime()).toString();
		this.description = description;
		this.albumID = belongAlbum.getID();
		fileCount = folderCount = 0;
	}
	
	/**
	 * 删除数据库上该张光盘上所有数据的索引
	 */
	public void deleteIndex(){
	    try {
	    	Term term = new Term("rootID", this.ID);
	    	IndexReader reader = IndexFactory.getCDIndexReader();
			reader.deleteDocuments(term);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 得到光盘的名字
	 * @return 光盘的名字
	 */
	public String getName() {
		return name;
	}
	/**
	 * 更改光盘的名字
	 * @param name 光盘的新名字
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 得到光盘的描述
	 * @return 光盘的描述
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * 更改光盘的描述
	 * @param description 光盘的新描述
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * 得到光盘的ID
	 * @return 光盘的ID
	 */
	public String getID() {
		return ID;
	}

	/**
	 * 得到光盘的创建日期
	 * @return 光盘的创建日期
	 */
	public Date getCreateDate() {
		return createDate;
	}
	
	/**
	 * 得到光盘所属的光盘架ID
	 * @return 光盘所属的光盘架ID
	 */
	public long getAlbumID() {
		return albumID;
	}

	/**
	 * 设置光盘所属的光盘架
	 * @param belongAlbum 光盘所属的光盘架
	 */
	public void setBelongAlbum(Album belongAlbum) {
		this.albumID = belongAlbum.getID();
	}
	
	/**
	 * 得到光盘中文件的个数
	 * @return 光盘中文件的个数
	 */
	public int getFileCount() {
		return fileCount;
	}

	/**
	 * 设置光盘中文件的个数
	 * @param fileCount 光盘中文件的个数
	 */
	public void setFileCount(int fileCount) {
		this.fileCount = fileCount;
	}

	/**
	 * 得到光盘中文件夹的个数
	 * @return 光盘中文件夹的个数
	 */
	public int getFolderCount() {
		return folderCount;
	}

	/**
	 * 设置光盘中文件夹的个数
	 * @param folderCount 光盘中文件夹的个数
	 */
	public void setFolderCount(int folderCount) {
		this.folderCount = folderCount;
	}
	
	/**
	 * 光盘中文件个数自加一
	 */
	public void fileIncrease(){
		fileCount++;
	}
	
	/**
	 * 光盘中文件夹个数自加一
	 */
	public void folderIncrease(){
		folderCount++;
	}
}

⌨️ 快捷键说明

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