Class SourceEntry
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.sources.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 booleanactiveactive is a boolean flag that can be used to turn the source on or off at runtime.booleanisZipIndicates, thaturlis a zip file and the resource is inside the zip file.java.lang.StringnameName is used as a namespace for color preferences and (currently) only one file with a name can be loaded at a time.java.lang.StringtitleA title that can be used as menu entry.SourceTypetypeThe type of source entry.java.lang.StringurlA URL can be anything that CachedFile understands, i.e.java.lang.StringzipEntryPathIfisZipis true, denotes the path inside the zip file.
-
Constructor Summary
Constructors Constructor Description SourceEntry(SourceEntry e)Constructs a newSourceEntry.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 newSourceEntry.SourceEntry(SourceType type, java.lang.String url, java.lang.String name, java.lang.String title, boolean active)Constructs a newSourceEntry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetDisplayString()String to show in menus and error messages.java.lang.StringgetFileNamePart()Extracts file part from url, e.g.:http://www.test.com/file.xml?format=text → file.xmljava.io.FilegetLocalSourceDir()Return the source directory, only for local files.java.lang.StringgetPrefName()the name / identifier that should be used to save custom color values and similar stuff to the preference filejava.lang.StringgetZipEntryDirName()Returns the parent directory of the resource inside the zip file.inthashCode()booleanisLocal()Determines if this source denotes a file on a local filesystem.java.lang.StringtoString()
-
-
-
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, thaturlis a zip file and the resource is inside the zip file.
-
zipEntryPath
public java.lang.String zipEntryPath
IfisZipis 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 newSourceEntry.- Parameters:
type- type of source entryurl- URL thatCachedFileunderstandsisZip- if url is a zip file and the resource is inside the zip filezipEntryPath- IfisZipistrue, denotes the path inside the zip filename- Source nametitle- title that can be used as menu entryactive- 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 newSourceEntry.- Parameters:
type- type of source entryurl- URL thatCachedFileunderstandsname- Source nametitle- title that can be used as menu entryactive- 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 newSourceEntry.- Parameters:
e- existing source entry to copy
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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:
trueif 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
nullif 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
-
-