Class Tag2Link


  • public final class Tag2Link
    extends java.lang.Object
    Extracts web links from OSM tags.

    The following rules are used:

    • internal rules for basic tags
    • rules from Wikidata based on OSM tag or key (P1282); formatter URL (P1630); third-party formatter URL (P3303)
    • rules from OSM Sophox based on permanent key ID (P16); formatter URL (P8)
    Since:
    15673
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  Tag2Link.LinkConsumer
      Represents an operation that accepts a link.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String languagePattern  
      private static java.util.regex.Pattern PATTERN_DOLLAR_ONE  
      (package private) static CachingProperty<java.util.List<java.lang.String>> PREF_SEARCH_ENGINES  
      (package private) static ListProperty PREF_SOURCE  
      (package private) static java.util.Map<java.lang.String,​java.util.function.UnaryOperator<java.lang.String>> valueFormatter  
      (package private) static MultiMap<java.lang.String,​java.lang.String> wikidataRules
      Maps OSM keys to formatter URLs from Wikidata and OSM Sophox where "$1" has to be replaced by a value.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Tag2Link()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String getHost​(java.lang.String url, java.lang.String fallback)  
      private static java.lang.String getLinkName​(java.lang.String url, java.lang.String fallback)  
      static void getLinksForTag​(java.lang.String key, java.lang.String value, Tag2Link.LinkConsumer linkConsumer)
      Generates the links for the tag given by key and value, and sends 0, 1 or more links to the linkConsumer.
      private static java.lang.String getWikimediaCommonsUrl​(java.lang.String i)  
      static void initialize()
      Initializes the tag2link rules
      private static void initializeFromResources​(CachedFile resource)
      Initializes the tag2link rules from the resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • initialize

        public static void initialize()
        Initializes the tag2link rules
      • initializeFromResources

        private static void initializeFromResources​(CachedFile resource)
                                             throws java.io.IOException
        Initializes the tag2link rules from the resources.
        Parameters:
        resource - the source
        Throws:
        java.io.IOException - in case of I/O error
      • getLinksForTag

        public static void getLinksForTag​(java.lang.String key,
                                          java.lang.String value,
                                          Tag2Link.LinkConsumer linkConsumer)
        Generates the links for the tag given by key and value, and sends 0, 1 or more links to the linkConsumer.
        Parameters:
        key - the tag key
        value - the tag value
        linkConsumer - the receiver of the generated links
      • getLinkName

        private static java.lang.String getLinkName​(java.lang.String url,
                                                    java.lang.String fallback)
      • getHost

        private static java.lang.String getHost​(java.lang.String url,
                                                java.lang.String fallback)