source: josm/trunk/src/com/drew/metadata/exif/DataFormat.java@ 4974

Last change on this file since 4974 was 4231, checked in by stoecker, 14 years ago

add signpost and metadata extractor code to repository directly

File size: 2.6 KB
Line 
1/*
2 * This is public domain software - that is, you can do whatever you want
3 * with it, and include it software that is licensed under the GNU or the
4 * BSD license, or whatever other licence you choose, including proprietary
5 * closed source licenses. I do ask that you leave this header in tact.
6 *
7 * If you make modifications to this code that you think would benefit the
8 * wider community, please send me a copy and I'll post it on my site.
9 *
10 * If you make use of this code, I'd appreciate hearing about it.
11 * drew@drewnoakes.com
12 * Latest version of this software kept at
13 * http://drewnoakes.com/
14 */
15package com.drew.metadata.exif;
16
17import com.drew.metadata.MetadataException;
18
19/**
20 * An enumeration of data formats used in the TIFF IFDs.
21 */
22public class DataFormat
23{
24 public static final DataFormat BYTE = new DataFormat("BYTE", 1);
25 public static final DataFormat STRING = new DataFormat("STRING", 2);
26 public static final DataFormat USHORT = new DataFormat("USHORT", 3);
27 public static final DataFormat ULONG = new DataFormat("ULONG", 4);
28 public static final DataFormat URATIONAL = new DataFormat("URATIONAL", 5);
29 public static final DataFormat SBYTE = new DataFormat("SBYTE", 6);
30 public static final DataFormat UNDEFINED = new DataFormat("UNDEFINED", 7);
31 public static final DataFormat SSHORT = new DataFormat("SSHORT", 8);
32 public static final DataFormat SLONG = new DataFormat("SLONG", 9);
33 public static final DataFormat SRATIONAL = new DataFormat("SRATIONAL", 10);
34 public static final DataFormat SINGLE = new DataFormat("SINGLE", 11);
35 public static final DataFormat DOUBLE = new DataFormat("DOUBLE", 12);
36
37 private final String myName;
38 private final int value;
39
40 public static DataFormat fromValue(int value) throws MetadataException
41 {
42 switch (value)
43 {
44 case 1: return BYTE;
45 case 2: return STRING;
46 case 3: return USHORT;
47 case 4: return ULONG;
48 case 5: return URATIONAL;
49 case 6: return SBYTE;
50 case 7: return UNDEFINED;
51 case 8: return SSHORT;
52 case 9: return SLONG;
53 case 10: return SRATIONAL;
54 case 11: return SINGLE;
55 case 12: return DOUBLE;
56 }
57
58 throw new MetadataException("value '"+value+"' does not represent a known data format.");
59 }
60
61 private DataFormat(String name, int value)
62 {
63 myName = name;
64 this.value = value;
65 }
66
67 public int getValue()
68 {
69 return value;
70 }
71
72 public String toString()
73 {
74 return myName;
75 }
76}
Note: See TracBrowser for help on using the repository browser.