File Source: attachment.java

         /* 
    P/P   *  Method: net.sourceforge.pebble.domain.Attachment__static_init
          */
     1  /*
     2   * Copyright (c) 2003-2006, Simon Brown
     3   * All rights reserved.
     4   *
     5   * Redistribution and use in source and binary forms, with or without
     6   * modification, are permitted provided that the following conditions are met:
     7   *
     8   *   - Redistributions of source code must retain the above copyright
     9   *     notice, this list of conditions and the following disclaimer.
    10   *
    11   *   - Redistributions in binary form must reproduce the above copyright
    12   *     notice, this list of conditions and the following disclaimer in
    13   *     the documentation and/or other materials provided with the
    14   *     distribution.
    15   *
    16   *   - Neither the name of Pebble nor the names of its contributors may
    17   *     be used to endorse or promote products derived from this software
    18   *     without specific prior written permission.
    19   *
    20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    30   * POSSIBILITY OF SUCH DAMAGE.
    31   */
    32  package net.sourceforge.pebble.domain;
    33  
    34  
    35  /**
    36   * Represents a blog entry attachment (such as that used within an RSS
    37   * enclosure).
    38   *
    39   * @author Simon Brown
    40   */
    41  public class Attachment implements Cloneable {
    42  
    43    /** the URL of the attachment */
    44    private String url;
    45  
    46    /** the content size (length in bytes) */
    47    private long size;
    48  
    49    /** the content type */
    50    private String type;
    51  
    52    /**
    53     * Default, no args constructor.
    54     */
           /* 
    P/P     *  Method: void net.sourceforge.pebble.domain.Attachment()
            */
    55    public Attachment() {
    56    }
    57  
    58    /**
    59     * Creates an instance with the specified properties.
    60     *
    61     * @param url   a URL as a String
    62     * @param size    the size in bytes
    63     * @param type    a content type as a String
    64     */
           /* 
    P/P     *  Method: void net.sourceforge.pebble.domain.Attachment(String, long, String)
            * 
            *  Postconditions:
            *    this.size == size
            *    init'ed(this.size)
            *    this.type == type
            *    init'ed(this.type)
            *    this.url == url
            *    init'ed(this.url)
            */
    65    public Attachment(String url, long size, String type) {
    66      setUrl(url);
    67      setSize(size);
    68      setType(type);
    69    }
    70  
    71    /**
    72     * Gets the URL.
    73     *
    74     * @return  the URL as a String
    75     */
    76    public String getUrl() {
             /* 
    P/P       *  Method: String getUrl()
              * 
              *  Preconditions:
              *    init'ed(this.url)
              * 
              *  Postconditions:
              *    return_value == this.url
              *    init'ed(return_value)
              */
    77      return url;
    78    }
    79  
    80    /**
    81     * Sets the URL.
    82     *
    83     * @param url   a URL as a String
    84     */
    85    public void setUrl(String url) {
             /* 
    P/P       *  Method: void setUrl(String)
              * 
              *  Postconditions:
              *    this.url == url
              *    init'ed(this.url)
              */
    86      this.url = url;
    87    }
    88  
    89    /**
    90     * Gets the size in bytes.
    91     *
    92     * @return  the size of the attachement in bytes
    93     */
    94    public long getSize() {
             /* 
    P/P       *  Method: long getSize()
              * 
              *  Preconditions:
              *    init'ed(this.size)
              * 
              *  Postconditions:
              *    return_value == this.size
              *    init'ed(return_value)
              */
    95      return size;
    96    }
    97  
    98    /**
    99     * Sets the size of the attachement in bytes.
   100     *
   101     * @param size    the size in bytes
   102     */
   103    public void setSize(long size) {
             /* 
    P/P       *  Method: void setSize(long)
              * 
              *  Postconditions:
              *    this.size == size
              *    init'ed(this.size)
              */
   104      this.size = size;
   105    }
   106  
   107    /**
   108     * Gets the content type.
   109     *
   110     * @return  a MIME type as a String
   111     */
   112    public String getType() {
             /* 
    P/P       *  Method: String getType()
              * 
              *  Preconditions:
              *    init'ed(this.type)
              * 
              *  Postconditions:
              *    return_value == this.type
              *    init'ed(return_value)
              */
   113      return type;
   114    }
   115  
   116    /**
   117     * Sets the content type.
   118     *
   119     * @param type    a content type as a String
   120     */
   121    public void setType(String type) {
             /* 
    P/P       *  Method: void setType(String)
              * 
              *  Postconditions:
              *    this.type == type
              *    init'ed(this.type)
              */
   122      this.type = type;
   123    }
   124  
   125    public boolean equals(Object o) {
             /* 
    P/P       *  Method: bool equals(Object)
              * 
              *  Preconditions:
              *    (soft) init'ed(o.url)
              *    (soft) init'ed(this.url)
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Test Vectors:
              *    o.url: Addr_Set{null}, Inverse{null}
              *    this == o: {0}, {1}
              *    this.url: Addr_Set{null}, Inverse{null}
              *    java.lang.String:length(...)@135: {1..232-1}, {0}
              *    java.lang.String:length(...)@136: {0}, {1..232-1}
              */
   126      if (this == o) {
   127        return true;
   128      }
   129  
   130      if (!(o instanceof Attachment)) {
   131        return false;
   132      }
   133  
   134      final Attachment attachment = (Attachment) o;
   135      if (url == null || url.length() == 0) {
   136        return attachment.url == null || attachment.url.length() == 0;
   137      } else {
   138        return url.equals(attachment.url);
   139      }
   140    }
   141  
   142    public int hashCode() {
             /* 
    P/P       *  Method: int hashCode()
              * 
              *  Preconditions:
              *    this.url != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   143      return url.hashCode();
   144    }
   145  
   146    /**
   147     * Creates and returns a copy of this object.
   148     *
   149     * @return a clone of this instance.
   150     * @see Cloneable
   151     */
   152    public Object clone() {
             /* 
    P/P       *  Method: Object clone()
              * 
              *  Preconditions:
              *    init'ed(this.size)
              *    init'ed(this.type)
              *    init'ed(this.url)
              * 
              *  Postconditions:
              *    return_value == &new Attachment(clone#1)
              *    new Attachment(clone#1) num objects == 1
              *    return_value.size == this.size
              *    init'ed(return_value.size)
              *    return_value.type == this.type
              *    init'ed(return_value.type)
              *    return_value.url == this.url
              *    init'ed(return_value.url)
              */
   153      Attachment attachment = new Attachment();
   154      attachment.setUrl(url);
   155      attachment.setSize(size);
   156      attachment.setType(type);
   157  
   158      return attachment;
   159    }
   160  
   161  }








SofCheck Inspector Build Version : 2.22510
attachment.java 2010-Jun-25 19:40:32
attachment.class 2010-Jul-19 20:23:40