1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.common.mediaMetaData;
|
11
|
|
12
|
import java.io.IOException;
|
13
|
import java.net.URI;
|
14
|
|
15
|
import org.apache.http.HttpException;
|
16
|
|
17
|
|
18
|
/**
|
19
|
* @author k.luther
|
20
|
* @date 27.11.2009
|
21
|
*
|
22
|
*/
|
23
|
public final class MetaDataFactory {
|
24
|
|
25
|
private static MetaDataFactory instance;
|
26
|
|
27
|
private MetaDataFactory(){
|
28
|
|
29
|
}
|
30
|
public synchronized static MetaDataFactory getInstance() {
|
31
|
if (instance == null) {
|
32
|
instance = new MetaDataFactory();
|
33
|
}
|
34
|
return instance;
|
35
|
}
|
36
|
public MediaMetaData readMediaData(URI uri, MimeType mimetype, Integer timeOut) throws IOException, HttpException{
|
37
|
//MediaMetaData metaData = MediaMetaData.newInstance();
|
38
|
//MimeType mimeType = metaData.readMediaInfo(uri);
|
39
|
switch (mimetype){
|
40
|
case JPEG:
|
41
|
JpegImageMetaData jpegMediaMetaData = JpegImageMetaData.newInstance();
|
42
|
jpegMediaMetaData.readMetaData(uri, timeOut);
|
43
|
((ImageMetaData)jpegMediaMetaData).readImageInfo(uri, timeOut);
|
44
|
return jpegMediaMetaData;
|
45
|
case TIFF:
|
46
|
TiffImageMetaData tiffMetaData = TiffImageMetaData.newInstance();
|
47
|
tiffMetaData.readMetaData(uri, timeOut);
|
48
|
((ImageMetaData)tiffMetaData).readImageInfo(uri, timeOut);
|
49
|
return tiffMetaData;
|
50
|
case IMAGE:
|
51
|
ImageMetaData imageMetaData = ImageMetaData.newInstance();
|
52
|
imageMetaData.readImageInfo(uri, timeOut);
|
53
|
if (imageMetaData.mimeType.equals(MimeType.JPEG.getMimeType())){
|
54
|
JpegImageMetaData jpegMediaMetaData2 = JpegImageMetaData.newInstance();
|
55
|
jpegMediaMetaData2.readMetaData(uri, timeOut);
|
56
|
return jpegMediaMetaData2;
|
57
|
}else if (imageMetaData.mimeType.equals(MimeType.TIFF.getMimeType())){
|
58
|
TiffImageMetaData tiffMetaData2 = TiffImageMetaData.newInstance();
|
59
|
tiffMetaData2.readMetaData(uri, timeOut);
|
60
|
((ImageMetaData)tiffMetaData2).readImageInfo(uri, timeOut);
|
61
|
return tiffMetaData2;
|
62
|
} else {
|
63
|
return imageMetaData;
|
64
|
}
|
65
|
default:
|
66
|
break;
|
67
|
}
|
68
|
return null;
|
69
|
|
70
|
|
71
|
}
|
72
|
}
|
73
|
|