Class SourceEntry

  • Direct Known Subclasses:
    ExtendedSourceEntry, StyleSource

    public class SourceEntry
    extends java.lang.Object
    A source entry primarily used to save the user's selection of mappaint styles, but also for preset sources or validator rules.
    Since:
    12649 (moved from gui.preferences package), 3796
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean active
      active is a boolean flag that can be used to turn the source on or off at runtime.
      boolean isZip
      Indicates, that url is a zip file and the resource is inside the zip file.
      java.lang.String name
      Name is used as a namespace for color preferences and (currently) only one file with a name can be loaded at a time.
      java.lang.String title
      A title that can be used as menu entry.
      SourceType type
      The type of source entry.
      java.lang.String url
      A URL can be anything that CachedFile understands, i.e.
      java.lang.String zipEntryPath
      If isZip is true, denotes the path inside the zip file.
    • Constructor Summary

      Constructors 
      Constructor Description
      SourceEntry​(SourceEntry e)
      Constructs a new SourceEntry.
      SourceEntry​(SourceType type, java.lang.String url, boolean isZip, java.lang.String zipEntryPath, java.lang.String name, java.lang.String title, boolean active)
      Constructs a new SourceEntry.
      SourceEntry​(SourceType type, java.lang.String url, java.lang.String name, java.lang.String title, boolean active)
      Constructs a new SourceEntry.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getDisplayString()
      String to show in menus and error messages.
      java.lang.String getFileNamePart()
      Extracts file part from url, e.g.: http://www.test.com/file.xml?format=text → file.xml
      java.io.File getLocalSourceDir()
      Return the source directory, only for local files.
      java.lang.String getPrefName()
      the name / identifier that should be used to save custom color values and similar stuff to the preference file
      java.lang.String getZipEntryDirName()
      Returns the parent directory of the resource inside the zip file.
      int hashCode()  
      boolean isLocal()
      Determines if this source denotes a file on a local filesystem.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • type

        public final SourceType type
        The type of source entry.
        Since:
        12825
      • url

        public java.lang.String url
        A URL can be anything that CachedFile understands, i.e. a local file, http://, or a file from the current jar
      • isZip

        public boolean isZip
        Indicates, that url is a zip file and the resource is inside the zip file.
      • zipEntryPath

        public java.lang.String zipEntryPath
        If isZip is true, denotes the path inside the zip file.
      • name

        public java.lang.String name
        Name is used as a namespace for color preferences and (currently) only one file with a name can be loaded at a time. Additional styles must either have the same name as the main style or no name at all. If no name is provided, it will be set to the default value "standard". The name can also be given in the xml file as attribute for the rules tag. (This overrides the name given in the preferences, otherwise both methods are equivalent.)
      • title

        public java.lang.String title
        A title that can be used as menu entry.
      • active

        public boolean active
        active is a boolean flag that can be used to turn the source on or off at runtime.
    • Constructor Detail

      • SourceEntry

        public SourceEntry​(SourceType type,
                           java.lang.String url,
                           boolean isZip,
                           java.lang.String zipEntryPath,
                           java.lang.String name,
                           java.lang.String title,
                           boolean active)
        Constructs a new SourceEntry.
        Parameters:
        type - type of source entry
        url - URL that CachedFile understands
        isZip - if url is a zip file and the resource is inside the zip file
        zipEntryPath - If isZip is true, denotes the path inside the zip file
        name - Source name
        title - title that can be used as menu entry
        active - boolean flag that can be used to turn the source on or off at runtime
        Since:
        12825
        See Also:
        url, isZip, zipEntryPath, name, title, active
      • SourceEntry

        public SourceEntry​(SourceType type,
                           java.lang.String url,
                           java.lang.String name,
                           java.lang.String title,
                           boolean active)
        Constructs a new SourceEntry.
        Parameters:
        type - type of source entry
        url - URL that CachedFile understands
        name - Source name
        title - title that can be used as menu entry
        active - boolean flag that can be used to turn the source on or off at runtime
        Since:
        12825
        See Also:
        url, name, title, active
      • SourceEntry

        public SourceEntry​(SourceEntry e)
        Constructs a new SourceEntry.
        Parameters:
        e - existing source entry to copy
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getDisplayString

        public java.lang.String getDisplayString()
        String to show in menus and error messages.
        Returns:
        Usually the shortdescription, but can be the file name if no shortdescription is available.
      • getFileNamePart

        public java.lang.String getFileNamePart()
        Extracts file part from url, e.g.: http://www.test.com/file.xml?format=text → file.xml
        Returns:
        The filename part of the URL
      • getPrefName

        public java.lang.String getPrefName()
        the name / identifier that should be used to save custom color values and similar stuff to the preference file
        Returns:
        the identifier; never null. Usually the result is "standard"
      • isLocal

        public boolean isLocal()
        Determines if this source denotes a file on a local filesystem.
        Returns:
        true if the source is a local file
      • getLocalSourceDir

        public java.io.File getLocalSourceDir()
        Return the source directory, only for local files.
        Returns:
        The source directory, or null if this file isn't local, or does not have a parent
        Since:
        7276
      • getZipEntryDirName

        public java.lang.String getZipEntryDirName()
        Returns the parent directory of the resource inside the zip file.
        Returns:
        the parent directory of the resource inside the zip file, "." if zipEntryPath is a top level file; null, if zipEntryPath is null