
it.tidalwave.metadata.MetadataItemFormat 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: MetadataItemFormat.java,v d60681e7fc1d 2009/09/17 23:59:23 fabrizio $
*
******************************************************************************/
package it.tidalwave.metadata;
import java.text.ParseException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.openide.util.Lookup;
/*******************************************************************************
*
* This class provides formatting and parsing capabilities for a given metadata
* item.
*
*
* MetadataItemFormat itemFormat = MetadataItemFormat.Locator.findMetadataItemFormat();
* String displayName = itemFormat.getItemDisplayName(EXIF.class); // e.g. returns "EXIF"
* String aperture = itemFormat.getPropertyDisplayName(EXIF.class, "exposureTime"); // e.g. returns "Shutter Time"
* String s = itemFormat.format(EXIF.class, "exposureTime", new Rational(1, 200)); // e.g. returns "1/200 sec"
* Rational r = itemFormat.parse(EXIF.class, "exposureTime", "1/200 sec")); // e.g. returns new Rational(1,200)
*
*
* @author Fabrizio Giudici
* @version $Id: MetadataItemFormat.java,v d60681e7fc1d 2009/09/17 23:59:23 fabrizio $
*
******************************************************************************/
public interface MetadataItemFormat
{
/***************************************************************************
*
* Returns the display name for the given type of metadata item.
*
* @param itemClass the type of the metadata item
* @return the display name of the item
*
**************************************************************************/
@Nonnull
public String getItemDisplayName (@Nonnull Class> itemClass);
/***************************************************************************
*
* Returns the display name of a property of the given metadata item.
*
* @param itemClass the type of the metadata item
* @param propertyName the name of the property
* @return the formatted value
*
**************************************************************************/
@Nonnull
public String getPropertyDisplayName (@Nonnull Class> itemClass, @Nonnull String propertyName);
/***************************************************************************
*
* Formats a property value of the given metadata item.
*
* @param itemClass the type of the metadata item
* @param propertyName the name of the property
* @param value the value of the property
* @return the formatted value
*
**************************************************************************/
@Nonnull
public String format (@Nonnull Class> itemClass,
@Nonnull String propertyName,
@CheckForNull Object value);
/***************************************************************************
*
* Parses a property value of the given metadata item.
*
* @param itemClass the type of the metadata item
* @param propertyName the name of the property
* @param string the string form of the property
* @return the parsed value
*
**************************************************************************/
@CheckForNull
public T parse (@Nonnull Class> itemClass,
@Nonnull String propertyName,
@CheckForNull String string)
throws ParseException;
/***************************************************************************
*
* The service locator for {@link MetadataItemFormat}.
*
* @hidden
*
**************************************************************************/
public final static class Locator
{
private Locator()
{
}
@Nonnull
public final static MetadataItemFormat findMetadataItemFormat()
{
final MetadataItemFormat metadataItemFormat = Lookup.getDefault().lookup(MetadataItemFormat.class);
if (metadataItemFormat == null)
{
throw new RuntimeException("metadataItemFormat not found");
}
return metadataItemFormat;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy