File Source: WeblogTemplate.java

         /* 
    P/P   *  Method: void readObject(ObjectInputStream)
          * 
          *  Preconditions:
          *    Param_1 != null
          * 
          *  Presumptions:
          *    init'ed(org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED)
          * 
          *  Postconditions:
          *    Param_0.pcDetachedState == org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED
          *    (soft) init'ed(Param_0.pcDetachedState)
          */
     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   *  contributor license agreements.  The ASF licenses this file to You
     4   * under the Apache License, Version 2.0 (the "License"); you may not
     5   * use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.  For additional information regarding
    15   * copyright in this work, please see the NOTICE file in the top level
    16   * directory of this distribution.
    17   */
    18  
    19  package org.apache.roller.weblogger.pojos;
    20  
    21  import java.io.Serializable;
    22  import java.util.Date;
    23  import java.util.HashSet;
    24  import java.util.Set;
    25  import org.apache.commons.lang.builder.EqualsBuilder;
    26  import org.apache.commons.lang.builder.HashCodeBuilder;
    27  import org.apache.commons.logging.Log;
    28  import org.apache.commons.logging.LogFactory;
    29  import org.apache.roller.weblogger.WebloggerException;
    30  import org.apache.roller.util.UUIDGenerator;
    31  
    32  
    33  /**
    34   * POJO that represents a single user defined template page.
    35   *
    36   * This template is different from the generic template because it also
    37   * contains a reference to the website it is part of.
    38   */
    39  public class WeblogTemplate implements ThemeTemplate, Serializable {
    40      
    41      public static final long serialVersionUID = -613737191638263428L;
    42      public static final String DEFAULT_PAGE = "Weblog";
    43      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.pojos.WeblogTemplate__static_init
              * 
              *  Presumptions:
              *    init'ed(java.lang.Boolean.TYPE)
              * 
              *  Postconditions:
              *    init'ed(log)
              *    pcFieldFlags == &new byte[](WeblogTemplate__static_init#4)
              *    pcFieldNames == &new String[](WeblogTemplate__static_init#2)
              *    pcFieldTypes == &new Class[](WeblogTemplate__static_init#3)
              *    requiredTemplates == &new HashSet(WeblogTemplate__static_init#1)
              *    new Class[](WeblogTemplate__static_init#3) num objects == 1
              *    new HashSet(WeblogTemplate__static_init#1) num objects == 1
              *    new String[](WeblogTemplate__static_init#2) num objects == 1
              *    new byte[](WeblogTemplate__static_init#4) num objects == 1
              *    pcFieldTypes.length == 13
              *    ...
              */
    44      private static Log log = LogFactory.getLog(WeblogTemplate.class);
    45      private static Set requiredTemplates = null;
    46      
    47      // attributes
    48      private String id = UUIDGenerator.generateUUID();
    49      private String  action = null;
    50      private String  name = null;
    51      private String  description = null;
    52      private String  link = null;
    53      private String  contents = null;
    54      private Date    lastModified = null;
    55      private String  templateLanguage = null;
    56      private boolean hidden = false;
    57      private boolean navbar = false;
    58      private String  decoratorName = null;
    59      private String  outputContentType = null;
    60      
    61      // associations
    62      private Weblog weblog = null;
    63      
    64      
    65      static {
    66          requiredTemplates = new HashSet();
    67          requiredTemplates.add("Weblog");
    68          requiredTemplates.add("_day");
    69      }
    70      
    71      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.pojos.WeblogTemplate()
              * 
              *  Postconditions:
              *    this.action == null
              *    this.contents == null
              *    this.decoratorName == null
              *    this.description == null
              *    this.lastModified == null
              *    this.link == null
              *    this.name == null
              *    this.outputContentType == null
              *    this.templateLanguage == null
              *    this.weblog == null
              *    ...
              */
    72      public WeblogTemplate() {}
    73      
    74      
    75      public ThemeTemplate getDecorator() {
                 /* 
    P/P           *  Method: ThemeTemplate getDecorator()
                  * 
                  *  Preconditions:
                  *    init'ed(this.decoratorName)
                  *    (soft) log != null
                  *    (soft) this.id != null
                  *    (soft) this.weblog != null
                  * 
                  *  Presumptions:
                  *    getTheme(...)@78 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    this.decoratorName: Addr_Set{null}, Inverse{null}
                  *    java.lang.String:equals(...)@76: {1}, {0}
                  */
    76          if(decoratorName != null && !id.equals(decoratorName)) {
    77              try {
    78                  return weblog.getTheme().getTemplateByName(decoratorName);
    79              } catch (WebloggerException ex) {
    80                  log.error("Error getting decorator["+decoratorName+"] "+
    81                          "for template "+id);
    82              }
    83          }
    84          return null;
    85      }
    86      
    87      
    88      public String getId() {
                 /* 
    P/P           *  Method: String pcgetId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  * 
                  *  Postconditions:
                  *    return_value == this.id
                  *    init'ed(return_value)
                  */
    89          return this.id;
    90      }
    91      
    92      public void setId( String id ) {
                 /* 
    P/P           *  Method: void pcsetId(String)
                  * 
                  *  Postconditions:
                  *    this.id == Param_1
                  *    init'ed(this.id)
                  */
    93          this.id = id;
    94      }
    95      
    96      
    97      public Weblog getWebsite() {
                 /* 
    P/P           *  Method: Weblog pcgetWebsite()
                  * 
                  *  Preconditions:
                  *    init'ed(this.weblog)
                  * 
                  *  Postconditions:
                  *    return_value == this.weblog
                  *    init'ed(return_value)
                  */
    98          return this.weblog;
    99      }
   100      
   101      public void setWebsite( Weblog website ) {
                 /* 
    P/P           *  Method: void pcsetWebsite(Weblog)
                  * 
                  *  Postconditions:
                  *    this.weblog == Param_1
                  *    init'ed(this.weblog)
                  */
   102          this.weblog = website;
   103      }
   104      
   105      
   106      public String getAction() {
                 /* 
    P/P           *  Method: String pcgetAction()
                  * 
                  *  Preconditions:
                  *    init'ed(this.action)
                  * 
                  *  Postconditions:
                  *    return_value == this.action
                  *    init'ed(return_value)
                  */
   107          return action;
   108      }
   109  
   110      public void setAction(String action) {
                 /* 
    P/P           *  Method: void pcsetAction(String)
                  * 
                  *  Postconditions:
                  *    this.action == Param_1
                  *    init'ed(this.action)
                  */
   111          this.action = action;
   112      }
   113      
   114      
   115      public String getName() {
                 /* 
    P/P           *  Method: String pcgetName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.name)
                  * 
                  *  Postconditions:
                  *    return_value == this.name
                  *    init'ed(return_value)
                  */
   116          return this.name;
   117      }
   118      
   119      public void setName( String name ) {
                 /* 
    P/P           *  Method: void pcsetName(String)
                  * 
                  *  Postconditions:
                  *    this.name == Param_1
                  *    init'ed(this.name)
                  */
   120          this.name = name;
   121      }
   122      
   123      
   124      public String getDescription() {
                 /* 
    P/P           *  Method: String pcgetDescription()
                  * 
                  *  Preconditions:
                  *    init'ed(this.description)
                  * 
                  *  Postconditions:
                  *    return_value == this.description
                  *    init'ed(return_value)
                  */
   125          return this.description;
   126      }
   127      
   128      public void setDescription( String description ) {
                 /* 
    P/P           *  Method: void pcsetDescription(String)
                  * 
                  *  Postconditions:
                  *    this.description == Param_1
                  *    init'ed(this.description)
                  */
   129          this.description = description;
   130      }
   131      
   132      
   133      public String getLink() {
                 /* 
    P/P           *  Method: String pcgetLink()
                  * 
                  *  Preconditions:
                  *    init'ed(this.link)
                  * 
                  *  Postconditions:
                  *    return_value == this.link
                  *    init'ed(return_value)
                  */
   134          return this.link;
   135      }
   136      
   137      public void setLink( String link ) {
                 /* 
    P/P           *  Method: void pcsetLink(String)
                  * 
                  *  Postconditions:
                  *    this.link == Param_1
                  *    init'ed(this.link)
                  */
   138          this.link = link;
   139      }
   140      
   141      
   142      public String getContents() {
                 /* 
    P/P           *  Method: String pcgetContents()
                  * 
                  *  Preconditions:
                  *    init'ed(this.contents)
                  * 
                  *  Postconditions:
                  *    return_value == this.contents
                  *    init'ed(return_value)
                  */
   143          return this.contents;
   144      }
   145      
   146      public void setContents( String template ) {
                 /* 
    P/P           *  Method: void pcsetContents(String)
                  * 
                  *  Postconditions:
                  *    this.contents == Param_1
                  *    init'ed(this.contents)
                  */
   147          this.contents = template;
   148      }
   149      
   150      
   151      public Date getLastModified() {
                 /* 
    P/P           *  Method: Date pcgetLastModified()
                  * 
                  *  Preconditions:
                  *    init'ed(this.lastModified)
                  * 
                  *  Postconditions:
                  *    return_value == this.lastModified
                  *    init'ed(return_value)
                  */
   152          return lastModified;
   153      }
   154      
   155      public void setLastModified(final Date newtime ) {
                 /* 
    P/P           *  Method: void pcsetLastModified(Date)
                  * 
                  *  Postconditions:
                  *    this.lastModified == Param_1
                  *    init'ed(this.lastModified)
                  */
   156          lastModified = newtime;
   157      }
   158      
   159      
   160      public String getTemplateLanguage() {
                 /* 
    P/P           *  Method: String pcgetTemplateLanguage()
                  * 
                  *  Preconditions:
                  *    init'ed(this.templateLanguage)
                  * 
                  *  Postconditions:
                  *    return_value == this.templateLanguage
                  *    init'ed(return_value)
                  */
   161          return templateLanguage;
   162      }
   163  
   164      public void setTemplateLanguage(String templateLanguage) {
                 /* 
    P/P           *  Method: void pcsetTemplateLanguage(String)
                  * 
                  *  Postconditions:
                  *    this.templateLanguage == Param_1
                  *    init'ed(this.templateLanguage)
                  */
   165          this.templateLanguage = templateLanguage;
   166      }
   167      
   168      
   169      public boolean isNavbar() {
                 /* 
    P/P           *  Method: bool pcisNavbar()
                  * 
                  *  Preconditions:
                  *    init'ed(this.navbar)
                  * 
                  *  Postconditions:
                  *    return_value == this.navbar
                  *    init'ed(return_value)
                  */
   170          return navbar;
   171      }
   172  
   173      public void setNavbar(boolean navbar) {
                 /* 
    P/P           *  Method: void pcsetNavbar(bool)
                  * 
                  *  Postconditions:
                  *    this.navbar == Param_1
                  *    init'ed(this.navbar)
                  */
   174          this.navbar = navbar;
   175      }
   176      
   177      
   178      public boolean isHidden() {
                 /* 
    P/P           *  Method: bool pcisHidden()
                  * 
                  *  Preconditions:
                  *    init'ed(this.hidden)
                  * 
                  *  Postconditions:
                  *    return_value == this.hidden
                  *    init'ed(return_value)
                  */
   179          return hidden;
   180      }
   181  
   182      public void setHidden(boolean isHidden) {
                 /* 
    P/P           *  Method: void pcsetHidden(bool)
                  * 
                  *  Postconditions:
                  *    this.hidden == Param_1
                  *    init'ed(this.hidden)
                  */
   183          this.hidden = isHidden;
   184      }
   185          
   186      
   187      public String getDecoratorName() {
                 /* 
    P/P           *  Method: String pcgetDecoratorName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.decoratorName)
                  * 
                  *  Postconditions:
                  *    return_value == this.decoratorName
                  *    init'ed(return_value)
                  */
   188          return decoratorName;
   189      }
   190  
   191      public void setDecoratorName(String decorator) {
                 /* 
    P/P           *  Method: void pcsetDecoratorName(String)
                  * 
                  *  Postconditions:
                  *    this.decoratorName == Param_1
                  *    init'ed(this.decoratorName)
                  */
   192          this.decoratorName = decorator;
   193      }
   194      
   195      
   196      /** 
   197       * Content-type rendered by template or null for auto-detection by link extension.
   198       */
   199      public String getOutputContentType() {
                 /* 
    P/P           *  Method: String pcgetOutputContentType()
                  * 
                  *  Preconditions:
                  *    init'ed(this.outputContentType)
                  * 
                  *  Postconditions:
                  *    return_value == this.outputContentType
                  *    init'ed(return_value)
                  */
   200          return outputContentType;
   201      }
   202      
   203      public void setOutputContentType(String outputContentType) {
                 /* 
    P/P           *  Method: void pcsetOutputContentType(String)
                  * 
                  *  Postconditions:
                  *    this.outputContentType == Param_1
                  *    init'ed(this.outputContentType)
                  */
   204          this.outputContentType = outputContentType;
   205      }
   206      
   207      
   208      /**
   209       * Determine if this WeblogTemplate is required or not.
   210       */
   211      public boolean isRequired() {
   212         /*
   213          * this is kind of hacky right now, but it's like that so we can be
   214          * reasonably flexible while we migrate old blogs which may have some
   215          * pretty strange customizations.
   216          *
   217          * my main goal starting now is to prevent further deviations from the
   218          * standardized templates as we move forward.
   219          *
   220          * eventually, the required flag should probably be stored in the db
   221          * and possibly applicable to any template.
   222          */
                 /* 
    P/P           *  Method: bool isRequired()
                  * 
                  *  Preconditions:
                  *    requiredTemplates != null
                  *    init'ed(this.name)
                  *    (soft) init'ed(this.link)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   223          return (requiredTemplates.contains(this.name) || "Weblog".equals(this.link));
   224      }
   225      
   226      
   227      /**
   228       * A convenience method for testing if this template represents a 'custom'
   229       * template, meaning a template with action = ACTION_CUSTOM.
   230       */
   231      public boolean isCustom() {
                 /* 
    P/P           *  Method: bool isCustom()
                  * 
                  *  Preconditions:
                  *    init'ed(this.action)
                  *    init'ed(this.pcStateManager)
                  *    (soft) init'ed(pcInheritedFieldCount)
                  *    (soft) requiredTemplates != null
                  *    (soft) init'ed(this.link)
                  *    (soft) init'ed(this.name)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   232          return ACTION_CUSTOM.equals(getAction()) && !isRequired();
   233      }
   234      
   235      
   236      //------------------------------------------------------- Good citizenship
   237  
   238      public String toString() {
                 /* 
    P/P           *  Method: String toString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.decoratorName)
                  *    init'ed(this.id)
                  *    init'ed(this.link)
                  *    init'ed(this.name)
                  *    init'ed(this.templateLanguage)
                  * 
                  *  Postconditions:
                  *    java.lang.StringBuffer:toString(...)._tainted == this.templateLanguage._tainted | this.decoratorName._tainted | this.link._tainted | this.id._tainted | this.name._tainted
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuffer:toString(...)
                  */
   239          StringBuffer buf = new StringBuffer();
   240          buf.append("{");
   241          buf.append(this.id);
   242          buf.append(", ").append(this.name);
   243          buf.append(", ").append(this.link);
   244          buf.append(", ").append(this.decoratorName);
   245          buf.append(", ").append(this.templateLanguage);
   246          buf.append("}");
   247          return buf.toString();
   248      }
   249  
   250      public boolean equals(Object other) {
                 /* 
    P/P           *  Method: bool equals(Object)
                  * 
                  *  Preconditions:
                  *    (soft) init'ed(other.name)
                  *    (soft) init'ed(other.pcStateManager)
                  *    (soft) init'ed(other.weblog)
                  *    (soft) pcInheritedFieldCount <= 232-13
                  *    (soft) init'ed(this.name)
                  *    (soft) init'ed(this.pcStateManager)
                  *    (soft) init'ed(this.weblog)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.EqualsBuilder:append(...)@254 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    other == this: {0}, {1}
                  */
   251          if (other == this) return true;
   252          if (other instanceof WeblogTemplate != true) return false;
   253          WeblogTemplate o = (WeblogTemplate)other;
   254          return new EqualsBuilder()
   255              .append(name, o.getName()) 
   256              .append(getWebsite(), o.getWebsite()) 
   257              .isEquals();
   258      }
   259      
   260      public int hashCode() { 
                 /* 
    P/P           *  Method: int hashCode()
                  * 
                  *  Preconditions:
                  *    init'ed(this.name)
                  *    init'ed(this.pcStateManager)
                  *    init'ed(this.weblog)
                  *    (soft) pcInheritedFieldCount <= 232-13
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.HashCodeBuilder:append(...)@261 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   261          return new HashCodeBuilder()
   262              .append(getName())
   263              .append(getWebsite())
   264              .toHashCode();
   265      }
   266      
   267  }
+  268  Other Messages








SofCheck Inspector Build Version : 2.18479
WeblogTemplate.java 2009-Jan-02 14:25:04
WeblogTemplate.class 2009-Sep-04 03:12:38