| 1 | /*
|
|---|
| 2 | * Copyright 2002-2012 Drew Noakes
|
|---|
| 3 | *
|
|---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|---|
| 5 | * you may not use this file except in compliance with the License.
|
|---|
| 6 | * You may obtain a copy of the License at
|
|---|
| 7 | *
|
|---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
|---|
| 9 | *
|
|---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
|---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
|---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|---|
| 13 | * See the License for the specific language governing permissions and
|
|---|
| 14 | * limitations under the License.
|
|---|
| 15 | *
|
|---|
| 16 | * More information about this project is available at:
|
|---|
| 17 | *
|
|---|
| 18 | * http://drewnoakes.com/code/exif/
|
|---|
| 19 | * http://code.google.com/p/metadata-extractor/
|
|---|
| 20 | */
|
|---|
| 21 | package com.drew.metadata.exif;
|
|---|
| 22 |
|
|---|
| 23 | import com.drew.lang.annotations.NotNull;
|
|---|
| 24 | import com.drew.metadata.MetadataException;
|
|---|
| 25 |
|
|---|
| 26 | /**
|
|---|
| 27 | * An enumeration of data formats used in the TIFF IFDs.
|
|---|
| 28 | *
|
|---|
| 29 | * @author Drew Noakes http://drewnoakes.com
|
|---|
| 30 | */
|
|---|
| 31 | public class DataFormat
|
|---|
| 32 | {
|
|---|
| 33 | @NotNull public static final DataFormat BYTE = new DataFormat("BYTE", 1);
|
|---|
| 34 | @NotNull public static final DataFormat STRING = new DataFormat("STRING", 2);
|
|---|
| 35 | @NotNull public static final DataFormat USHORT = new DataFormat("USHORT", 3);
|
|---|
| 36 | @NotNull public static final DataFormat ULONG = new DataFormat("ULONG", 4);
|
|---|
| 37 | @NotNull public static final DataFormat URATIONAL = new DataFormat("URATIONAL", 5);
|
|---|
| 38 | @NotNull public static final DataFormat SBYTE = new DataFormat("SBYTE", 6);
|
|---|
| 39 | @NotNull public static final DataFormat UNDEFINED = new DataFormat("UNDEFINED", 7);
|
|---|
| 40 | @NotNull public static final DataFormat SSHORT = new DataFormat("SSHORT", 8);
|
|---|
| 41 | @NotNull public static final DataFormat SLONG = new DataFormat("SLONG", 9);
|
|---|
| 42 | @NotNull public static final DataFormat SRATIONAL = new DataFormat("SRATIONAL", 10);
|
|---|
| 43 | @NotNull public static final DataFormat SINGLE = new DataFormat("SINGLE", 11);
|
|---|
| 44 | @NotNull public static final DataFormat DOUBLE = new DataFormat("DOUBLE", 12);
|
|---|
| 45 |
|
|---|
| 46 | @NotNull private final String _name;
|
|---|
| 47 | private final int _value;
|
|---|
| 48 |
|
|---|
| 49 | @NotNull
|
|---|
| 50 | public static DataFormat fromValue(int value) throws MetadataException
|
|---|
| 51 | {
|
|---|
| 52 | switch (value)
|
|---|
| 53 | {
|
|---|
| 54 | case 1: return BYTE;
|
|---|
| 55 | case 2: return STRING;
|
|---|
| 56 | case 3: return USHORT;
|
|---|
| 57 | case 4: return ULONG;
|
|---|
| 58 | case 5: return URATIONAL;
|
|---|
| 59 | case 6: return SBYTE;
|
|---|
| 60 | case 7: return UNDEFINED;
|
|---|
| 61 | case 8: return SSHORT;
|
|---|
| 62 | case 9: return SLONG;
|
|---|
| 63 | case 10: return SRATIONAL;
|
|---|
| 64 | case 11: return SINGLE;
|
|---|
| 65 | case 12: return DOUBLE;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | throw new MetadataException("value '"+value+"' does not represent a known data format.");
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | private DataFormat(@NotNull String name, int value)
|
|---|
| 72 | {
|
|---|
| 73 | _name = name;
|
|---|
| 74 | _value = value;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | public int getValue()
|
|---|
| 78 | {
|
|---|
| 79 | return _value;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | @NotNull
|
|---|
| 83 | public String toString()
|
|---|
| 84 | {
|
|---|
| 85 | return _name;
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|