content: /*
   * Solo - A small and beautiful blogging system written in Java.
   * Copyright (c) 2010-present, b3log.org
   *
   * Solo is licensed under Mulan PSL v2.
   * You can use this software according to the terms and conditions of the Mulan PSL v2.
   * You may obtain a copy of Mulan PSL v2 at:
   *         http://license.coscl.org.cn/MulanPSL2
   * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
   * See the Mulan PSL v2 for more details.
   */
  package org.b3log.solo.model.sitemap;
  
  
  import java.util.ArrayList;
  import java.util.List;
  
  
  /**
   * Sitemap.
   *
   * <p>
   * See <a href="http://www.sitemaps.org/protocol.php">Sitemap XML format</a>
   * for more details.
   * </p>
   *
   * @author <a href="http://88250.b3log.org">Liang Ding</a>
   * @version 1.1.0.0, Sep 22, 2011
   * @see URL
   * @since 0.3.1
   */
  public final class Sitemap {
  
      /**
       * Start document.
       */
      private static final String START_DOCUMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  
      /**
       * Start URL set element.
       */
      private static final String START_URL_SET_ELEMENT = "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
  
      /**
       * End URL set element.
       */
      private static final String END_URL_SET_ELEMENT = "</urlset>";
  
      /**
       * URLs.
       */
      private final List<URL> urls = new ArrayList<>();
  
      /**
       * Adds the specified url.
       *
       * @param url the specified url
       */
      public void addURL(final URL url) {
          urls.add(url);
      }
  
      @Override
      public String toString() {
          final StringBuilder stringBuilder = new StringBuilder();
          stringBuilder.append(START_DOCUMENT);
          stringBuilder.append(START_URL_SET_ELEMENT);
          for (final URL url : urls) {
              stringBuilder.append(url.toString());
          }
          stringBuilder.append(END_URL_SET_ELEMENT);
          return stringBuilder.toString();
      }
  }
  