View Javadoc

1   package net.sf.jpkgmk.prototype;
2   
3   import java.io.File;
4   import java.io.IOException;
5   import java.util.List;
6   
7   import net.sf.jpkgmk.pkgmap.PkgMapEntry;
8   import net.sf.jpkgmk.util.StringUtil;
9   import net.sf.jpkgmk.util.VariableResolver;
10  
11  import org.apache.commons.logging.Log;
12  import org.apache.commons.logging.LogFactory;
13  
14  /**
15   * A default value holding defaults for the mode, owner and group of a file.
16   * 
17   * @author gommma (gommma AT users.sourceforge.net)
18   * @author Last changed by: $Author: gommma $
19   * @version $Revision: 2 $ $Date: 2008-08-20 21:14:19 +0200 (Mi, 20 Aug 2008) $
20   * @since 1.0
21   */
22  public class PrototypeEntryCommandDefault extends PrototypeEntryCommand
23  {
24  	private Log log = LogFactory.getLog(PrototypeEntryCommandDefault.class);
25  
26  	private String mode;
27  	private String owner;
28  	private String group;
29  
30  	public PrototypeEntryCommandDefault(String mode, String owner, String group)
31  	{
32  		super(CommandType.DEFAULT);
33  		if(mode==null) {
34  			throw new NullPointerException("The parameter 'mode' must not be null");
35  		}
36  		if(owner==null) {
37  			throw new NullPointerException("The parameter 'owner' must not be null");
38  		}
39  		if(group==null) {
40  			throw new NullPointerException("The parameter 'group' must not be null");
41  		}
42  		
43  		this.mode = mode;
44  		this.owner = owner;
45  		this.group = group;
46  	}
47  
48      @Override
49  	protected String getCommandLinePart() {
50  		StringBuffer sb = new StringBuffer();
51  		if(!StringUtil.isNullOrEmpty(mode)) {
52  			sb.append(mode);
53  		}
54  		if(!StringUtil.isNullOrEmpty(owner)) {
55  			sb.append(" ").append(owner);
56  		}
57  		if(!StringUtil.isNullOrEmpty(group)) {
58  			sb.append(" ").append(group);
59  		}
60  		return sb.toString();
61  	}
62  
63  	public List<PkgMapEntry> createPkgMapEntry(File basedir, VariableResolver variableResolver) {
64  		// Execute the command and add all necessary entries to the map and to the pkginfo file
65  		log.debug("<Entering> createPkgMapEntry() - nothing to do here");
66  		return null;
67  	}
68  
69  	public void create(File basedir, VariableResolver variableResolver) throws IOException {
70  		log.debug("<Entering> create(File basedir) - nothing to do here");
71  	}
72  
73  	public String getMode() {
74  		return mode;
75  	}
76  
77  	public String getOwner() {
78  		return owner;
79  	}
80  
81  	public String getGroup() {
82  		return group;
83  	}
84  
85      @Override
86  	public String toString()
87  	{
88  		StringBuffer sb = new StringBuffer();
89  		sb.append(super.toString());
90  		sb.append(this.getClass().getName()).append("[");
91  		sb.append("mode=").append(this.mode);
92  		sb.append(",owner=").append(this.owner);
93  		sb.append(",group=").append(this.group);
94  		sb.append("]");
95  		return sb.toString();
96  	}
97  }