package org.jerrymouse.cc.site.store.cc;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;

@Entity
public class CCResourceFile {
	@Lob
	private byte[] content;
	@Id
	private String usernameFilename = "username-filename";

	public byte[] getContent() {
		return content;
	}

	public String getFilename() {
		int i = usernameFilename.indexOf('-');
		return usernameFilename.substring(i + 1);
	}

	public void setContent(byte[] content) {
		this.content = content;
	}

	public void setFilename(String filename) {
		usernameFilename = getUsername() + "-" + filename;
	}

	public void setUsername(String username) {
		usernameFilename = username + "-" + getFilename();
	}

	public String getUsername() {
		int i = usernameFilename.indexOf('-');
		return usernameFilename.substring(0, i);
	}

	public void setUsernameFilename(String usernameFilename) {
		this.usernameFilename = usernameFilename;
	}

	public String getUsernameFilename() {
		return usernameFilename;
	}

}
