1 package net.sf.invicta.handler; 2 3 import java.util.List ; 4 import java.util.Map ; 5 6 import net.sf.invicta.InvictaException; 7 import net.sf.invicta.api.DefinedProperty; 8 import net.sf.invicta.api.InvictaComponent; 9 10 21 public class ActualPropertyValueHandler extends InvictaBasicHandler { 22 23 26 public String getName() { 27 return "actualPropertyValue"; 28 } 29 30 33 public String handle(Map paramsMap) throws InvictaException { 34 35 InvictaComponent useComponent = getComponent(); 36 String propertyName = getRequiredParameter("name"); 37 String componentName = getParameter("component"); 38 39 if (componentName != null) { 41 useComponent = getProject().getComponent(componentName); 42 } 43 44 return getActualPropertyValue(propertyName, useComponent); 45 } 46 47 50 public String handle(List params) throws InvictaException { 51 52 InvictaComponent useComponent = getComponent(); 53 String propertyName = getRequiredParameter(0); 54 return getActualPropertyValue(propertyName, useComponent); 55 } 56 57 60 protected String getActualPropertyValue(String propertyName, InvictaComponent useComponent) throws InvictaHandlerException { 61 DefinedProperty property = useComponent.getDefinedProperty(propertyName); 62 if (property == null) { 63 throw new InvictaHandlerException 64 (this, "Property '" + propertyName + 65 "' not defined for component '" + useComponent.getName() + 66 "' (type '" + useComponent.getTypeName() + "')"); 67 } 68 return property.getActualValue(); 69 } 70 71 } 72 | Popular Tags |