View Javadoc
1   /******************************************************************************
2    * SetSize - Convienence class to manipulate a Set/Size pair as a single entity
3    * 
4    * PicMan - The BuckoSoft Picture Manager in Java
5    * Copyright(c) 2006 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.PicMan.domain;
9   
10  import java.text.DecimalFormat;
11  
12  /** Convienence class to manipulate a Set/Size pair as a single entity.
13   * Size = 0 = wildcard and matches anyother SetSize
14   */
15  public class SetSize {
16  	private String	setName;
17  	private	int		size;
18  
19  	private static final DecimalFormat df3 = new DecimalFormat("000");
20  
21  	/** Default Constructor. */
22  	public	SetSize() {}
23  	
24  	/** Construct a SetSize from this string of the form SetName_075
25  	 * @param setSizeName The string to convert to a SetSize.
26  	 */
27  	public	SetSize(String setSizeName) {
28  		setSetSize(setSizeName);
29  	}
30  
31  	/** Construct a SetSize from this setName and size 
32  	 * @param setName The name of the Set
33  	 * @param size The size of the new SetSize
34  	 */
35  	public SetSize(String setName, int size) {
36  		this.setName = setName;
37  		this.size = size;
38  	}
39  
40  	public	String	getGuiSetSize() {
41  		return(new String(getSetName() 
42  							+ "_" + df3.format(getSize())));
43  	}
44  	public	String	getSetSizeDash() {
45  		return(new String(getSetName() 
46  							+ "-" + df3.format(getSize())));
47  	}
48  	public	void setSetSize(String setSize) {
49  		int i = setSize.indexOf('_');
50  		if (i != -1) {
51  			setSetName(setSize.substring(0,i));
52  			setSize(Integer.parseInt(setSize.substring(i+1,setSize.length())));
53  			return;
54  		}
55  		i = setSize.indexOf('-');
56  		if (i != -1) {
57  			setSetName(setSize.substring(0,i));
58  			setSize(Integer.parseInt(setSize.substring(i+1,setSize.length())));
59  			return;
60  		}
61  		
62  		setSetName(setSize);
63  		setSize(0);
64  	}
65  
66  	public String getSetSize() {
67  		return(setName + "_" + size);
68  	}
69  
70  	public String getSetName() {
71  		return setName;
72  	}
73  	public void setSetName(String set) {
74  		this.setName = set;
75  	}
76  	public int getSize() {
77  		return size;
78  	}
79  	public void setSize(int size) {
80  		this.size = size;
81  	}
82  }