//# 0 errors, 62 messages
//#
/*
    //#shortpermalinkprovider.java:1:1: class: net.sourceforge.pebble.permalink.ShortPermalinkProvider
    //#shortpermalinkprovider.java:1:1: method: net.sourceforge.pebble.permalink.ShortPermalinkProvider.net.sourceforge.pebble.permalink.ShortPermalinkProvider__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.BlogEntry;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.domain.BlogService;
import net.sourceforge.pebble.domain.BlogServiceException;


/**
 * Generates permalinks using the pattern <time-in-millis>.
 *
 * @author Simon Brown
 */
public class ShortPermalinkProvider extends PermalinkProviderSupport {
    //#shortpermalinkprovider.java:45: method: void net.sourceforge.pebble.permalink.ShortPermalinkProvider.net.sourceforge.pebble.permalink.ShortPermalinkProvider()
    //#input(void net.sourceforge.pebble.permalink.ShortPermalinkProvider()): this
    //#shortpermalinkprovider.java:45: end of method: void net.sourceforge.pebble.permalink.ShortPermalinkProvider.net.sourceforge.pebble.permalink.ShortPermalinkProvider()

  /** the regex used to check for a blog entry permalink */
  private static final String BLOG_ENTRY_PERMALINK_REGEX = "/\\d*.html";

  /**
   * Gets the permalink for a blog entry.
   *
   * @return  a URI as a String
   */
  public String getPermalink(BlogEntry blogEntry) {
    return "/" + blogEntry.getId() + ".html";
    //#shortpermalinkprovider.java:56: method: String net.sourceforge.pebble.permalink.ShortPermalinkProvider.getPermalink(BlogEntry)
    //#shortpermalinkprovider.java:56: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.BlogEntry:getId()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.ShortPermalinkProvider
    //#    method: String getPermalink(BlogEntry)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.BlogEntry:getId()
    //#input(String getPermalink(BlogEntry)): blogEntry
    //#output(String getPermalink(BlogEntry)): return_value
    //#pre[1] (String getPermalink(BlogEntry)): blogEntry != null
    //#post(String getPermalink(BlogEntry)): return_value != null
    //#shortpermalinkprovider.java:56: end of method: String net.sourceforge.pebble.permalink.ShortPermalinkProvider.getPermalink(BlogEntry)
  }

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

  /**
   * Gets the blog entry referred to by the specified URI.
   *
   * @param uri   a relative URI
   * @return  a BlogEntry instance, or null if one can't be found
   */
  public BlogEntry getBlogEntry(String uri) {
    // uri is of the form /1234567890123.html, so extract the 13-digit ID
    // and use it to find the correct blog entry
    Blog blog = getBlog();
    //#shortpermalinkprovider.java:83: method: BlogEntry net.sourceforge.pebble.permalink.ShortPermalinkProvider.getBlogEntry(String)
    //#input(BlogEntry getBlogEntry(String)): __Descendant_Table[net/sourceforge/pebble/permalink/ShortPermalinkProvider]
    //#input(BlogEntry getBlogEntry(String)): __Descendant_Table[others]
    //#input(BlogEntry getBlogEntry(String)): __Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(BlogEntry getBlogEntry(String)): this
    //#input(BlogEntry getBlogEntry(String)): this.__Tag
    //#input(BlogEntry getBlogEntry(String)): this.blog
    //#input(BlogEntry getBlogEntry(String)): uri
    //#output(BlogEntry getBlogEntry(String)): return_value
    //#pre[2] (BlogEntry getBlogEntry(String)): this.__Tag == net/sourceforge/pebble/permalink/ShortPermalinkProvider
    //#pre[3] (BlogEntry getBlogEntry(String)): init'ed(this.blog)
    //#pre[4] (BlogEntry getBlogEntry(String)): (soft) uri != null
    //#post(BlogEntry getBlogEntry(String)): init'ed(return_value)
    BlogService service = new BlogService();
    //#shortpermalinkprovider.java:84: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.domain.BlogService()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.ShortPermalinkProvider
    //#    method: BlogEntry getBlogEntry(String)
    //#    unanalyzed callee: void net.sourceforge.pebble.domain.BlogService()
    try {
      return service.getBlogEntry(blog, uri.substring(1, 14));
    //#shortpermalinkprovider.java:86: Warning: method not available
    //#    -- call on BlogEntry net.sourceforge.pebble.domain.BlogService:getBlogEntry(Blog, String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.permalink.ShortPermalinkProvider
    //#    method: BlogEntry getBlogEntry(String)
    //#    unanalyzed callee: BlogEntry net.sourceforge.pebble.domain.BlogService:getBlogEntry(Blog, String)
    } catch (BlogServiceException e) {
      return null;
    //#shortpermalinkprovider.java:88: end of method: BlogEntry net.sourceforge.pebble.permalink.ShortPermalinkProvider.getBlogEntry(String)
    }
  }

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