2017-07-27 17:35:16 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2017 Paul Schaub
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-08-04 23:05:59 +02:00
|
|
|
package org.jivesoftware.smackx.jft.component.file;
|
2017-07-27 15:18:18 +02:00
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by vanitas on 26.07.17.
|
|
|
|
*/
|
|
|
|
public class LocalFile extends AbstractJingleFileTransferFile {
|
|
|
|
|
|
|
|
private File file;
|
2017-08-13 14:38:53 +02:00
|
|
|
private String name;
|
2017-07-27 15:18:18 +02:00
|
|
|
private String description;
|
|
|
|
private String mediaType;
|
|
|
|
private HashElement hashElement;
|
|
|
|
|
|
|
|
public LocalFile(File file) {
|
|
|
|
this(file, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalFile(File file, String description) {
|
|
|
|
this(file, description, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalFile(File file, String description, String mediaType) {
|
|
|
|
super();
|
|
|
|
this.file = file;
|
2017-08-13 14:38:53 +02:00
|
|
|
String path = file.getAbsolutePath();
|
|
|
|
name = path.substring(path.lastIndexOf(File.separator) + 1);
|
2017-07-27 15:18:18 +02:00
|
|
|
this.description = description;
|
|
|
|
this.mediaType = mediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Date getDate() {
|
|
|
|
return new Date(file.lastModified());
|
|
|
|
}
|
|
|
|
|
2017-08-13 14:38:53 +02:00
|
|
|
public void setDate(Date date) {
|
|
|
|
}
|
|
|
|
|
2017-07-27 15:18:18 +02:00
|
|
|
@Override
|
|
|
|
public long getSize() {
|
|
|
|
return file.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
2017-08-13 14:38:53 +02:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
2017-07-27 15:18:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getMediaType() {
|
|
|
|
return mediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public HashElement getHashElement() {
|
|
|
|
return hashElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMediaType(String mediaType) {
|
|
|
|
this.mediaType = mediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHashElement(HashElement hashElement) {
|
|
|
|
this.hashElement = hashElement;
|
|
|
|
}
|
2017-07-29 22:21:36 +02:00
|
|
|
|
|
|
|
public File getFile() {
|
|
|
|
return file;
|
|
|
|
}
|
2017-07-27 15:18:18 +02:00
|
|
|
}
|