# SiteMapParser (Crawler-commons 0.6-SNAPSHOT API)
Date: 2015-05-26

crawlercommons.sitemaps

## Class SiteMapParser

- java.lang.Object
- - crawlercommons.sitemaps.SiteMapParser

    public class SiteMapParser
    extends Object

### Field Summary

Fields
`static org.slf4j.Logger` `LOG`
`static int` `MAX_BYTES_ALLOWED` Sitemap docs must be limited to 10MB (10,485,760 bytes)

### Constructor Summary

Constructors
Constructor and Description
`SiteMapParser()`
`SiteMapParser(boolean strict)`

### Method Summary

Methods
`boolean` `isStrict()`
`AbstractSiteMap` `parseSiteMap(byte[] content, URL url)`
`AbstractSiteMap` `parseSiteMap(String contentType, byte[] content, AbstractSiteMap sitemap)` Returns a processed copy of an unprocessed sitemap object, i.e.
`AbstractSiteMap` `parseSiteMap(String contentType, byte[] content, URL url)`
`AbstractSiteMap` `parseSiteMap(URL onlineSitemapUrl)` Returns a SiteMap or SiteMapIndex given an online sitemap URL Please note that this method is a static method which goes online and fetches the sitemap then parses it This method is a convenience method for a user who has a sitemap URL and wants a "Keep it simple" way to parse it.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### LOG

    public static final org.slf4j.Logger LOG

#### MAX_BYTES_ALLOWED

    public static int MAX_BYTES_ALLOWED

Sitemap docs must be limited to 10MB (10,485,760 bytes)

### Constructor Detail

#### SiteMapParser

    public SiteMapParser()

#### SiteMapParser

    public SiteMapParser(boolean strict)

### Method Detail

#### isStrict

    public boolean isStrict()

Returns:
  whether invalid URLs will be rejected

#### parseSiteMap

    public AbstractSiteMap parseSiteMap(URL onlineSitemapUrl)
                                 throws UnknownFormatException,
                                        IOException

Returns a SiteMap or SiteMapIndex given an online sitemap URL
Please note that this method is a static method which goes online and fetches the sitemap then parses it
This method is a convenience method for a user who has a sitemap URL and wants a "Keep it simple" way to parse it.

Parameters:
  `onlineSitemapUrl` - URL of the online sitemap
Returns:
  AbstractSiteMap object or null if the onlineSitemap is null
Throws:
  `UnknownFormatException`
  `IOException`

#### parseSiteMap

    public AbstractSiteMap parseSiteMap(String contentType,
                               byte[] content,
                               AbstractSiteMap sitemap)
                                 throws UnknownFormatException,
                                        IOException

Returns a processed copy of an unprocessed sitemap object, i.e. transfer the value of getLastModified Please note that the sitemap input stays unchanged

Throws:
  `UnknownFormatException`
  `IOException`

#### parseSiteMap

    public AbstractSiteMap parseSiteMap(byte[] content,
                               URL url)
                                 throws UnknownFormatException,
                                        IOException

Returns:
  SiteMap/SiteMapIndex by guessing the content type from the binary content and URL
Throws:
  `UnknownFormatException`
  `IOException`

#### parseSiteMap

    public AbstractSiteMap parseSiteMap(String contentType,
                               byte[] content,
                               URL url)
                                 throws UnknownFormatException,
                                        IOException

Returns:
  SiteMap/SiteMapIndex given a content type, byte content and the URL of a sitemap
Throws:
  `UnknownFormatException`
  `IOException`