1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
package tim.prune.data;
import java.io.File;
/**
* Class to hold the source of the point data, including the original file
* and file type
*/
public class SourceInfo
{
/** Source file */
private final File _sourceFile;
/** Name of source */
private final String _sourceName;
/** File type */
private final FileType _fileType;
/** File version */
private final String _fileVersion;
/** File title, if any */
private String _fileTitle = null;
/** File description, if any */
private String _fileDescription = null;
/** Extension info, if any */
private ExtensionInfo _extensionInfo = null;
/** Number of points */
private int _numPoints = 0;
/** Constructor giving just the file and its type, without a version */
public SourceInfo(File inFile, FileType inType) {
this(inFile, inType, null);
}
/**
* Constructor
* @param inFile source file
* @param inType type of file
* @param inVersion version
*/
public SourceInfo(File inFile, FileType inType, String inVersion)
{
_sourceFile = inFile;
_sourceName = inFile.getName();
_fileType = inType;
_fileVersion = inVersion;
}
/**
* Constructor
* @param inName name of source (without file)
* @param inType type of file
*/
public SourceInfo(String inName, FileType inType)
{
_sourceFile = null;
_sourceName = inName;
_fileType = inType;
_fileVersion = null;
}
/**
* @param inTitle title of file, eg from <name> tag in gpx
*/
public void setFileTitle(String inTitle) {
_fileTitle = inTitle;
}
/**
* @param inDesc description of file, eg from <desc> tag in gpx
*/
public void setFileDescription(String inDesc) {
_fileDescription = inDesc;
}
public void setExtensionInfo(ExtensionInfo inInfo) {
_extensionInfo = inInfo;
}
/**
* @return source file
*/
public File getFile() {
return _sourceFile;
}
/**
* @return source name
*/
public String getName() {
return _sourceName;
}
/**
* @return file type of source
*/
public FileType getFileType() {
return _fileType;
}
/** @return version of file */
public String getFileVersion() {
return _fileVersion;
}
/**
* @return title of file
*/
public String getFileTitle() {
return _fileTitle;
}
/**
* @return description of file
*/
public String getFileDescription() {
return _fileDescription;
}
/**
* @param inNumPoints the number of points loaded from this source
*/
public void setNumPoints(int inNumPoints) {
_numPoints = inNumPoints;
}
/**
* @return number of points from this source
*/
public int getNumPoints() {
return _numPoints;
}
/**
* @return a string describing the extensions, or null if there aren't any
*/
public String getExtensions()
{
if (_extensionInfo == null) {
return null;
}
StringBuilder builder = null;
for (String url : _extensionInfo.getExtensions())
{
if (builder == null) {
builder = new StringBuilder();
}
else {
builder.append(", ");
}
builder.append(url);
}
return builder == null ? null : builder.toString();
}
/** @return the complete extension information, or null */
public ExtensionInfo getExtensionInfo() {
return _extensionInfo;
}
}
|