java.lang.Object
org.openstreetmap.josm.data.preferences.sources.SourceEntry
Direct Known Subclasses:
ExtendedSourceEntry, StyleSource

public class SourceEntry extends 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 Details

    • type

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

      public 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

      If isZip is true, denotes the path inside the zip file.
    • name

      public 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 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 Details

    • SourceEntry

      public SourceEntry(SourceType type, String url, boolean isZip, String zipEntryPath, String name, 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:
    • SourceEntry

      public SourceEntry(SourceType type, String url, String name, 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:
    • SourceEntry

      Constructs a new SourceEntry.
      Parameters:
      e - existing source entry to copy
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object
    • 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

      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 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

      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

      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