KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jicengine > builder > BuildContextImpl


1 package org.jicengine.builder;
2
3 import org.jicengine.Instructions;
4 import org.jicengine.BuildContext;
5 import org.jicengine.JICException;
6 import org.jicengine.io.Resource;
7 import java.util.Map JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.io.IOException JavaDoc;
10
11 /**
12  * <p>
13  * Copyright (C) 2004 Timo Laitinen
14  * </p>
15  *
16  * @author .timo
17  */

18
19 public class BuildContextImpl implements BuildContext {
20
21     private Instructions instructions;
22
23     public BuildContextImpl(Instructions instructions)
24     {
25         this.instructions = instructions;
26     }
27
28     public Resource getResource(String JavaDoc relativePath) throws IOException JavaDoc
29     {
30         return getCurrentFile().getResource(relativePath);
31     }
32
33     public Resource getCurrentFile()
34     {
35         return this.instructions.getFile();
36     }
37
38     public Map JavaDoc getParameters()
39     {
40         return this.instructions.getParameters();
41     }
42
43     public Object JavaDoc getParameter(String JavaDoc name) throws JICException
44     {
45         Map JavaDoc parameters = getParameters();
46         if( parameters != null ){
47             Object JavaDoc parameter = parameters.get(name);
48             if( parameter != null ){
49                 return parameter;
50             }
51             else {
52                 throw new JICException("Parameter '" + name + "' not found. available parameters: " + parameters);
53             }
54         }
55         else {
56             throw new JICException("Parameter '" + name + "' not found. (0 parameters available)");
57         }
58     }
59 }
60
Popular Tags