Coverage Report - com.buckosoft.PicMan.domain.Set
 
Classes in this File Line Coverage Branch Coverage Complexity
Set
0%
0/65
0%
0/26
1.909
 
 1  
 /******************************************************************************
 2  
  * Set.java - a set bean, define a group of pictures
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2005 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.domain;
 9  
 
 10  
 import java.io.Serializable;
 11  
 import java.util.Comparator;
 12  
 import java.util.Date;
 13  
 
 14  0
 public class Set implements Serializable, Comparator<Set> {
 15  
         private static final long serialVersionUID = 1L;
 16  
         
 17  
         public final static String        FUNC_NAME_DATE        = "[date]";
 18  
         public final static int                FUNC_SID_DATE        = -2;
 19  
         public final static String        FUNC_NAME_ROOT        = "[root]";
 20  
         public final static int                FUNC_SID_ROOT        = -3;
 21  
 
 22  
         
 23  
         private        int                sid;
 24  
         private        String        name;
 25  
         private        String        description;
 26  0
         private        boolean        active = true;
 27  0
         private        boolean        metaSet = false;
 28  0
         private        boolean        microSet = false;
 29  0
         private boolean nanoSet = false;
 30  0
         private        Date        editDate = new Date();
 31  
 
 32  
         /** Default constructor, create an empty set.
 33  
          */
 34  0
         public Set() {
 35  0
         }
 36  
         
 37  
         /** Convienence constructor to preset some values.
 38  
          * @param sid The set id to set
 39  
          * @param name The name of this set
 40  
          */
 41  0
         public Set(int sid, String name) {
 42  0
                 this.sid = sid;
 43  0
                 this.name = name;
 44  0
         }
 45  
 
 46  
         /** Clone this set.
 47  
          * @return A copy of this Set.
 48  
          */
 49  
         public Set clone() {
 50  0
                 Set set = new Set();
 51  0
                 set.setSid(this.getSid());
 52  0
                 set.setName(this.getName());
 53  0
                 set.setDescription(this.getDescription());
 54  0
                 set.setActive(this.isActive());
 55  0
                 set.setMetaSet(this.isMetaSet());
 56  0
                 set.setMicroSet(this.isMicroSet());
 57  0
                 set.setNanoSet(this.isNanoSet());
 58  0
                 set.editDate.setTime(this.editDate.getTime());
 59  0
                 return(set);
 60  
         }
 61  
 
 62  
         
 63  
         /* (non-Javadoc)
 64  
          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 65  
          */
 66  
         public int compare(Set set0, Set set1) {
 67  0
                 if (!set1.name.equals(set0.name))
 68  0
                         return(set1.name.compareTo(set0.name));
 69  0
                 if (!set1.description.equals(set0.description))
 70  0
                         return(set1.description.compareTo(set0.description));
 71  0
                 if (set0.sid != set1.sid)
 72  0
                         return(set1.sid - set0.sid);
 73  0
                 if (set0.active != set1.active)
 74  0
                         return(set1.active ? 1 : -1);
 75  0
                 if (set0.metaSet != set1.metaSet)
 76  0
                         return(set1.metaSet ? 1 : -1);
 77  0
                 if (set0.microSet != set1.microSet)
 78  0
                         return(set1.microSet ? 1 : -1);
 79  0
                 if (set0.nanoSet != set1.nanoSet)
 80  0
                         return(set1.nanoSet ? 1 : -1);
 81  0
                 if (set0.editDate.getTime() != set1.editDate.getTime())
 82  0
                         return((int)(set1.editDate.getTime() - set0.editDate.getTime()));
 83  0
                 return 0;
 84  
         }
 85  
 
 86  
 
 87  
         /** Fetch the PicMan unique Set id.
 88  
          * @return Returns the set id.
 89  
          */
 90  
         public int getSid() {
 91  0
                 return sid;
 92  
         }
 93  
         /**
 94  
          * @param sid The set id to set.
 95  
          */
 96  
         public void setSid(int sid) {
 97  0
                 this.sid = sid;
 98  0
         }
 99  0
         public        void        setName(String name) { this.name = name; }
 100  0
         public        String        getName() { return(name); }
 101  
         
 102  
         /** Set the user's desciption of this set.
 103  
          * @param description
 104  
          */
 105  
         public void setDescription(String description) {
 106  0
                 this.description = description; 
 107  0
         }
 108  
 
 109  0
         public        String        getDescription() { return(description); }
 110  
         /**
 111  
          * @return Returns whether this Set is active.
 112  
          */
 113  
         public boolean isActive() {
 114  0
                 return active;
 115  
         }
 116  
         /**
 117  
          * @param active Set whether this Set is active.
 118  
          */
 119  
         public void setActive(boolean active) {
 120  0
                 this.active = active;
 121  0
         }
 122  
         /** Is this a metaSet?
 123  
          * @return Returns the metaSet flag.
 124  
          */
 125  
         public boolean isMetaSet() {
 126  0
                 return metaSet;
 127  
         }
 128  
         /**
 129  
          * @param metaSet The metaSet to set.
 130  
          */
 131  
         public void setMetaSet(boolean metaSet) {
 132  0
                 this.metaSet = metaSet;
 133  0
         }
 134  
         /** Is this a microSet?
 135  
          * @return the microSet
 136  
          */
 137  
         public boolean isMicroSet() {
 138  0
                 return microSet;
 139  
         }
 140  
         /**
 141  
          * @param microSet the microSet to set
 142  
          */
 143  
         public void setMicroSet(boolean microSet) {
 144  0
                 this.microSet = microSet;
 145  0
         }
 146  
         /** Is this a nanoSet?
 147  
          * A pic in a nanoSet contains a boolean yes/no value.
 148  
          * @return the nanoSet
 149  
          */
 150  
         public boolean isNanoSet() {
 151  0
                 return nanoSet;
 152  
         }
 153  
         /**
 154  
          * @param nanoSet the nanoSet to set
 155  
          */
 156  
         public void setNanoSet(boolean nanoSet) {
 157  0
                 this.nanoSet = nanoSet;
 158  0
         }
 159  
 
 160  
         public boolean        isFuncSet() {
 161  0
                 return(this.sid < -1);
 162  
         }
 163  
 
 164  
         /**
 165  
          * @return the editDate
 166  
          */
 167  
         public Date getEditDate() {
 168  0
                 return editDate;
 169  
         }
 170  
 
 171  
         /**
 172  
          * @param editDate the editDate to set
 173  
          */
 174  
         public void setEditDate(Date editDate) {
 175  0
                 this.editDate = editDate;
 176  0
         }
 177  
 
 178  
         /** Set the time of this set's edit to be now.
 179  
          */
 180  
         public void setEditDateNow() {
 181  0
                 this.editDate = new Date();
 182  0
         }
 183  
 }