source: DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/requirements/ResourceRequirements.java @ 477

Revision 477, 1.6 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.scheduling.tasks.requirements;
2
3import java.io.StringWriter;
4import java.io.Writer;
5
6import org.exolab.castor.xml.Marshaller;
7import org.exolab.castor.xml.ResolverException;
8import org.exolab.castor.xml.XMLContext;
9
10
11import schedframe.scheduling.tasks.TaskInterface;
12import org.qcg.broker.schemas.resreqs.Task;
13
14/**
15 *
16 * @author Marcin Krystek
17 *
18 */
19public class ResourceRequirements extends AbstractResourceRequirements<Task>{
20
21        protected static Marshaller marshaller;
22        static {
23                XMLContext context = new XMLContext();
24                try {
25                        context.addClass(org.qcg.broker.schemas.resreqs.Task.class);
26                        marshaller = context.createMarshaller();
27                } catch (ResolverException e) {
28                        e.printStackTrace();
29                        marshaller = null;
30                }
31        }
32       
33        protected TaskInterface<?> task;
34       
35        public ResourceRequirements(Task task){
36                this.task = new schedframe.scheduling.tasks.Task(task);
37                this.resourceRequirements = task;
38        }
39       
40        public ResourceRequirements(TaskInterface<?> task){
41                this.task = task;
42                this.resourceRequirements = (Task) task.getDescription();
43        }
44       
45        public double getParameterDoubleValue(ResourceParameterName parameterName)
46                        throws NoSuchFieldException, IllegalArgumentException {
47                return task.getParameterDoubleValue(parameterName);
48        }
49
50        public String getParameterStringValue(ResourceParameterName parameterName)
51                        throws NoSuchFieldException, IllegalArgumentException {
52                return task.getParameterStringValue(parameterName);
53        }
54
55        public Task getDescription() {
56                return this.resourceRequirements;
57        }
58
59        public String getDocument() throws Exception {
60                Writer w = new StringWriter();
61               
62                marshaller.marshal(this.resourceRequirements, w);
63
64                return w.toString();
65        }
66
67}
Note: See TracBrowser for help on using the repository browser.