/** Add a set of name-value pairs. */ public void addVariables(Parameters params) { String[] names = params.getNames(); for (int i=0; i<names.length; i++) { String paramVal = params.getParameter(names[i], null); if (paramVal != null) { vars.put(names[i], paramVal); } } }
/** * Create a <code>Parameters</code> object from a <code>Properties</code> * object. * * @param properties the Properties * @return This <code>Parameters</code> instance. */ public static Parameters fromProperties( final Properties properties ) { final Parameters parameters = new Parameters(); final Enumeration names = properties.propertyNames(); while( names.hasMoreElements() ) { final String key = names.nextElement().toString(); final String value = properties.getProperty( key ); parameters.setParameter( key, value ); } return parameters; }
/** * Create a <code>Parameters</code> object from a <code>Configuration</code> * object. This acts exactly like the following method call: * <pre> * Parameters.fromConfiguration(configuration, "parameter"); * </pre> * * @param configuration the Configuration * @return This <code>Parameters</code> instance. * @throws ConfigurationException if an error occurs */ public static Parameters fromConfiguration( final Configuration configuration ) throws ConfigurationException { return fromConfiguration( configuration, "parameter" ); }
public void parameterize(Parameters parameters) throws ParameterException { global_container_encoding = parameters.getParameter("container-encoding", "ISO-8859-1"); global_form_encoding = parameters.getParameter("form-encoding", null); global_generate_attributes = parameters.getParameterAsBoolean("generate-attributes", false); }
/** * Read sitemap parameters and set properties accordingly. */ private void evaluateParameters() { this.documentFixed = this.parameters.getParameterAsBoolean("fixed", false); this.fixed = this.documentFixed; this.prefix = this.parameters.getParameter("prefix", this.defaultPrefix); this.suffix = this.parameters.getParameter("suffix", this.defaultSuffix); this.inputName = this.parameters.getParameter("input", null); this.decorationSize = this.parameters.getParameterAsInteger("decoration", this.decorationSize); this.stripNumber = this.parameters.getParameterAsBoolean("strip-number", this.stripNumber); }
/** * Constructor * @param configuration The parameters configuring this session * @param proxy The proxy used to cache the data */ IncludeCacheManagerSession(Parameters configuration, IncludeCacheStorageProxy proxy) { this.expires = configuration.getParameterAsLong("expires", 0); this.purge = configuration.getParameterAsBoolean("purge", false); this.preemptive = configuration.getParameterAsBoolean("preemptive", false); this.parallel = configuration.getParameterAsBoolean("parallel", false); this.storage = proxy; }
/** BEGIN SitemapComponent methods **/ public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws ProcessingException, SAXException, IOException { this.counter=0; this.currentBlocknr=0; this.skip=false; this.foundIt=false; this.parentName=null; this.elementName = parameters.getParameter(ELEMENT, ""); this.count = parameters.getParameterAsInteger(COUNT, DEFAULT_COUNT); this.blocknr = parameters.getParameterAsInteger(BLOCKNR, DEFAULT_BLOCK); if (this.elementName == null || this.elementName.equals("") || this.count == 0) { throw new ProcessingException("FilterTransformer: both "+ ELEMENT + " and " + COUNT + " parameters need to be specified"); } }
public String getParameter(String arg0) throws ParameterException { return wrappedParameters.getParameter(arg0); }
final Parameters params = new Parameters(); if (sp != null) { SourceParameters remainingParameters = (SourceParameters) sp.clone(); String name = (String) names.next(); if (name.startsWith("cocoon:cache")) { params.setParameter(name.substring("cocoon:".length()), sp.getParameter(name)); remainingParameters.removeParameter(name); int expires = params.getParameterAsInteger(CachingSource.CACHE_EXPIRES_PARAM, this.defaultExpires); String cacheName = params.getParameter(CachingSource.CACHE_NAME_PARAM, null); boolean fail = params.getParameterAsBoolean(CachingSource.CACHE_FAIL_PARAM, false);
this.depth = par.getParameterAsInteger("depth", 1); this.cacheKeyParList.add(String.valueOf(this.depth)); String dateFormatString = par.getParameter("dateFormat", null); this.cacheKeyParList.add(dateFormatString); if (dateFormatString != null) { String locale = par.getParameter("locale", null); if (locale != null) { this.dateFormatter = new SimpleDateFormat(dateFormatString, new Locale(locale, "")); String timeZone = par.getParameter("timeZone", null); if (timeZone != null) { this.dateFormatter.setTimeZone(TimeZone.getTimeZone(timeZone)); this.sort = par.getParameter("sort", "name"); this.cacheKeyParList.add(this.sort); this.reverse = par.getParameterAsBoolean("reverse", false); this.cacheKeyParList.add(String.valueOf(this.reverse)); this.refreshDelay = par.getParameterAsLong("refreshDelay", 1L) * 1000L; this.cacheKeyParList.add(String.valueOf(this.refreshDelay)); rePattern = par.getParameter("root", null); if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("root pattern: " + rePattern); rePattern = par.getParameter("include", null); if (this.getLogger().isDebugEnabled()) {
ContainerUtil.parameterize( component, Parameters.fromConfiguration( m_configuration ) ); m_classinfo.m_setParametersMethod.invoke( component, new Object[] {Parameters.fromConfiguration( m_configuration )}); final Parameters p = Parameters.fromConfiguration( m_configuration ); String[] names = p.getNames(); for( int i = 0; i < names.length; i++ ) BeanUtils.setProperty( component, names[i], p.getParameter(names[i]));
/** * Merge parameters from another <code>Parameters</code> instance * into this. * * @param other the other Parameters * @return This <code>Parameters</code> instance. */ public Parameters merge( final Parameters other ) { checkWriteable(); final String[] names = other.getNames(); for( int i = 0; i < names.length; i++ ) { final String name = names[ i ]; String value = null; try { value = other.getParameter( name ); } catch( final ParameterException pe ) { value = null; } setParameter( name, value ); } return this; }
/** * Read reader configuration * * @deprecated use property injection instead */ public void configure(Configuration configuration) throws ConfigurationException { // VG Parameters are deprecated as of 2.2.0-Dev/2.1.6-Dev final Parameters parameters = Parameters.fromConfiguration(configuration); this.setExpires(parameters.getParameterAsLong("expires", CONFIGURED_EXPIRES_DEFAULT)); this.setQuickTest(parameters.getParameterAsBoolean("quick-modified-test", CONFIGURED_QUICK_TEST_DEFAULT)); this.setBufferSize(parameters.getParameterAsInteger("buffer-size", CONFIGURED_BUFFER_SIZE_DEFAULT)); this.setByteRanges(parameters.getParameterAsBoolean("byte-ranges", CONFIGURED_BYTE_RANGES_DEFAULT)); // Configuration has precedence over parameters. setExpires(configuration.getChild("expires").getValueAsLong(configuredExpires)); setQuickTest(configuration.getChild("quick-modified-test").getValueAsBoolean(configuredQuickTest)); setBufferSize(configuration.getChild("buffer-size").getValueAsInteger(configuredBufferSize)); setByteRanges(configuration.getChild("byte-ranges").getValueAsBoolean(configuredByteRanges)); }
String tmpWidth = par.getParameter("width", "0"); String tmpHeight = par.getParameter("height", "0"); this.scaleColor[0] = par.getParameterAsFloat("scaleRed", -1.0f); this.scaleColor[1] = par.getParameterAsFloat("scaleGreen", -1.0f); this.scaleColor[2] = par.getParameterAsFloat("scaleBlue", -1.0f); this.offsetColor[0] = par.getParameterAsFloat("offsetRed", 0.0f); this.offsetColor[1] = par.getParameterAsFloat("offsetGreen", 0.0f); this.offsetColor[2] = par.getParameterAsFloat("offsetBlue", 0.0f); this.quality[0] = par.getParameterAsFloat("quality", 0.9f); if (par.getParameterAsBoolean("grayscale", GRAYSCALE_DEFAULT)) { this.grayscaleFilter = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); this.enlarge = par.getParameterAsBoolean("allow-enlarging", ENLARGE_DEFAULT); this.fitUniform = par.getParameterAsBoolean("fit-uniform", FIT_DEFAULT);
/** * Set the component up, pulling any configuration values from the sitemap * parameters. */ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, parameters); depth = parameters.getParameterAsInteger("depth", DEFAULT_DEPTH); excludeCollections = parameters.getParameterAsBoolean( "exclude-collections", false); }
public int getParameterAsInteger(String arg0, int arg1) { return wrappedParameters.getParameterAsInteger(arg0, arg1); }
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); this.request = ObjectModelHelper.getRequest(objectModel); this.response = ObjectModelHelper.getResponse(objectModel); this.expires = par.getParameterAsLong("expires", this.configuredExpires); this.encoding = par.getParameter("encoding", this.configuredEncoding); try { this.inputSource = resolver.resolveURI(src); } catch (SourceException e) { throw SourceUtil.handle("Error during resolving of '" + src + "'.", e); } setupHeaders(); }
/** * Setup the reader. * The resource is opened to get an <code>InputStream</code>, * the length and the last modification date */ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); this.request = ObjectModelHelper.getRequest(objectModel); this.response = ObjectModelHelper.getResponse(objectModel); this.expires = par.getParameterAsLong("expires", this.configuredExpires); this.quickTest = par.getParameterAsBoolean("quick-modified-test", this.configuredQuickTest); this.bufferSize = par.getParameterAsInteger("buffer-size", this.configuredBufferSize); this.byteRanges = par.getParameterAsBoolean("byte-ranges", this.configuredByteRanges); try { this.inputSource = resolver.resolveURI(src); } catch (SourceException e) { throw SourceUtil.handle("Error during resolving of '" + src + "'.", e); } setupHeaders(); }
/** * Load the parameters * * @param location The location as a file * @param isEncrypted is the file encrypted * @return The loaded configuration * @throws Exception Something went wrong */ private Parameters loadParameters(String location, String isEncrypted) throws Exception { InputStreamLocator locator = this.createInputStreamLocator(); InputStream is = locator.locate(location); Parameters result = new Parameters(); if (is != null) { try { is = this.getDecryptingInputStream(is, isEncrypted); Properties props = new Properties(); props.load(is); result = Parameters.fromProperties(props); } finally { safeClose(is); } } return result; }
/** * @see org.apache.avalon.framework.activity.Disposable#dispose() */ public void dispose() { this.serviceManager = null; this.parameters = new Parameters(); this.context = new DefaultContext(); ServiceManagerServiceImpl.instance = null; }