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 ; 8 import java.util.HashMap ; 9 import java.io.IOException ; 10 11 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 relativePath) throws IOException 29 { 30 return getCurrentFile().getResource(relativePath); 31 } 32 33 public Resource getCurrentFile() 34 { 35 return this.instructions.getFile(); 36 } 37 38 public Map getParameters() 39 { 40 return this.instructions.getParameters(); 41 } 42 43 public Object getParameter(String name) throws JICException 44 { 45 Map parameters = getParameters(); 46 if( parameters != null ){ 47 Object 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 |