diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java
index 4837a330..69748af5 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata;
import java.util.ArrayList;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java
index 2ef60c07..75b8b456 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata;
import com.twelvemonkeys.lang.Validate;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java
index 07c5fb0e..e1766f54 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata;
/**
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Entry.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Entry.java
index 3b8f7da2..8681382e 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Entry.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Entry.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata;
/**
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java
index d67aff25..01457bf4 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata;
import javax.imageio.stream.ImageInputStream;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIF.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIF.java
index 5ff05628..46e22826 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIF.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIF.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.exif;
/**
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java
index 77bb8e64..d1ce5930 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.exif;
import com.twelvemonkeys.imageio.metadata.AbstractDirectory;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java
index da2e4c6e..fef71f37 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.exif;
import com.twelvemonkeys.imageio.metadata.AbstractEntry;
@@ -25,6 +53,20 @@ final class EXIFEntry extends AbstractEntry {
@Override
public String getFieldName() {
switch ((Integer) getIdentifier()) {
+ case TIFF.TAG_COMPRESSION:
+ return "Compression";
+ case TIFF.TAG_ORIENTATION:
+ return "Orientation";
+ case TIFF.TAG_X_RESOLUTION:
+ return "XResolution";
+ case TIFF.TAG_Y_RESOLUTION:
+ return "YResolution";
+ case TIFF.TAG_RESOLUTION_UNIT:
+ return "ResolutionUnit";
+ case TIFF.TAG_JPEG_INTERCHANGE_FORMAT:
+ return "JPEGInterchangeFormat";
+ case TIFF.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
+ return "JPEGInterchangeFormatLength";
case TIFF.TAG_SOFTWARE:
return "Software";
case TIFF.TAG_DATE_TIME:
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java
index f4dd56f1..2118bc57 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.exif;
import com.twelvemonkeys.imageio.metadata.Directory;
@@ -119,7 +147,7 @@ public final class EXIFReader extends MetadataReader {
private static Object readValueDirect(final ImageInputStream pInput, final short pType, final int pCount) throws IOException {
switch (pType) {
case 2:
- // TODO: This might be UTF-8 or ISO-8859-1, even spec says ASCII
+ // TODO: This might be UTF-8 or ISO-8859-1, even though spec says ASCII
byte[] ascii = new byte[pCount];
pInput.readFully(ascii);
return StringUtil.decode(ascii, 0, ascii.length, "UTF-8"); // UTF-8 is ASCII compatible
@@ -176,26 +204,25 @@ public final class EXIFReader extends MetadataReader {
pInput.readFully(doubles, 0, doubles.length);
return doubles;
- // TODO: Consider using a Rational class
case 5:
if (pCount == 1) {
- return pInput.readUnsignedInt() / (double) pInput.readUnsignedInt();
+ return new Rational(pInput.readUnsignedInt(), pInput.readUnsignedInt());
}
- double[] rationals = new double[pCount];
+ Rational[] rationals = new Rational[pCount];
for (int i = 0; i < rationals.length; i++) {
- rationals[i] = pInput.readUnsignedInt() / (double) pInput.readUnsignedInt();
+ rationals[i] = new Rational(pInput.readUnsignedInt(), pInput.readUnsignedInt());
}
return rationals;
case 10:
if (pCount == 1) {
- return pInput.readInt() / (double) pInput.readInt();
+ return new Rational(pInput.readInt(), pInput.readInt());
}
- double[] srationals = new double[pCount];
+ Rational[] srationals = new Rational[pCount];
for (int i = 0; i < srationals.length; i++) {
- srationals[i] = pInput.readInt() / (double) pInput.readInt();
+ srationals[i] = new Rational(pInput.readInt(), pInput.readInt());
}
return srationals;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java
new file mode 100644
index 00000000..ffe69ae0
--- /dev/null
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Adapted from sample code featured in
+ * "Intro to Programming in Java: An Interdisciplinary Approach" (Addison Wesley)
+ * by Robert Sedgewick and Kevin Wayne. Permission granted to redistribute under BSD license.
+ */
+
+package com.twelvemonkeys.imageio.metadata.exif;
+
+/**
+ * Represents a rational number with a {@code long} numerator and {@code long} denominator.
+ * Rational numbers are stored in reduced form with the sign stored with the numerator.
+ * Rationals are immutable.
+ *
+ * Adapted from sample code featured in
+ * "Intro to Programming in Java: An Interdisciplinary Approach" (Addison Wesley)
+ * by Robert Sedgewick and Kevin Wayne. Permission granted to redistribute under BSD license.
+ *
+ * @author Harald Kuhr
+ * @author Robert Sedgewick and Kevin Wayne (original version)
+ * @author last modified by $Author: haraldk$
+ * @version $Id: Rational.java,v 1.0 Nov 18, 2009 1:12:00 AM haraldk Exp$
+ */
+public final class Rational extends Number implements Comparable {
+ // TODO: Document public API
+ // TODO: Move to com.tm.lang?
+ // Inspired by http://www.cs.princeton.edu/introcs/92symbolic/Rational.java.html and java.lang.Integer
+ static final Rational ZERO = new Rational(0, 1);
+
+ private final long mNumerator;
+ private final long mDenominator;
+
+ public Rational(final long pNumber) {
+ this(pNumber, 1);
+ }
+
+ public Rational(final long pNumerator, final long pDenominator) {
+ if (pDenominator == 0) {
+ throw new IllegalArgumentException("denominator == 0");
+ }
+ if (pNumerator == Long.MIN_VALUE || pDenominator == Long.MIN_VALUE) {
+ throw new IllegalArgumentException("value == Long.MIN_VALUE");
+ }
+
+ // Reduce fractions
+ long gcd = gcd(pNumerator, pDenominator);
+ long num = pNumerator / gcd;
+ long den = pDenominator / gcd;
+
+ mNumerator = pDenominator >= 0 ? num : -num;
+ mDenominator = pDenominator >= 0 ? den : -den;
+ }
+
+ private static long gcd(final long m, final long n) {
+ if (m < 0) {
+ return gcd(n, -m);
+ }
+
+ return n == 0 ? m : gcd(n, m % n);
+ }
+
+ private static long lcm(final long m, final long n) {
+ if (m < 0) {
+ return lcm(n, -m);
+ }
+
+ return m * (n / gcd(m, n)); // parentheses important to avoid overflow
+ }
+
+ public long numerator() {
+ return mNumerator;
+ }
+
+ public long denominator() {
+ return mDenominator;
+ }
+
+ /// Number implementation
+
+ @Override
+ public int intValue() {
+ return (int) doubleValue();
+ }
+
+ @Override
+ public long longValue() {
+ return (long) doubleValue();
+ }
+
+ @Override
+ public float floatValue() {
+ return (float) doubleValue();
+ }
+
+ @Override
+ public double doubleValue() {
+ return mNumerator / (double) mDenominator;
+ }
+
+ /// Comparable implementation
+
+ public int compareTo(final Rational pOther) {
+ double thisVal = doubleValue();
+ double otherVal = pOther.doubleValue();
+
+ return thisVal < otherVal ? -1 : thisVal == otherVal ? 0 : 1;
+ }
+
+ /// Object overrides
+
+ @Override
+ public int hashCode() {
+ return Float.floatToIntBits(floatValue());
+ }
+
+ @Override
+ public boolean equals(final Object pOther) {
+ return pOther == this || pOther instanceof Rational && compareTo((Rational) pOther) == 0;
+ }
+
+ @Override
+ public String toString() {
+ return mDenominator == 1 ? Long.toString(mNumerator) : String.format("%s/%s", mNumerator, mDenominator);
+ }
+
+ /// Operations (adapted from http://www.cs.princeton.edu/introcs/92symbolic/Rational.java.html)
+ // TODO: Naming! multiply/divide/add/subtract or times/divides/plus/minus
+
+ // return a * b, staving off overflow as much as possible by cross-cancellation
+ public Rational times(final Rational pOther) {
+ // special cases
+ if (equals(ZERO) || pOther.equals(ZERO)) {
+ return ZERO;
+ }
+
+ // reduce p1/q2 and p2/q1, then multiply, where a = p1/q1 and b = p2/q2
+ Rational c = new Rational(mNumerator, pOther.mDenominator);
+ Rational d = new Rational(pOther.mNumerator, mDenominator);
+
+ return new Rational(c.mNumerator * d.mNumerator, c.mDenominator * d.mDenominator);
+ }
+
+ // return a + b, staving off overflow
+ public Rational plus(final Rational pOther) {
+ // special cases
+ if (equals(ZERO)) {
+ return pOther;
+ }
+ if (pOther.equals(ZERO)) {
+ return this;
+ }
+
+ // Find gcd of numerators and denominators
+ long f = gcd(mNumerator, pOther.mNumerator);
+ long g = gcd(mDenominator, pOther.mDenominator);
+
+ // add cross-product terms for numerator
+ // multiply back in
+ return new Rational(
+ ((mNumerator / f) * (pOther.mDenominator / g) + (pOther.mNumerator / f) * (mDenominator / g)) * f,
+ lcm(mDenominator, pOther.mDenominator)
+ );
+ }
+
+ // return -a
+ public Rational negate() {
+ return new Rational(-mNumerator, mDenominator);
+ }
+
+ // return a - b
+ public Rational minus(final Rational pOther) {
+ return plus(pOther.negate());
+ }
+
+ public Rational reciprocal() {
+ return new Rational(mDenominator, mNumerator);
+ }
+
+ // return a / b
+ public Rational divides(final Rational pOther) {
+ if (pOther.equals(ZERO)) {
+ throw new ArithmeticException("/ by zero");
+ }
+
+ return times(pOther.reciprocal());
+ }
+}
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/TIFF.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/TIFF.java
index b47ae01b..c7fc6e27 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/TIFF.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/TIFF.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.exif;
/**
@@ -45,9 +73,45 @@ public interface TIFF {
int IFD_GPS = 0x8825;
int IFD_INTEROP = 0xA005;
+ /// A. Tags relating to image data structure:
+
+ int TAG_IMAGE_WIDTH = 256;
+ int TAG_IMAGE_HEIGHT = 257;
+ int TAG_BITS_PER_SAMPLE = 258;
+ int TAG_COMPRESSION = 259;
+ int TAG_PHOTOMETRIC_INTERPRETATION = 262;
+ int TAG_ORIENTATION = 274;
+ int TAG_SAMPLES_PER_PIXELS = 277;
+ int TAG_PLANAR_CONFIGURATION = 284;
+ int TAG_YCBCR_SUB_SAMPLING = 530;
+ int TAG_YCBCR_POSITIONING = 531;
+ int TAG_X_RESOLUTION = 282;
+ int TAG_Y_RESOLUTION = 283;
+ int TAG_RESOLUTION_UNIT = 296;
+
+ /// B. Tags relating to recording offset
+
+ int TAG_STRIP_OFFSETS = 273;
+ int TAG_ROWS_PER_STRIP = 278;
+ int TAG_STRIP_BYTE_COUNTS = 279;
+ int TAG_JPEG_INTERCHANGE_FORMAT = 513;
+ int TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = 514;
+
+ /// C. Tags relating to image data characteristics
+
+ int TAG_TRANSFER_FUNCTION = 301;
+ int TAG_WHITE_POINT = 318;
+ int TAG_PRIMARY_CHROMATICITIES = 319;
+ int TAG_YCBCR_COEFFICIENTS = 529;
+ int TAG_REFERENCE_BLACK_WHITE = 532;
+
+ /// D. Other tags
- int TAG_SOFTWARE = 305;
int TAG_DATE_TIME = 306;
+ int TAG_IMAGE_DESCRIPTION = 270;
+ int TAG_MAKE = 271;
+ int TAG_MODEL = 272;
+ int TAG_SOFTWARE = 305;
int TAG_ARTIST = 315;
int TAG_COPYRIGHT = 33432;
}
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTC.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTC.java
index a762f6bb..a149aa80 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTC.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTC.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.iptc;
/**
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java
index e3bb2745..a3fb3325 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.iptc;
import com.twelvemonkeys.imageio.metadata.AbstractDirectory;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java
index 9c046911..3b1175a2 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.iptc;
import com.twelvemonkeys.imageio.metadata.AbstractEntry;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java
index eea40917..a9f23b96 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.iptc;
import com.twelvemonkeys.imageio.metadata.Directory;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMP.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMP.java
index b67d24ab..d36cc6c4 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMP.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMP.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import java.util.Collections;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java
index b79ad8d1..8f4d53a2 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import com.twelvemonkeys.imageio.metadata.AbstractDirectory;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java
index 4ef515ff..202a0ce7 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import com.twelvemonkeys.imageio.metadata.AbstractEntry;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPNamespaceMapping.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPNamespaceMapping.java
index bc0077be..0170acb3 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPNamespaceMapping.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPNamespaceMapping.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import java.util.HashMap;
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java
index fff9de38..ff4d4f51 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import com.twelvemonkeys.imageio.metadata.*;
@@ -70,8 +98,6 @@ public final class XMPReader extends MetadataReader {
}
}
- // TODO: Consider using namespace-prefix in tags/identifiers and qName as field only!?
-
private XMPDirectory parseDirectories(final Node pParentNode, NodeList pNodes) {
Map> subdirs = new LinkedHashMap>();
@@ -103,7 +129,6 @@ public final class XMPReader extends MetadataReader {
continue;
}
- // TODO: Preserve the stRef namespace here..
entries.add(new XMPEntry(child.getNamespaceURI() + child.getLocalName(), child.getLocalName(), getChildTextValue(child)));
}
value = new XMPDirectory(entries);
@@ -120,12 +145,12 @@ public final class XMPReader extends MetadataReader {
value = getChildTextValue(node);
}
- // TODO: Preserve namespace (without URI?) here..
XMPEntry entry = new XMPEntry(node.getNamespaceURI() + node.getLocalName(), node.getLocalName(), value);
dir.add(entry);
}
}
+ // TODO: Consider flattening the somewhat artificial directory structure
List entries = new ArrayList();
for (Map.Entry> entry : subdirs.entrySet()) {
diff --git a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java
index 8e9f6a7c..07f2b2fa 100644
--- a/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java
+++ b/twelvemonkeys-imageio/metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) 2009, Harald Kuhr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name "TwelveMonkeys" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package com.twelvemonkeys.imageio.metadata.xmp;
import com.twelvemonkeys.imageio.stream.BufferedImageInputStream;
diff --git a/twelvemonkeys-imageio/metadata/src/test/java/com/twelvemonkeys/imageio/metadata/exif/RationalTestCase.java b/twelvemonkeys-imageio/metadata/src/test/java/com/twelvemonkeys/imageio/metadata/exif/RationalTestCase.java
new file mode 100644
index 00000000..819c334e
--- /dev/null
+++ b/twelvemonkeys-imageio/metadata/src/test/java/com/twelvemonkeys/imageio/metadata/exif/RationalTestCase.java
@@ -0,0 +1,143 @@
+package com.twelvemonkeys.imageio.metadata.exif;
+
+import junit.framework.TestCase;
+
+/**
+ * RationalTestCase
+ *
+ * @author Harald Kuhr
+ * @author last modified by $Author: haraldk$
+ * @version $Id: RationalTestCase.java,v 1.0 Nov 18, 2009 3:23:17 PM haraldk Exp$
+ */
+public class RationalTestCase extends TestCase {
+ public void testZeroDenominator() {
+ try {
+ new Rational(1, 0);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException expected) {
+ }
+ }
+
+ // TODO: Find a solution to this problem, as we should be able to work with it...
+ public void testLongMinValue() {
+ try {
+ new Rational(Long.MIN_VALUE, 1);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException expected) {
+ }
+
+ try {
+ new Rational(1, Long.MIN_VALUE);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testEquals() {
+ assertEquals(new Rational(0, 1), new Rational(0, 999));
+ assertEquals(new Rational(0, 1), new Rational(0, -1));
+ assertEquals(new Rational(1, 2), new Rational(1000000, 2000000));
+ assertEquals(new Rational(1, -2), new Rational(-1, 2));
+
+ Rational x = new Rational(1, -2);
+ Rational y = new Rational(-1000000, 2000000);
+ assertEquals(x, y);
+ assertEquals(x.numerator(), y.numerator());
+ assertEquals(x.denominator(), y.denominator());
+
+ }
+
+ public void testEqualsBoundaries() {
+ assertEquals(new Rational(Long.MAX_VALUE, Long.MAX_VALUE), new Rational(1, 1));
+
+ // NOTE: Math.abs(Long.MIN_VALUE) == Long.MIN_VALUE... :-P
+ assertEquals(new Rational(Long.MIN_VALUE + 1, Long.MIN_VALUE + 1), new Rational(1, 1));
+ assertEquals(new Rational(Long.MIN_VALUE + 1, Long.MAX_VALUE), new Rational(-1, 1));
+ assertEquals(new Rational(Long.MAX_VALUE, Long.MIN_VALUE + 1), new Rational(-1, 1));
+ }
+
+ public void testReciprocal() {
+ assertEquals(new Rational(1, 99), new Rational(99, 1).reciprocal());
+ assertEquals(new Rational(-1, 1234567), new Rational(-1234567, 1).reciprocal());
+ }
+
+ public void testNegate() {
+ assertEquals(new Rational(-1, 99), new Rational(1, 99).negate());
+ assertEquals(new Rational(1, 1234567), new Rational(1, -1234567).negate());
+ }
+
+ public void testPlus() {
+ Rational x, y;
+
+ // 1/2 + 1/3 = 5/6
+ x = new Rational(1, 2);
+ y = new Rational(1, 3);
+ assertEquals(new Rational(5, 6), x.plus(y));
+
+ // 8/9 + 1/9 = 1
+ x = new Rational(8, 9);
+ y = new Rational(1, 9);
+ assertEquals(new Rational(1, 1), x.plus(y));
+
+ // 1/200000000 + 1/300000000 = 1/120000000
+ x = new Rational(1, 200000000);
+ y = new Rational(1, 300000000);
+ assertEquals(new Rational(1, 120000000), x.plus(y));
+
+ // 1073741789/20 + 1073741789/30 = 1073741789/12
+ x = new Rational(1073741789, 20);
+ y = new Rational(1073741789, 30);
+ assertEquals(new Rational(1073741789, 12), x.plus(y));
+
+ // x + 0 = x
+ assertEquals(x, x.plus(Rational.ZERO));
+ }
+
+ public void testTimes() {
+ Rational x, y;
+
+ // 4/17 * 17/4 = 1
+ x = new Rational(4, 17);
+ y = new Rational(17, 4);
+ assertEquals(new Rational(1, 1), x.times(y));
+
+ // 3037141/3247033 * 3037547/3246599 = 841/961
+ x = new Rational(3037141, 3247033);
+ y = new Rational(3037547, 3246599);
+ assertEquals(new Rational(841, 961), x.times(y));
+
+ // x * 0 = 0
+ assertEquals(Rational.ZERO, x.times(Rational.ZERO));
+ }
+
+ public void testMinus() {
+ // 1/6 - -4/-8 = -1/3
+ Rational x = new Rational(1, 6);
+ Rational y = new Rational(-4, -8);
+ assertEquals(new Rational(-1, 3), x.minus(y));
+
+ // x - 0 = x
+ assertEquals(x, x.minus(Rational.ZERO));
+ }
+
+ public void testDivides() {
+ // 3037141/3247033 / 3246599/3037547 = 841/961
+ Rational x = new Rational(3037141, 3247033);
+ Rational y = new Rational(3246599, 3037547);
+ assertEquals(new Rational(841, 961), x.divides(y));
+
+ // 0 / x = 0
+ assertEquals(Rational.ZERO, new Rational(0, 386).divides(x));
+ }
+
+ public void testDivideZero() {
+ try {
+ new Rational(3037141, 3247033).divides(new Rational(0, 1));
+ }
+ catch (ArithmeticException expected) {
+ }
+ }
+}