001 /** 002 * Do we want to use this space for anything? Eg, revision history? 003 */ 004 package edu.nrao.sss.model.proposal; 005 006 007 /** <i>Placeholder for time when we integrate proposal work.</i> 008 * A description of a {@link JustificationFile}. This class 009 * represents the metadata, but not the data, for a 010 * justification file. 011 * <p> 012 * TODO Should we think about making this more general by 013 * removing the "Justification" label an putting this 014 * in a different package?</p> 015 * 016 * @version 1.1 017 * @since 2006-03-23 018 */ 019 public class JustificationFileDescriptor 020 { 021 private String fileName; 022 private JustificationFileType fileType; 023 private long byteSize; 024 025 /** 026 * Representation of an empty file. This is the initial state 027 * of the {@code byteSize} property of objects of this class. 028 */ 029 public static final long EMPTY_FILE = 0L; 030 031 /** 032 * Representation of an unnamed file. This is the initial state 033 * of the {@code fileName} property of objects of this class. 034 */ 035 public static final String UNNAMED_FILE = ""; 036 037 /** Creates a new instance. */ 038 public JustificationFileDescriptor() 039 { 040 initialize(); 041 } 042 043 private void initialize() 044 { 045 fileName = ""; 046 fileType = JustificationFileType.UNKNOWN; 047 byteSize = 0L; 048 } 049 050 /** 051 * Resets this descriptor to its initial state. The state 052 * of this descriptor is the same as that of a newly 053 * created descriptor. 054 */ 055 public void reset() 056 { 057 initialize(); 058 } 059 060 /** 061 * Returns the size of the {@link JustificationFile} described by this 062 * object in bytes. 063 * 064 * @return the size of the described justification file in bytes. 065 */ 066 public long getByteSize() 067 { 068 return byteSize; 069 } 070 071 /** 072 * Sets the size of the {@link JustificationFile} described by this 073 * object in bytes. 074 * <p> 075 * If {@code byteSize} is less than zero, it will be treated as if it 076 * were {@link #EMPTY_FILE}.</p> 077 * 078 * @param byteSize the size of the described justification file in bytes. 079 */ 080 public void setByteSize(long byteSize) 081 { 082 this.byteSize = (byteSize < EMPTY_FILE) ? EMPTY_FILE : byteSize; 083 } 084 085 /** 086 * Returns the name of the {@link JustificationFile} described by this object. 087 * 088 * @return the name of the described justification file. 089 */ 090 public String getFileName() 091 { 092 return fileName; 093 } 094 095 /** 096 * Sets the name of the {@link JustificationFile} described by this object. 097 * <p> 098 * If {@code fileName} is <i>null</i>, it will be treated as if it were 099 * {@link #UNNAMED_FILE}.</p> 100 * 101 * @param fileName the name of the described justification file. 102 */ 103 public void setFileName(String fileName) 104 { 105 this.fileName = (fileName == null) ? UNNAMED_FILE : fileName; 106 } 107 108 /** 109 * Returns the type of the {@link JustificationFile} described by this object. 110 * 111 * @return the type of the described justification file. 112 */ 113 public JustificationFileType getFileType() 114 { 115 return fileType; 116 } 117 118 /** 119 * Sets the type of the {@link JustificationFile} described by this object. 120 * <p> 121 * If {@code fileName} is <i>null</i>, it will be treated as if it were 122 * {@link JustificationFileType#UNKNOWN}.</p> 123 * 124 * @param fileType the type of the described justification file. 125 */ 126 public void setFileType(JustificationFileType fileType) 127 { 128 this.fileType = (fileType == null) ? JustificationFileType.UNKNOWN 129 : fileType; 130 } 131 }