All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.metadata.tiff.persistence.TIFFBasedBeanAccessor Maven / Gradle / Ivy

/***********************************************************************************************************************
 *
 * blueMarine Metadata - open source media workflow
 * Copyright (C) 2007-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluemarine.tidalwave.it
 * SCM: https://kenai.com/hg/bluemarine~metadata-src
 *
 **********************************************************************************************************************/
package it.tidalwave.metadata.tiff.persistence;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import it.tidalwave.image.metadata.Directory;

/*******************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public class TIFFBasedBeanAccessor extends DirectoryBeanAccessor
  {
    protected static final List TRANSIENT_PROPERTIES =
            Arrays.asList("Thumbnail", "Inter Colour Profile", "Original Raw File Data", "XMP", "DNG Private Data", "User Comment");

    /*
     * TIFF defines some derived properties that returns some values with
     * alternate types. They will be added to the bunch of available properties.
     * */
    /* package */ static final Object[][] EXTRA_PROPERTIES =
      {
        {   306, "dateTimeAsDate" },
        { 36867, "dateTimeOriginalAsDate" },
        { 36868, "dateTimeDigitizedAsDate" },
        { 37510, "userCommentAsString" }
      };

    /***************************************************************************
     *
     **************************************************************************/
    protected TIFFBasedBeanAccessor (@Nonnull final Class beanClass,
                                     @Nonnull final String name)
      {
        super(beanClass, name, TRANSIENT_PROPERTIES, EXTRA_PROPERTIES);
      }
    
    /***************************************************************************
     *
     **************************************************************************/
    protected TIFFBasedBeanAccessor (@Nonnull final Class beanClass,
                                     @Nonnull final String name,
                                     @Nonnull final List transientProperties,
                                     @Nonnull final Object[][] extraProperties)
      {
        super(beanClass, name, added(TRANSIENT_PROPERTIES, transientProperties),
                               added(EXTRA_PROPERTIES, extraProperties));
      }

    /***************************************************************************
     *
     **************************************************************************/
    @Nonnull
    private static List added (@Nonnull final List s1,
                                       @Nonnull final List s2)
      {
        final List result = new ArrayList();
        result.addAll(s1);
        result.addAll(s2);

        return result;
      }

    /***************************************************************************
     *
     **************************************************************************/
    @Nonnull
    private static Object[][] added (@Nonnull final Object[][] a1,
                                     @Nonnull final Object[][] a2)
      {
        final List result = new ArrayList();
        result.addAll(Arrays.asList(a1));
        result.addAll(Arrays.asList(a2));

        return result.toArray(new Object[0][0]);
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy