public String getData(int field) throws NoMetaDataException {
logger.log(Level.FINEST, "get data " + field + " from "
+ file.getPath());
String value = null;
TiffField valueField;
if (jpegMetadata != null && jpegMetadata.getExif() != null) {
switch (field) {
case InfoConstants.GPS_LATITUDE:
try {
if (jpegMetadata.getExif() != null
&& jpegMetadata.getExif().getGPS() != null) {
value = String.valueOf(jpegMetadata.getExif().getGPS()
.getLatitudeAsDegreesNorth());
if (jpegMetadata.getExif().getGPS().latitudeRef == GPSTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_SOUTH) {
value = "-" + value;
}
} else {
logger.log(Level.FINER,
"no meta data for latitude exist in "
+ getFile().getPath());
throw new NoMetaDataException(
"no meta data for latitude exist in "
+ getFile().getPath());
}
} catch (ImageReadException ire) {
logger.log(Level.WARNING,
"error while reading latitude from "
+ file.getName(), ire);
}
break;
case InfoConstants.GPS_LONGITUDE:
try {
if (jpegMetadata.getExif() != null
&& jpegMetadata.getExif().getGPS() != null) {
value = String.valueOf(jpegMetadata.getExif().getGPS()
.getLongitudeAsDegreesEast());
if (jpegMetadata.getExif().getGPS().longitudeRef == GPSTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF_VALUE_WEST) {
value = "-" + value;
}
} else {
logger.log(Level.FINER,
"no meta data for longitude exist in "
+ getFile().getPath());
throw new NoMetaDataException(
"no meta data for longitude exist in "
+ getFile().getPath());
}
} catch (ImageReadException ire) {
logger.log(Level.WARNING,
"error while reading longitude from "
+ file.getName(), ire);
}
break;
case InfoConstants.DATE_TIME:
/* format 'yyyy:MM:dd kk:mm:ss' */
valueField = jpegMetadata
.findEXIFValue(TiffConstants.EXIF_TAG_CREATE_DATE);
if (valueField != null) {
value = valueField.getValueDescription();
value = value.substring(1, value.length() - 1);
}
break;
case InfoConstants.USER_COMMENT:
valueField = jpegMetadata
.findEXIFValue(TiffConstants.EXIF_TAG_USER_COMMENT);
if (valueField != null) {
value = valueField.getValueDescription();
value = value.substring(1, value.length() - 1);
}
break;
case InfoConstants.IMAGE_DESCRIPTION:
valueField = jpegMetadata
.findEXIFValue(TiffConstants.TIFF_TAG_IMAGE_DESCRIPTION);
if (valueField != null) {
value = valueField.getValueDescription();
value = value.substring(1, value.length() - 1);
}
break;
}
} else {