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

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

/*******************************************************************************
 *
 * blueMarine - open source photo workflow
 * =======================================
 *
 * Copyright (C) 2003-2009 by Fabrizio Giudici
 * Project home page: http://bluemarine.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. 
 *
 *******************************************************************************
 *
 * $Id: TIFFBasedBeanAccessor.java,v d7e8fed5e750 2009/09/17 23:55:58 fabrizio $
 *
 ******************************************************************************/
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: TIFFBasedBeanAccessor.java,v d7e8fed5e750 2009/09/17 23:55:58 fabrizio $
 *
 ******************************************************************************/
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