01: package org.jicengine.builder;
02:
03: import org.jicengine.Instructions;
04: import org.jicengine.BuildContext;
05: import org.jicengine.JICException;
06: import org.jicengine.io.Resource;
07: import java.util.Map;
08: import java.util.HashMap;
09: import java.io.IOException;
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: this .instructions = instructions;
25: }
26:
27: public Resource getResource(String relativePath) throws IOException {
28: return getCurrentFile().getResource(relativePath);
29: }
30:
31: public Resource getCurrentFile() {
32: return this .instructions.getFile();
33: }
34:
35: public Map getParameters() {
36: return this .instructions.getParameters();
37: }
38:
39: public Object getParameter(String name) throws JICException {
40: Map parameters = getParameters();
41: if (parameters != null) {
42: Object parameter = parameters.get(name);
43: if (parameter != null) {
44: return parameter;
45: } else {
46: throw new JICException("Parameter '" + name
47: + "' not found. available parameters: "
48: + parameters);
49: }
50: } else {
51: throw new JICException("Parameter '" + name
52: + "' not found. (0 parameters available)");
53: }
54: }
55: }
|