Class MetadataSource

  • Direct Known Subclasses:
    MetadataSource.ThreadedMetadataSource

    public class MetadataSource
    extends java.lang.Object
    An object that can determine metadata for one or more file types. Note that if appliesTo(ca.cgjennings.apps.arkham.project.Member) returns false for a given member, then the result of passing that member to any other method is undefined.

    A typical metadata source is shared between many different members, and may even represent more than one type of file. For this reason, methods that query metadata require you to pass in the specific member for which the data is desired.

    Since:
    2.1
    Author:
    Chris Jennings
    • Field Detail

      • ICON_PROJECT

        public static final javax.swing.Icon ICON_PROJECT
      • ICON_FOLDER

        public static final javax.swing.Icon ICON_FOLDER
      • ICON_FILE

        public static final javax.swing.Icon ICON_FILE
      • ICON_IMAGE

        public static final javax.swing.Icon ICON_IMAGE
      • ICON_VECTOR_IMAGE

        public static final javax.swing.Icon ICON_VECTOR_IMAGE
      • ICON_JAVA

        public static final javax.swing.Icon ICON_JAVA
      • ICON_SCRIPT

        public static final javax.swing.Icon ICON_SCRIPT
      • ICON_AUTOMATION_SCRIPT

        public static final javax.swing.Icon ICON_AUTOMATION_SCRIPT
      • ICON_TYPESCRIPT

        public static final javax.swing.Icon ICON_TYPESCRIPT
      • ICON_SETTINGS

        public static final javax.swing.Icon ICON_SETTINGS
      • ICON_PROPERTIES

        public static final javax.swing.Icon ICON_PROPERTIES
      • ICON_COLLECTION

        public static final javax.swing.Icon ICON_COLLECTION
      • ICON_TABLE

        public static final javax.swing.Icon ICON_TABLE
      • ICON_HTML

        public static final javax.swing.Icon ICON_HTML
      • ICON_MARKDOWN

        public static final javax.swing.Icon ICON_MARKDOWN
      • ICON_STYLE_SHEET

        public static final javax.swing.Icon ICON_STYLE_SHEET
      • ICON_PLUGIN_ROOT

        public static final javax.swing.Icon ICON_PLUGIN_ROOT
      • ICON_CLASS

        public static final javax.swing.Icon ICON_CLASS
      • ICON_BLANK

        public static final javax.swing.Icon ICON_BLANK
      • ICON_COPIES_LIST

        public static final javax.swing.Icon ICON_COPIES_LIST
      • ICON_DOCUMENT

        public static final javax.swing.Icon ICON_DOCUMENT
      • ICON_FONT

        public static final javax.swing.Icon ICON_FONT
      • ICON_EON_DEFAULT

        public static final javax.swing.Icon ICON_EON_DEFAULT
      • ICON_EON_PLUGIN

        public static final javax.swing.Icon ICON_EON_PLUGIN
      • ICON_EON_EXTENSION

        public static final javax.swing.Icon ICON_EON_EXTENSION
      • ICON_EON_THEME

        public static final javax.swing.Icon ICON_EON_THEME
      • ICON_EON_LIBRARY

        public static final javax.swing.Icon ICON_EON_LIBRARY
      • ICON_PACKED_BUNDLE

        public static final javax.swing.Icon ICON_PACKED_BUNDLE
      • ICON_CLASS_MAP

        public static final javax.swing.Icon ICON_CLASS_MAP
      • ICON_CONVERSION_MAP

        public static final javax.swing.Icon ICON_CONVERSION_MAP
      • ICON_SILHOUETTES

        public static final javax.swing.Icon ICON_SILHOUETTES
      • ICON_TILE_SET

        public static final javax.swing.Icon ICON_TILE_SET
      • ICON_CARD_LAYOUT

        public static final javax.swing.Icon ICON_CARD_LAYOUT
      • ICON_DICT_CPL

        public static final javax.swing.Icon ICON_DICT_CPL
      • ICON_DICT_TST

        public static final javax.swing.Icon ICON_DICT_TST
      • ICON_TEXT_INDEX

        public static final javax.swing.Icon ICON_TEXT_INDEX
      • ICON_TASK

        public static final javax.swing.Icon ICON_TASK
      • ICON_TASK_PLUGIN

        public static final javax.swing.Icon ICON_TASK_PLUGIN
      • ICON_TASK_FACTORY

        public static final javax.swing.Icon ICON_TASK_FACTORY
      • ICON_TASK_EXPBOARD

        public static final javax.swing.Icon ICON_TASK_EXPBOARD
      • ICON_TASK_CASEBOOK

        public static final javax.swing.Icon ICON_TASK_CASEBOOK
      • ICON_TASK_DECK

        public static final javax.swing.Icon ICON_TASK_DECK
      • ICON_TASK_DOCUMENTATION

        public static final javax.swing.Icon ICON_TASK_DOCUMENTATION
      • ICON_TASK_GROUP

        public static final javax.swing.Icon ICON_TASK_GROUP
    • Constructor Detail

      • MetadataSource

        public MetadataSource()
    • Method Detail

      • appliesTo

        public boolean appliesTo​(Member m)
        Returns true if this source is intended to provide metadata for a given project member. The base class returns true for anything, as it provides the fallback implementation for unspecialized file types.
        Parameters:
        m - the member to check for applicability
        Returns:
        true if this source can provide metadata about the specified member, otherwise false
      • getSpecificInstanceFor

        public MetadataSource getSpecificInstanceFor​(Member m)
        After locating the correct source for a given member, a specific instance is requested by calling this method. The base class simply returns this, which shares the source with all members that it applies to. Subclasses may return an instance that is unique to a particular member. For example, they might supply a unique icon that is a thumbnail version of the member.
        Parameters:
        m - the member to request a more specific source for
        Returns:
        a source that provides the most specific available data for m, possibly this
        Throws:
        java.lang.IllegalArgumentException - if this source does not apply to m
      • getDescription

        public java.lang.String getDescription​(Member m)
        Returns a short description of the type of file represented by the specified member.
        Parameters:
        m - the member to fetch a description of
        Returns:
        a short description of m, typically 2-3 words
      • getIcon

        public ThemedIcon getIcon​(Member m)
        Return an icon that is appropriate for a particular member. Override this to provide a suitable icon for the file type.

        The base implementation provides built-in icons for certain common file types, and otherwise attempts to fetch the system icon for the file type.

        Parameters:
        m - the member to locate an icon for
        Returns:
        an icon appropriate for m
      • fillInMetadataImpl

        protected void fillInMetadataImpl​(Member m,
                                          MetadataSource.PropertyConsumer pc)
        Called to publish metadata to a consumer. The base class will publish basic metadata including the file type description. Classes that override the default implementation should call the super implementation first to fill in this basic information.
        Parameters:
        m - the member to publish metadata about
        pc - the consumer to publish metadata to
      • thumbnail

        protected static javax.swing.ImageIcon thumbnail​(java.awt.image.BufferedImage image)
        Creates a thumbnail version of an image.
        Parameters:
        image - the source image to convert to a thumbnail
        Returns:
        if the source image is small, the source image; otherwise a smaller thumbnail version of the source image
      • getDefaultCharset

        public java.nio.charset.Charset getDefaultCharset​(Member m)
        Returns a character set encoding for the specified member if it represents a character-based file. If it is not, then this method returns null.
        Parameters:
        m - a member to obtain a character set for
        Returns:
        the character set to use when reading the member as a character stream, or null if the member is not a kind of text file known to this source