Package it.tidalwave.image.metadata
Class Directory
- java.lang.Object
-
- it.tidalwave.image.metadata.JavaBeanSupport
-
- it.tidalwave.image.metadata.Directory
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
it.tidalwave.image.metadata.EXIFDirectoryGenerated,it.tidalwave.image.metadata.IPTCDirectoryGenerated,MakerNote,XMP
public class Directory extends JavaBeanSupport implements java.io.Serializable
This class provides basic support for all kinds of metadata such EXIF, IPTC or maker notes.- Author:
- Fabrizio Giudici
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDirectory.Tag<T>A descriptor for a tag.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,Directory.Tag>tagMapByCode-
Fields inherited from class it.tidalwave.image.metadata.JavaBeanSupport
pcs, vetoableChangeSupport
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(int code)Verifies if a value is present.booleanequals(java.lang.Object object)voidforEachTag(java.util.function.BiConsumer<Directory.Tag<?>,java.lang.Object> action)Iterates through all the tags and related raw values calling the provided action.voidforEachTag(java.util.function.Consumer<Directory.Tag<?>> action)Iterates through all the tags calling the provided action.voidforEachTagCode(java.util.function.IntConsumer action)Iterates through all the tag codes calling the provided action.protected static java.lang.StringformatDateTime(java.time.Instant date)<T> java.util.Optional<T>get(int code, java.lang.Class<T> asType)Returns a value given its tag.<T> java.util.Optional<T>get(Directory.Tag<T> tag)Returns a value given its tag.<T,U>
java.util.Optional<T>get(Directory.Tag<U> tag, java.lang.Class<T> asType)Returns a value given its tag.java.time.InstantgetLatestModificationTime()Returns the latest modification time of this object.java.lang.ObjectgetRaw(int code)Returns a value given its tag code.java.util.Optional<Directory>getSubDirectory(java.lang.String name)Returns a subdirectory given its name.java.util.Set<java.lang.String>getSubDirectoryNames()Returns the names of the available subdirectories.int[]getTagCodes()Returns the tag codes contained in this directory, sorted by code.java.util.Optional<Directory.Tag<?>>getTagInfo(int tag)Returns information about a tag.Directory.Tag[]getTags()Returns the tags contained in this directory.inthashCode()booleanisEmpty()Checks whether this directory is empty.protected booleanisSubClass(java.lang.Class aClass, java.lang.String ancestorClassName)voidload(DirectoryLoader loader)Loads tags and subdirectories from the given loader.protected static java.time.InstantparseDateTime(java.lang.String string)voidremove(int code)Removes a value.voidset(Directory.Tag<?> tag, java.lang.Object value)Sets a value for a tag.voidsetRaw(int code, java.lang.Object value)Sets a raw value, that is without converting any type.java.lang.StringtoHexString(Rational[] array)java.lang.StringtoString()protected voidtouch()-
Methods inherited from class it.tidalwave.image.metadata.JavaBeanSupport
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Field Detail
-
tagMapByCode
protected static final java.util.Map<java.lang.String,Directory.Tag> tagMapByCode
-
-
Method Detail
-
get
@Nonnull public <T> java.util.Optional<T> get(@Nonnull Directory.Tag<T> tag)Returns a value given its tag. The result is converted to the standard type of the tag (e.g. an enum).- Type Parameters:
T- the static type of the tag- Parameters:
tag- the tag to retrieve- Returns:
- the value
-
get
@Nonnull public <T,U> java.util.Optional<T> get(@Nonnull Directory.Tag<U> tag, @Nonnull java.lang.Class<T> asType)Returns a value given its tag. The result is converted to the specified type, is possible.- Type Parameters:
U- the static type of the tagT- the static type of the type to convert- Parameters:
tag- the tag to retrieveasType- the type to convert the value into- Returns:
- the value
-
get
@Nonnull public <T> java.util.Optional<T> get(@Nonnegative int code, @Nonnull java.lang.Class<T> asType)Returns a value given its tag. The result is converted to the specified type, is possible.- Type Parameters:
T- the static type of the type to convert- Parameters:
code- the code of the tag to retrieveasType- the type to convert the value into- Returns:
- the value
-
getRaw
@CheckForNull public java.lang.Object getRaw(@Nonnegative int code)Returns a value given its tag code. No type conversion is applied.- Parameters:
code- the code of the tag to retrieve- Returns:
- the value (can be null)
-
set
public void set(@Nonnull Directory.Tag<?> tag, java.lang.Object value)Sets a value for a tag.nullandOptionalare accepted and eventually unpacked: passingnullor an emptyOptionalis equivalent to a call toremove(int). If the value is different from the previous one, events are fired:the property nameemptylatestModificationTime
- Parameters:
tag- the tag to retrievevalue- the new value
-
setRaw
public void setRaw(@Nonnegative int code, java.lang.Object value)Sets a raw value, that is without converting any type.nullandOptionalare accepted and eventually unpacked: passingnullor an emptyOptionalis equivalent to a call toremove(int). This method does not fire events.- Parameters:
code- the code of the tag to setvalue- the value
-
contains
public boolean contains(@Nonnegative int code)Verifies if a value is present.- Parameters:
code- the code of the tag- Returns:
- if the value is present
-
remove
public void remove(@Nonnegative int code)Removes a value. This method does not fire events.- Parameters:
code- the code of the tag to remove
-
getTagInfo
@Nonnull public java.util.Optional<Directory.Tag<?>> getTagInfo(@Nonnegative int tag)
Returns information about a tag.- Parameters:
tag- the tag code- Returns:
- the tag info
-
getTagCodes
@Nonnull public int[] getTagCodes()
Returns the tag codes contained in this directory, sorted by code.- Returns:
- the tag codes
-
getTags
@Nonnull public Directory.Tag[] getTags()
Returns the tags contained in this directory. Tags are sorted by code.- Returns:
- the tags
-
forEachTag
public void forEachTag(@Nonnull java.util.function.Consumer<Directory.Tag<?>> action)Iterates through all the tags calling the provided action.- Parameters:
action- the action to call
-
forEachTag
public void forEachTag(@Nonnull java.util.function.BiConsumer<Directory.Tag<?>,java.lang.Object> action)Iterates through all the tags and related raw values calling the provided action.- Parameters:
action- the action to call
-
forEachTagCode
public void forEachTagCode(@Nonnull java.util.function.IntConsumer action)Iterates through all the tag codes calling the provided action.- Parameters:
action- the action to call
-
isEmpty
public boolean isEmpty()
Checks whether this directory is empty.- Returns:
trueif this directory doesn't contain any tag
-
getSubDirectoryNames
@Nonnull public java.util.Set<java.lang.String> getSubDirectoryNames()
Returns the names of the available subdirectories.- Returns:
- the names of subdirectories
-
getSubDirectory
@Nonnull public java.util.Optional<Directory> getSubDirectory(@Nonnull java.lang.String name)
Returns a subdirectory given its name.- Parameters:
name- the name of the subdirectory- Returns:
- the subdirectory
-
getLatestModificationTime
@Nonnull public java.time.Instant getLatestModificationTime()
Returns the latest modification time of this object.- Returns:
- the latest modification time
-
load
public void load(@Nonnull DirectoryLoader loader)Loads tags and subdirectories from the given loader.
-
equals
public final boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
toString
@Nonnull public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
touch
protected void touch()
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toHexString
@Nonnull public java.lang.String toHexString(@Nonnull Rational[] array)- Parameters:
array-- Returns:
-
isSubClass
protected boolean isSubClass(@Nonnull java.lang.Class aClass, @Nonnull java.lang.String ancestorClassName)- Returns:
-
formatDateTime
protected static java.lang.String formatDateTime(java.time.Instant date)
-
parseDateTime
protected static java.time.Instant parseDateTime(java.lang.String string)
-
-