| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ContactParams |
|
| 1.96;1.96 |
| 1 | /****************************************************************************** | |
| 2 | * ContactParams.java - Define how to make one contact sheet | |
| 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.text.DecimalFormat; | |
| 11 | ||
| 12 | import org.apache.commons.logging.Log; | |
| 13 | import org.apache.commons.logging.LogFactory; | |
| 14 | ||
| 15 | /** Define the rules to make one contact sheet. | |
| 16 | * @author Dick Balaska | |
| 17 | * @since 2005/08/07 | |
| 18 | * @see <a href="http://cvs.buckosoft.com/Projects/PicMan/PicMan/src/main/java/com/buckosoft/PicMan/domain/ContactParams.java">ContactParams.java</a> | |
| 19 | */ | |
| 20 | public class ContactParams { | |
| 21 | private static final boolean DEBUG = false; | |
| 22 | 0 | protected final Log logger = LogFactory.getLog(getClass()); |
| 23 | ||
| 24 | private int cid; | |
| 25 | private String setName; | |
| 26 | private int size; | |
| 27 | private int rankMin; | |
| 28 | private int rankMax; | |
| 29 | private String engineName; | |
| 30 | ||
| 31 | private String outputDirectory; | |
| 32 | private int contactNumber; | |
| 33 | // private int typeHint; | |
| 34 | ||
| 35 | 0 | public ContactParams() {} |
| 36 | ||
| 37 | 0 | public ContactParams(int cid, String setName, int size, int item) { |
| 38 | 0 | this.cid = cid; |
| 39 | 0 | this.setName = setName; |
| 40 | 0 | this.size = size; |
| 41 | 0 | this.contactNumber = item; |
| 42 | 0 | } |
| 43 | 0 | public ContactParams(SetSize setSize) { |
| 44 | 0 | setSetSize(setSize); |
| 45 | 0 | } |
| 46 | ||
| 47 | /** Compare two ContactParams for equality.<br> | |
| 48 | * Compare chain, setName, size, and contactNumber.<br> | |
| 49 | * either size = -1 is a wildcard and will match (contactNumber is ignored in this case).<br> | |
| 50 | * either contactNumber = -1 is a wildcard and will match. | |
| 51 | * @param other The other ContactParams to compare to. | |
| 52 | * @return equality | |
| 53 | */ | |
| 54 | public boolean equals(ContactParams other) { | |
| 55 | if (DEBUG) | |
| 56 | logger.info("equals: " + this.setName + "/" + this.size + "/" + this.contactNumber + " : " + other.setName + "/" + other.size + "/" + other.contactNumber); | |
| 57 | 0 | if (this.cid != other.cid) |
| 58 | 0 | return(false); |
| 59 | 0 | if (!this.setName.equals(other.setName)) |
| 60 | 0 | return(false); |
| 61 | 0 | if (this.size == -1 |
| 62 | || other.size == -1) | |
| 63 | 0 | return(true); |
| 64 | 0 | if (this.size != other.size) |
| 65 | 0 | return(false); |
| 66 | 0 | if (this.contactNumber == -1 |
| 67 | || other.contactNumber == -1) | |
| 68 | 0 | return(true); |
| 69 | 0 | if (this.contactNumber == other.contactNumber) |
| 70 | 0 | return(true); |
| 71 | 0 | return(false); |
| 72 | } | |
| 73 | ||
| 74 | /** Compare two ContactParams for equality.<br> | |
| 75 | * Compare setName, size, min/max.<br> | |
| 76 | * Basically, we are checking if these two ContactParams will select the same set of Pics. | |
| 77 | * @param other The other ContactParams to compare to. | |
| 78 | * @return equality | |
| 79 | */ | |
| 80 | public boolean equalsPics(ContactParams other) { | |
| 81 | if (DEBUG) | |
| 82 | logger.info("equals: " + this.setName + "/" + this.size + "/" + this.contactNumber + " : " + other.setName + "/" + other.size + "/" + other.contactNumber); | |
| 83 | 0 | if (!this.setName.equals(other.setName)) |
| 84 | 0 | return(false); |
| 85 | 0 | if (this.size != other.size) |
| 86 | 0 | return(false); |
| 87 | 0 | if (this.rankMin != other.rankMin) |
| 88 | 0 | return(false); |
| 89 | 0 | if (this.rankMax != other.rankMax) |
| 90 | 0 | return(false); |
| 91 | 0 | return(true); |
| 92 | ||
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * @return Returns the cid. | |
| 97 | */ | |
| 98 | public int getCid() { | |
| 99 | 0 | return cid; |
| 100 | } | |
| 101 | ||
| 102 | /** | |
| 103 | * @param cid The cid to set. | |
| 104 | */ | |
| 105 | public void setCid(int cid) { | |
| 106 | 0 | this.cid = cid; |
| 107 | 0 | } |
| 108 | ||
| 109 | public void setSetSize(SetSize setSize) { | |
| 110 | 0 | this.setName = setSize.getSetName(); |
| 111 | 0 | this.size = setSize.getSize(); |
| 112 | 0 | } |
| 113 | ||
| 114 | public String getSetName() { | |
| 115 | 0 | return setName; |
| 116 | } | |
| 117 | public void setSetName(String setName) { | |
| 118 | 0 | this.setName = setName; |
| 119 | 0 | } |
| 120 | ||
| 121 | /** Get the thumbnail size we should draw in | |
| 122 | * @return most likely 75,100,150,200 or 300 | |
| 123 | */ | |
| 124 | public int getSize() { | |
| 125 | 0 | return size; |
| 126 | } | |
| 127 | ||
| 128 | /** Set the thumbnail size we should draw in | |
| 129 | * @param size most likely 75,100,150,200 or 300 | |
| 130 | */ | |
| 131 | public void setSize(int size) { | |
| 132 | 0 | this.size = size; |
| 133 | 0 | } |
| 134 | ||
| 135 | public String getOutputDirectory() { | |
| 136 | 0 | return outputDirectory; |
| 137 | } | |
| 138 | public void setOutputDirectory(String outputDirectory) { | |
| 139 | 0 | this.outputDirectory = outputDirectory; |
| 140 | 0 | } |
| 141 | public int getContactNumber() { | |
| 142 | 0 | return contactNumber; |
| 143 | } | |
| 144 | public void setContactNumber(int contactNumber) { | |
| 145 | 0 | this.contactNumber = contactNumber; |
| 146 | 0 | } |
| 147 | ||
| 148 | 0 | private static DecimalFormat df2 = new DecimalFormat("00"); |
| 149 | 0 | private static DecimalFormat df3 = new DecimalFormat("000"); |
| 150 | /** Return a String which is the Uuid of a set/size/item combo | |
| 151 | * @return Something that looks like: mlb-075-001 | |
| 152 | */ | |
| 153 | public String getUuid() { | |
| 154 | 0 | return(new String(getSetName() |
| 155 | 0 | + "-" + df3.format(getSize()) |
| 156 | 0 | + "-" + df2.format(getContactNumber()))); |
| 157 | } | |
| 158 | ||
| 159 | /** Return a String which is the Uuid of a set/size combo. | |
| 160 | * Not so much a Uuid, per se. because the item is unknown, | |
| 161 | * so we call it a uid. */ | |
| 162 | public String getUid() { | |
| 163 | 0 | DecimalFormat df3 = new DecimalFormat("000"); |
| 164 | 0 | return(new String(getSetName() |
| 165 | 0 | + "-" + df3.format(getSize()))); |
| 166 | } | |
| 167 | ||
| 168 | /** | |
| 169 | * @return Returns the rankMax. | |
| 170 | */ | |
| 171 | public int getRankMax() { | |
| 172 | 0 | return rankMax; |
| 173 | } | |
| 174 | ||
| 175 | /** | |
| 176 | * @param rankMax The rankMax to set. | |
| 177 | */ | |
| 178 | public void setRankMax(int rankMax) { | |
| 179 | 0 | this.rankMax = rankMax; |
| 180 | 0 | } |
| 181 | ||
| 182 | /** | |
| 183 | * @return Returns the rankMin. | |
| 184 | */ | |
| 185 | public int getRankMin() { | |
| 186 | 0 | return rankMin; |
| 187 | } | |
| 188 | ||
| 189 | /** | |
| 190 | * @param rankMin The rankMin to set. | |
| 191 | */ | |
| 192 | public void setRankMin(int rankMin) { | |
| 193 | 0 | this.rankMin = rankMin; |
| 194 | 0 | } |
| 195 | ||
| 196 | /** Convienence method to set the min and max ratings in one call. | |
| 197 | * | |
| 198 | * @param min | |
| 199 | * @param max | |
| 200 | */ | |
| 201 | public void setRankMinMax(int min, int max) { | |
| 202 | 0 | this.rankMin = min; |
| 203 | 0 | this.rankMax = max; |
| 204 | 0 | } |
| 205 | ||
| 206 | /** Get the name of the engine that is to build these contacts | |
| 207 | * @return the engineName | |
| 208 | */ | |
| 209 | public String getEngineName() { | |
| 210 | 0 | return engineName; |
| 211 | } | |
| 212 | ||
| 213 | /** Set the name of the engine that is to build these contacts | |
| 214 | * @param engineName the engineName to set | |
| 215 | */ | |
| 216 | public void setEngineName(String engineName) { | |
| 217 | 0 | this.engineName = engineName; |
| 218 | 0 | } |
| 219 | ||
| 220 | } |