1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import org.openlaszlo.iv.flash.parser.*; 54 import org.openlaszlo.iv.flash.api.*; 55 import org.openlaszlo.iv.flash.util.*; 56 57 import org.openlaszlo.iv.flash.context.*; 58 59 import java.io.*; 60 import java.util.*; 61 62 65 66 public class GenericXMLCommand extends GenericCommand { 67 68 protected String datasource; 69 protected String select; 70 71 74 protected void initParms( Context context ) throws IVException { 75 datasource = getParameter( context, "datasource" ); 76 select = getParameter( context, "select" ); 77 } 78 79 85 86 protected GraphContext retrieveGraphContext( Context context ) 87 { 88 while ( context != null && ! ( context instanceof GraphContext ) ) 89 { 90 context = context.getParent(); 91 } 92 93 return ( GraphContext ) context; 94 } 95 96 106 107 protected GraphContext getGraphContext( FlashFile file, Context context ) throws IVException 108 { 109 if ( datasource != null ) 110 { 111 try 112 { 113 return ( GraphContext ) 114 ContextFactory.createContext( context, datasource, file, false ); 115 } 116 catch( Exception e ) 117 { 118 throw new IVException(Resource.ERRDATAREAD, new Object [] {datasource, getCommandName()}, e); 119 } 120 } 121 else 122 { 123 return retrieveGraphContext( context ); 124 } 125 } 126 127 135 136 protected String evalStringParameter ( Context context, String path, String def ) 137 { 138 String rval = context.getValue ( path ); 139 140 if ( rval == null ) 141 { 142 return def; 143 } 144 else 145 { 146 return rval; 147 } 148 } 149 150 158 159 protected boolean evalBoolParameter ( Context context, String path, boolean def ) 160 { 161 return Util.toBool( context.getValue( path ), def ); 162 } 163 164 172 173 protected int evalIntParameter( Context context, String path, int def ) 174 { 175 return Util.toInt( context.getValue( path ), def ); 176 } 177 178 186 protected double evalDoubleParameter( Context context, String path, double def ) 187 { 188 return Util.toDouble( context.getValue( path ), def ); 189 } 190 } 191 192 | Popular Tags |