# SiteMapURL (Crawler-commons 1.4 API)

Package crawlercommons.sitemaps

## Class SiteMapURL

- java.lang.Object
- - crawlercommons.sitemaps.SiteMapURL

All Implemented Interfaces:
  `Serializable`

    public class SiteMapURL
    extends Object
    implements Serializable

The SitemapUrl class represents a URL found in a Sitemap.

Author:
  fmccown
See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `SiteMapURL.ChangeFrequency` Allowed change frequencies

### Field Summary

Fields
`static double` `DEFAULT_PRIORITY`

### Constructor Summary

Constructors
`SiteMapURL​(String url, boolean valid)`
`SiteMapURL​(String url, String lastModified, String changeFreq, String priority, boolean valid)`
`SiteMapURL​(URL url, boolean valid)`
`SiteMapURL​(URL url, ZonedDateTime lastModified, SiteMapURL.ChangeFrequency changeFreq, double priority, boolean valid)`
`SiteMapURL​(URL url, Date lastModified, SiteMapURL.ChangeFrequency changeFreq, double priority, boolean valid)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addAttributesForExtension​(Extension extension, ExtensionMetadata[] attributes)` Add attributes of a specific sitemap extension
`boolean` `equals​(Object o)`
`Map<Extension,​ExtensionMetadata[]>` `getAttributes()` Get attributes of sitemap extensions (news, images, videos, etc.)
`ExtensionMetadata[]` `getAttributesForExtension​(Extension extension)` Get attributes of a specific sitemap extension
`SiteMapURL.ChangeFrequency` `getChangeFrequency()` Return the URL's change frequency
`Date` `getLastModified()` Return when this URL was last modified.
`double` `getPriority()` Return this URL's priority (a value between [0.0 - 1.0]).
`URL` `getUrl()` Return the URL.
`int` `hashCode()`
`boolean` `isValid()` Is the siteMapURL under the base url ?
`void` `setChangeFrequency​(SiteMapURL.ChangeFrequency changeFreq)` Set the URL's change frequency
`void` `setChangeFrequency​(String changeFreq)` Set the URL's change frequency In case of a bad ChangeFrequency, the current frequency in this instance will be set to NULL
`void` `setLastModified​(String lastModified)` Set when this URL was last modified.
`void` `setLastModified​(ZonedDateTime lastModified)` Set when this URL was last modified.
`void` `setLastModified​(Date lastModified)` Set when this URL was last modified.
`void` `setPriority​(double priority)` Set the URL's priority to a value between [0.0 - 1.0] (Default Priority is used if the given priority is out of range).
`void` `setPriority​(String priorityStr)` Set the URL's priority to a value between [0.0 - 1.0] (Default Priority is used if the given priority missing or is out of range).
`void` `setUrl​(String url)` Set the URL.
`void` `setUrl​(URL url)` Set the URL.
`void` `setValid​(boolean valid)` Valid means that it follows the official guidelines that the siteMapURL must be under the base url
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DEFAULT_PRIORITY

    public static final double DEFAULT_PRIORITY

See Also:
  Constant Field Values

### Constructor Detail

#### SiteMapURL

    public SiteMapURL​(String url,
                      boolean valid)

#### SiteMapURL

    public SiteMapURL​(URL url,
                      boolean valid)

#### SiteMapURL

    public SiteMapURL​(String url,
                      String lastModified,
                      String changeFreq,
                      String priority,
                      boolean valid)

#### SiteMapURL

    public SiteMapURL​(URL url,
                      Date lastModified,
                      SiteMapURL.ChangeFrequency changeFreq,
                      double priority,
                      boolean valid)

#### SiteMapURL

    public SiteMapURL​(URL url,
                      ZonedDateTime lastModified,
                      SiteMapURL.ChangeFrequency changeFreq,
                      double priority,
                      boolean valid)

### Method Detail

#### getUrl

    public URL getUrl()

Return the URL.

Returns:
  URL

#### setUrl

    public void setUrl​(URL url)

Set the URL.

Parameters:
  `url` - of the sitemap

#### setUrl

    public void setUrl​(String url)

Set the URL.

Parameters:
  `url` - In case of Malformed URL, the current url in this instance will be set to NULL

#### getLastModified

    public Date getLastModified()

Return when this URL was last modified.

Returns:
  last modified date

#### setLastModified

    public void setLastModified​(String lastModified)

Set when this URL was last modified.

Parameters:
  `lastModified` - lastmod specified for the URL

#### setLastModified

    public void setLastModified​(Date lastModified)

Set when this URL was last modified.

Parameters:
  `lastModified` - lastmod specified for the URL

#### setLastModified

    public void setLastModified​(ZonedDateTime lastModified)

Set when this URL was last modified.

Parameters:
  `lastModified` - lastmod specified for the URL

#### getPriority

    public double getPriority()

Return this URL's priority (a value between [0.0 - 1.0]).

Returns:
  URL's priority (a value between [0.0 - 1.0])

#### setPriority

    public void setPriority​(double priority)

Set the URL's priority to a value between [0.0 - 1.0] (Default Priority is used if the given priority is out of range).

Parameters:
  `priority` - a value between [0.0 - 1.0]

#### setPriority

    public void setPriority​(String priorityStr)

Set the URL's priority to a value between [0.0 - 1.0] (Default Priority is used if the given priority missing or is out of range).

Parameters:
  `priorityStr` - a value between [0.0 - 1.0]

#### getChangeFrequency

    public SiteMapURL.ChangeFrequency getChangeFrequency()

Return the URL's change frequency

Returns:
  the URL's change frequency

#### setChangeFrequency

    public void setChangeFrequency​(SiteMapURL.ChangeFrequency changeFreq)

Set the URL's change frequency

Parameters:
  `changeFreq` - a `SiteMapURL.ChangeFrequency` for this sitemap

#### setChangeFrequency

    public void setChangeFrequency​(String changeFreq)

Set the URL's change frequency In case of a bad ChangeFrequency, the current frequency in this instance will be set to NULL

Parameters:
  `changeFreq` - a string representing a `SiteMapURL.ChangeFrequency` for this sitemap

#### setValid

    public void setValid​(boolean valid)

Valid means that it follows the official guidelines that the siteMapURL must be under the base url

Parameters:
  `valid` - whether the Sitemap is valid syntax or not

#### isValid

    public boolean isValid()

Is the siteMapURL under the base url ?

Returns:
  true if the syntax is valid, false otherwise

#### addAttributesForExtension

    public void addAttributesForExtension​(Extension extension,
                                          ExtensionMetadata[] attributes)

Add attributes of a specific sitemap extension

Parameters:
  `extension` - sitemap extension (news, images, videos, etc.)
  `attributes` - array of attributes

#### getAttributes

    public Map<Extension,​ExtensionMetadata[]> getAttributes()

Get attributes of sitemap extensions (news, images, videos, etc.)

Returns:
  attribute map or null if no extensions are used

#### getAttributesForExtension

    public ExtensionMetadata[] getAttributesForExtension​(Extension extension)

Get attributes of a specific sitemap extension

Parameters:
  `extension` - sitemap extension (news, images, videos, etc.)
Returns:
  array of attributes or null if there are no attributes for the given extension

#### equals

    public boolean equals​(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`