Class LinkModel

  • All Implemented Interfaces:
    java.lang.Comparable

    public class LinkModel
    extends java.lang.Object
    implements java.lang.Comparable
    An bean which represents an URL link. Text, URL and visited are bound properties. Compares by Text.
    • Constructor Summary

      Constructors 
      Constructor Description
      LinkModel()  
      LinkModel​(java.lang.String text)  
      LinkModel​(java.lang.String text, java.lang.String target, java.lang.String template, java.lang.String[] args)  
      LinkModel​(java.lang.String text, java.lang.String target, java.net.URL url)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener l)  
      int compareTo​(java.lang.Object obj)  
      private java.net.URL createURL​(java.lang.String template, java.lang.String[] args)
      Create a URL from a template string that has place holders and an array of strings which will be substituted into the place holders.
      boolean equals​(java.lang.Object obj)  
      protected void firePropertyChange​(java.lang.String property, boolean oldValue, boolean newValue)  
      protected void firePropertyChange​(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)  
      private java.net.URL getDefaultURL()  
      private java.beans.PropertyChangeSupport getPropertyChangeSupport()  
      java.lang.String getTarget()
      Return the target for the URL.
      java.lang.String getText()  
      java.net.URL getURL()  
      boolean getVisited()  
      int hashCode()  
      void removePropertyChangeListener​(java.beans.PropertyChangeListener l)  
      void setTarget​(java.lang.String target)
      Set the target that the URL should load into.
      void setText​(java.lang.String text)
      Set the display text.
      void setURL​(java.net.URL url)
      Set the url and resets the visited flag.
      void setURLString​(java.lang.String howToURLString)  
      void setVisited​(boolean visited)
      Sets a flag to indicate if the link has been visited.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final java.util.logging.Logger LOG
      • text

        private java.lang.String text
      • url

        private java.net.URL url
      • target

        private java.lang.String target
      • visited

        private boolean visited
      • propertyChangeSupport

        private java.beans.PropertyChangeSupport propertyChangeSupport
      • VISITED_PROPERTY

        public static final java.lang.String VISITED_PROPERTY
        See Also:
        Constant Field Values
      • defaultURLString

        private static java.lang.String defaultURLString
      • defaultURL

        private static java.net.URL defaultURL
    • Constructor Detail

      • LinkModel

        public LinkModel​(java.lang.String text,
                         java.lang.String target,
                         java.net.URL url)
        Parameters:
        text -
        target -
        url -
      • LinkModel

        public LinkModel()
      • LinkModel

        public LinkModel​(java.lang.String text)
      • LinkModel

        public LinkModel​(java.lang.String text,
                         java.lang.String target,
                         java.lang.String template,
                         java.lang.String[] args)
        Parameters:
        text - text to that a renderer would display
        target - the target that a URL should load into.
        template - a string that represents a URL with &{N} place holders for string substitution
        args - an array of strings which will be used for substitition
    • Method Detail

      • setText

        public void setText​(java.lang.String text)
        Set the display text.
      • getText

        public java.lang.String getText()
      • setURLString

        public void setURLString​(java.lang.String howToURLString)
      • getDefaultURL

        private java.net.URL getDefaultURL()
      • setURL

        public void setURL​(java.net.URL url)
        Set the url and resets the visited flag. Think: keep list of visited urls here?
      • getURL

        public java.net.URL getURL()
      • createURL

        private java.net.URL createURL​(java.lang.String template,
                                       java.lang.String[] args)
        Create a URL from a template string that has place holders and an array of strings which will be substituted into the place holders. The place holders are represented as
        Parameters:
        template - a url string that contains the placeholders
        args - an array of strings that will be substituted
      • setTarget

        public void setTarget​(java.lang.String target)
        Set the target that the URL should load into. This can be a uri representing another control or the name of a window or special targets. See: http://www.w3c.org/TR/html401/present/frames.html#adef-target
      • getTarget

        public java.lang.String getTarget()
        Return the target for the URL.
        Returns:
        value of the target. If null then "_blank" will be returned.
      • setVisited

        public void setVisited​(boolean visited)
        Sets a flag to indicate if the link has been visited. The state of this flag can be used to render the color of the link.
      • getVisited

        public boolean getVisited()
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener l)
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener l)
      • firePropertyChange

        protected void firePropertyChange​(java.lang.String property,
                                          java.lang.Object oldValue,
                                          java.lang.Object newValue)
      • firePropertyChange

        protected void firePropertyChange​(java.lang.String property,
                                          boolean oldValue,
                                          boolean newValue)
      • getPropertyChangeSupport

        private java.beans.PropertyChangeSupport getPropertyChangeSupport()
      • compareTo

        public int compareTo​(java.lang.Object obj)
        Specified by:
        compareTo in interface java.lang.Comparable
      • 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