//# 0 errors, 117 messages
//#
/*
    //#permalinkprovidersupport.java:1:1: class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#permalinkprovidersupport.java:1:1: method: net.sourceforge.pebble.permalink.PermalinkProviderSupport.net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.permalink;

import net.sourceforge.pebble.domain.Day;
import net.sourceforge.pebble.domain.Month;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.api.permalink.PermalinkProvider;

import java.text.SimpleDateFormat;

/**
 * Support class that can be used as a basis for PermalinkProvider
 * implementations.
 *
 * @author Simon Brown
 */
public abstract class PermalinkProviderSupport implements PermalinkProvider {
    //#permalinkprovidersupport.java:47: method: void net.sourceforge.pebble.permalink.PermalinkProviderSupport.net.sourceforge.pebble.permalink.PermalinkProviderSupport()
    //#permalinkprovidersupport.java:47: end of method: void net.sourceforge.pebble.permalink.PermalinkProviderSupport.net.sourceforge.pebble.permalink.PermalinkProviderSupport()

  /** the regex used to check for a day request */
  private static final String DAY_PERMALINK_REGEX = "/\\d\\d\\d\\d/\\d\\d/\\d\\d.html";

  /** the regex used to check for a monthly blog request */
  private static final String MONTH_PERMALINK_REGEX = "/\\d\\d\\d\\d/\\d\\d.html";

  /** the Blog associated with this provider instance */
  private Blog blog;

  /**
   * Gets the blog associated with this provider instance.
   *
   * @return  a Blog instance
   */
  public Blog getBlog() {
    return this.blog;
    //#permalinkprovidersupport.java:64: method: Blog net.sourceforge.pebble.permalink.PermalinkProviderSupport.getBlog()
    //#input(Blog getBlog()): this
    //#input(Blog getBlog()): this.blog
    //#output(Blog getBlog()): return_value
    //#pre[2] (Blog getBlog()): init'ed(this.blog)
    //#post(Blog getBlog()): return_value == this.blog
    //#post(Blog getBlog()): init'ed(return_value)
    //#permalinkprovidersupport.java:64: end of method: Blog net.sourceforge.pebble.permalink.PermalinkProviderSupport.getBlog()
  }

  /**
   * Sets the blog associated with this provider instance.
   *
   * @param blog    a Blog instance
   */
  public void setBlog(Blog blog) {
    this.blog = blog;
    //#permalinkprovidersupport.java:73: method: void net.sourceforge.pebble.permalink.PermalinkProviderSupport.setBlog(Blog)
    //#input(void setBlog(Blog)): blog
    //#input(void setBlog(Blog)): this
    //#output(void setBlog(Blog)): this.blog
    //#post(void setBlog(Blog)): this.blog == blog
    //#post(void setBlog(Blog)): init'ed(this.blog)
  }
    //#permalinkprovidersupport.java:74: end of method: void net.sourceforge.pebble.permalink.PermalinkProviderSupport.setBlog(Blog)

  /**
   * Gets the permalink for a monthly blog.
   *
   * @param month a Month instance
   * @return a URI as a String
   */
  public String getPermalink(Month month) {
    SimpleDateFormat format = new SimpleDateFormat("'/'yyyy'/'MM'.html'");
    //#permalinkprovidersupport.java:83: method: String net.sourceforge.pebble.permalink.PermalinkProviderSupport.getPermalink(Month)
    //#input(String getPermalink(Month)): month
    //#input(String getPermalink(Month)): this
    //#input(String getPermalink(Month)): this.blog
    //#output(String getPermalink(Month)): return_value
    //#pre[1] (String getPermalink(Month)): month != null
    //#pre[3] (String getPermalink(Month)): this.blog != null
    //#post(String getPermalink(Month)): init'ed(return_value)
    format.setTimeZone(blog.getTimeZone());
    //#permalinkprovidersupport.java:84: Warning: method not available
    //#    -- call on TimeZone net.sourceforge.pebble.domain.Blog:getTimeZone()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: String getPermalink(Month)
    //#    unanalyzed callee: TimeZone net.sourceforge.pebble.domain.Blog:getTimeZone()
    return format.format(month.getDate());
    //#permalinkprovidersupport.java:85: Warning: method not available
    //#    -- call on Date net.sourceforge.pebble.domain.Month:getDate()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: String getPermalink(Month)
    //#    unanalyzed callee: Date net.sourceforge.pebble.domain.Month:getDate()
    //#permalinkprovidersupport.java:85: end of method: String net.sourceforge.pebble.permalink.PermalinkProviderSupport.getPermalink(Month)
  }

  /**
   * Determines whether the specified URI is a monthly blog permalink.
   *
   * @param uri   a relative URI
   * @return      true if the URI represents a permalink to a monthly blog,
   *              false otherwise
   */
  public boolean isMonthPermalink(String uri) {
    if (uri != null) {
    //#permalinkprovidersupport.java:96: method: bool net.sourceforge.pebble.permalink.PermalinkProviderSupport.isMonthPermalink(String)
    //#input(bool isMonthPermalink(String)): uri
    //#output(bool isMonthPermalink(String)): return_value
    //#post(bool isMonthPermalink(String)): init'ed(return_value)
    //#test_vector(bool isMonthPermalink(String)): uri: Addr_Set{null}, Inverse{null}
      return uri.matches(MONTH_PERMALINK_REGEX);
    } else {
      return false;
    //#permalinkprovidersupport.java:99: end of method: bool net.sourceforge.pebble.permalink.PermalinkProviderSupport.isMonthPermalink(String)
    }
  }

  /**
   * Gets the monthly blog referred to by the specified URI.
   *
   * @param uri   a relative URI
   * @return  a Month instance, or null if one can't be found
   */
  public Month getMonth(String uri) {
    String year = uri.substring(1, 5);
    //#permalinkprovidersupport.java:110: method: Month net.sourceforge.pebble.permalink.PermalinkProviderSupport.getMonth(String)
    //#permalinkprovidersupport.java:110: Warning: suspicious precondition
    //#    the precondition for this.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: Month getMonth(String)
    //#    suspicious precondition index: [2]
    //#input(Month getMonth(String)): __Descendant_Table[net/sourceforge/pebble/permalink/DefaultPermalinkProvider]
    //#input(Month getMonth(String)): __Descendant_Table[net/sourceforge/pebble/permalink/PermalinkProviderSupport]
    //#input(Month getMonth(String)): __Descendant_Table[net/sourceforge/pebble/permalink/ShortPermalinkProvider]
    //#input(Month getMonth(String)): __Descendant_Table[net/sourceforge/pebble/permalink/TitlePermalinkProvider]
    //#input(Month getMonth(String)): __Descendant_Table[others]
    //#input(Month getMonth(String)): __Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Month getMonth(String)): net/sourceforge/pebble/permalink/DefaultPermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Month getMonth(String)): net/sourceforge/pebble/permalink/ShortPermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Month getMonth(String)): net/sourceforge/pebble/permalink/TitlePermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Month getMonth(String)): this
    //#input(Month getMonth(String)): this.__Tag
    //#input(Month getMonth(String)): this.blog
    //#input(Month getMonth(String)): uri
    //#output(Month getMonth(String)): return_value
    //#pre[2] (Month getMonth(String)): this.__Tag in {net/sourceforge/pebble/permalink/DefaultPermalinkProvider, net/sourceforge/pebble/permalink/PermalinkProviderSupport, net/sourceforge/pebble/permalink/ShortPermalinkProvider, net/sourceforge/pebble/permalink/TitlePermalinkProvider}
    //#pre[3] (Month getMonth(String)): this.blog != null
    //#pre[4] (Month getMonth(String)): uri != null
    //#post(Month getMonth(String)): init'ed(return_value)
    String month = uri.substring(6, 8);

    return getBlog().getBlogForMonth(Integer.parseInt(year), Integer.parseInt(month));
    //#permalinkprovidersupport.java:113: Warning: method not available
    //#    -- call on Month net.sourceforge.pebble.domain.Blog:getBlogForMonth(int, int)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: Month getMonth(String)
    //#    unanalyzed callee: Month net.sourceforge.pebble.domain.Blog:getBlogForMonth(int, int)
    //#permalinkprovidersupport.java:113: end of method: Month net.sourceforge.pebble.permalink.PermalinkProviderSupport.getMonth(String)
  }

  /**
   * Gets the permalink for a day.
   *
   * @param day a Day instance
   * @return a URI as a String
   */
  public String getPermalink(Day day) {
    SimpleDateFormat format = new SimpleDateFormat("'/'yyyy'/'MM'/'dd'.html'");
    //#permalinkprovidersupport.java:123: method: String net.sourceforge.pebble.permalink.PermalinkProviderSupport.getPermalink(Day)
    //#input(String getPermalink(Day)): day
    //#input(String getPermalink(Day)): this
    //#input(String getPermalink(Day)): this.blog
    //#output(String getPermalink(Day)): return_value
    //#pre[1] (String getPermalink(Day)): day != null
    //#pre[3] (String getPermalink(Day)): this.blog != null
    //#post(String getPermalink(Day)): init'ed(return_value)
    format.setTimeZone(blog.getTimeZone());
    //#permalinkprovidersupport.java:124: Warning: method not available
    //#    -- call on TimeZone net.sourceforge.pebble.domain.Blog:getTimeZone()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: String getPermalink(Day)
    //#    unanalyzed callee: TimeZone net.sourceforge.pebble.domain.Blog:getTimeZone()
    return format.format(day.getDate());
    //#permalinkprovidersupport.java:125: Warning: method not available
    //#    -- call on Date net.sourceforge.pebble.domain.Day:getDate()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: String getPermalink(Day)
    //#    unanalyzed callee: Date net.sourceforge.pebble.domain.Day:getDate()
    //#permalinkprovidersupport.java:125: end of method: String net.sourceforge.pebble.permalink.PermalinkProviderSupport.getPermalink(Day)
  }

  /**
   * Determines whether the specified URI is a day permalink.
   *
   * @param uri   a relative URI
   * @return      true if the URI represents a permalink to a day,
   *              false otherwise
   */
  public boolean isDayPermalink(String uri) {
    if (uri != null) {
    //#permalinkprovidersupport.java:136: method: bool net.sourceforge.pebble.permalink.PermalinkProviderSupport.isDayPermalink(String)
    //#input(bool isDayPermalink(String)): uri
    //#output(bool isDayPermalink(String)): return_value
    //#post(bool isDayPermalink(String)): init'ed(return_value)
    //#test_vector(bool isDayPermalink(String)): uri: Addr_Set{null}, Inverse{null}
      return uri.matches(DAY_PERMALINK_REGEX);
    } else {
      return false;
    //#permalinkprovidersupport.java:139: end of method: bool net.sourceforge.pebble.permalink.PermalinkProviderSupport.isDayPermalink(String)
    }
  }

  /**
   * Gets the day referred to by the specified URI.
   *
   * @param uri   a relative URI
   * @return  a Day instance, or null if one can't be found
   */
  public Day getDay(String uri) {
    String year = uri.substring(1, 5);
    //#permalinkprovidersupport.java:150: method: Day net.sourceforge.pebble.permalink.PermalinkProviderSupport.getDay(String)
    //#permalinkprovidersupport.java:150: Warning: suspicious precondition
    //#    the precondition for this.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: Day getDay(String)
    //#    suspicious precondition index: [2]
    //#input(Day getDay(String)): __Descendant_Table[net/sourceforge/pebble/permalink/DefaultPermalinkProvider]
    //#input(Day getDay(String)): __Descendant_Table[net/sourceforge/pebble/permalink/PermalinkProviderSupport]
    //#input(Day getDay(String)): __Descendant_Table[net/sourceforge/pebble/permalink/ShortPermalinkProvider]
    //#input(Day getDay(String)): __Descendant_Table[net/sourceforge/pebble/permalink/TitlePermalinkProvider]
    //#input(Day getDay(String)): __Descendant_Table[others]
    //#input(Day getDay(String)): __Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Day getDay(String)): net/sourceforge/pebble/permalink/DefaultPermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Day getDay(String)): net/sourceforge/pebble/permalink/ShortPermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Day getDay(String)): net/sourceforge/pebble/permalink/TitlePermalinkProvider.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(Day getDay(String)): this
    //#input(Day getDay(String)): this.__Tag
    //#input(Day getDay(String)): this.blog
    //#input(Day getDay(String)): uri
    //#output(Day getDay(String)): return_value
    //#pre[2] (Day getDay(String)): this.__Tag in {net/sourceforge/pebble/permalink/DefaultPermalinkProvider, net/sourceforge/pebble/permalink/PermalinkProviderSupport, net/sourceforge/pebble/permalink/ShortPermalinkProvider, net/sourceforge/pebble/permalink/TitlePermalinkProvider}
    //#pre[3] (Day getDay(String)): this.blog != null
    //#pre[4] (Day getDay(String)): uri != null
    //#post(Day getDay(String)): init'ed(return_value)
    String month = uri.substring(6, 8);
    String day = uri.substring(9, 11);

    return getBlog().getBlogForDay(Integer.parseInt(year),
    //#permalinkprovidersupport.java:154: Warning: method not available
    //#    -- call on Day net.sourceforge.pebble.domain.Blog:getBlogForDay(int, int, int)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
    //#    method: Day getDay(String)
    //#    unanalyzed callee: Day net.sourceforge.pebble.domain.Blog:getBlogForDay(int, int, int)
       Integer.parseInt(month), Integer.parseInt(day));
    //#permalinkprovidersupport.java:155: end of method: Day net.sourceforge.pebble.permalink.PermalinkProviderSupport.getDay(String)
  }

}
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Descendant_Table[net/sourceforge/pebble/permalink/PermalinkProviderSupport]
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getDay(Ljava/lang/String;)Lnet/sourceforge/pebble/domain/Day;
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getMonth(Ljava/lang/String;)Lnet/sourceforge/pebble/domain/Month;
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getPermalink(Lnet/sourceforge/pebble/domain/Day;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getPermalink(Lnet/sourceforge/pebble/domain/Month;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.isDayPermalink(Ljava/lang/String;)Z
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.isMonthPermalink(Ljava/lang/String;)Z
    //#output(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.setBlog(Lnet/sourceforge/pebble/domain/Blog;)V
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Descendant_Table[net/sourceforge/pebble/permalink/PermalinkProviderSupport] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog; == &getBlog
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getDay(Ljava/lang/String;)Lnet/sourceforge/pebble/domain/Day; == &getDay
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getMonth(Ljava/lang/String;)Lnet/sourceforge/pebble/domain/Month; == &getMonth
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getPermalink(Lnet/sourceforge/pebble/domain/Day;)Ljava/lang/String; == &getPermalink
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.getPermalink(Lnet/sourceforge/pebble/domain/Month;)Ljava/lang/String; == &getPermalink
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.isDayPermalink(Ljava/lang/String;)Z == &isDayPermalink
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.isMonthPermalink(Ljava/lang/String;)Z == &isMonthPermalink
    //#post(net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init): __Dispatch_Table.setBlog(Lnet/sourceforge/pebble/domain/Blog;)V == &setBlog
    //#permalinkprovidersupport.java:: end of method: net.sourceforge.pebble.permalink.PermalinkProviderSupport.net.sourceforge.pebble.permalink.PermalinkProviderSupport__static_init
    //#permalinkprovidersupport.java:: end of class: net.sourceforge.pebble.permalink.PermalinkProviderSupport
