private static FontQualifier getQualfierFromConfiguration(Configuration cfg) throws FOPException { String fontFamily = cfg.getAttribute("font-family", null); if (fontFamily == null) { throw new FOPException("substitution qualifier must have a font-family"); } FontQualifier qualifier = new FontQualifier(); qualifier.setFontFamily(fontFamily); String fontWeight = cfg.getAttribute("font-weight", null); if (fontWeight != null) { qualifier.setFontWeight(fontWeight); } String fontStyle = cfg.getAttribute("font-style", null); if (fontStyle != null) { qualifier.setFontStyle(fontStyle); } return qualifier; }
if (cfg.getChild("use-cache", false) != null) { try { fontManager.setUseCache( cfg.getChild("use-cache").getValueAsBoolean()); } catch (ConfigurationException mfue) { LogUtil.handleException(log, mfue, true); if (cfg.getChild("font-base", false) != null) { try { fontManager.setFontBaseURL( cfg.getChild("font-base").getValue(null)); } catch (MalformedURLException mfue) { LogUtil.handleException(log, mfue, true); Configuration fontsCfg = cfg.getChild("fonts", false); if (fontsCfg != null) { Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false); if (substitutionsCfg != null) { FontSubstitutionsConfigurator fontSubstitutionsConfigurator Configuration referencedFontsCfg = fontsCfg.getChild("referenced-fonts", false); if (referencedFontsCfg != null) { createReferencedFontsMatcher(referencedFontsCfg, strict, fontManager);
private static void createReferencedFontsMatcher(Configuration referencedFontsCfg, boolean strict, FontManager fontManager) throws FOPException { List matcherList = new java.util.ArrayList(); Configuration[] matches = referencedFontsCfg.getChildren("match"); for (int i = 0; i < matches.length; i++) { try { matcherList.add(new FontFamilyRegExFontTripletMatcher( matches[i].getAttribute("font-family"))); } catch (ConfigurationException ce) { LogUtil.handleException(log, ce, strict); continue; } } FontTriplet.Matcher orMatcher = new OrFontTripletMatcher( (FontTriplet.Matcher[])matcherList.toArray( new FontTriplet.Matcher[matcherList.size()])); fontManager.setReferencedFontsMatcher(orMatcher); }
/** * Configure user manager - third step. */ public void configure(Configuration config) throws ConfigurationException { mConfig = config; Configuration adminConf = mConfig.getChild("ftp-admin-name", false); mstAdminName = "admin"; if(adminConf != null) { mstAdminName = adminConf.getValue(mstAdminName); } mBaseDirectory = config.getChild("base-directory").getValue(null); if(mBaseDirectory == null) throw new ConfigurationException("Missing configuration element 'base-directory'"); }
/** * Configures a font substitution catalog * * @param substitutions font substitutions * @throws FOPException if something's wrong with the config data */ public void configure(FontSubstitutions substitutions) throws FOPException { Configuration[] substitutionCfgs = cfg.getChildren("substitution"); for (int i = 0; i < substitutionCfgs.length; i++) { Configuration fromCfg = substitutionCfgs[i].getChild("from", false); if (fromCfg == null) { throw new FOPException("'substitution' element without child 'from' element"); } Configuration toCfg = substitutionCfgs[i].getChild("to", false); if (fromCfg == null) { throw new FOPException("'substitution' element without child 'to' element"); } FontQualifier fromQualifier = getQualfierFromConfiguration(fromCfg); FontQualifier toQualifier = getQualfierFromConfiguration(toCfg); FontSubstitution substitution = new FontSubstitution(fromQualifier, toQualifier); substitutions.add(substitution); } } }
/** * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) */ public void configure(Configuration config) throws ConfigurationException { this.cacheCheckFrequency = config.getChild("cacheCheckFrequency") .getValueAsLong(DEFAULT_CACHE_CHECK_FREQUENCY); this.cacheName = config.getChild("cacheName").getValue(DEFAULT_CACHE_NAME); this.configFile = config.getChild("configurationFile").getValue(null); }
protected Configuration getAndCreateConfiguration(Configuration config, String name) { if (config.getChild(name, false) == null) { final DefaultConfiguration newConfig = new DefaultConfiguration(name, config.getLocation()); ((DefaultConfiguration) config).addChild(newConfig); } return config.getChild(name, false); }
/** * Helper method to obtain the debug glag to use from the given * configuration object. * * @param config a <code>Configuration</code> instance * @return subject line */ private boolean getDebug( Configuration config ) throws ConfigurationException { return config.getChild( "debug" ).getValueAsBoolean(); }
/** * Add all the attributes, children and value * from specified configuration element to current * configuration element. * * @param other the {@link Configuration} element */ public void addAll( final Configuration other ) { checkWriteable(); setValue( other.getValue( null ) ); addAllAttributes( other ); addAllChildren( other ); }
/** * Helper method to obtain the maximum delay time any particular SMTP * message can be queued from a given configuration object. * * @param config a <code>Configuration</code> instance * @return maximum SMTP mail delay time */ private int getMaxDelayTime( Configuration config ) throws ConfigurationException { return config.getChild( "maximum-delay-time" ).getValueAsInteger( 0 ); }
/** * Avalon component lifecycle method */ public void configure(Configuration conf) throws ConfigurationException { this.cacheCheckFrequency = conf.getAttributeAsLong( CACHE_CHECK_FREQUENCY, DEFAULT_CACHE_CHECK_FREQUENCY); this.cacheInitialSize = conf.getAttributeAsInteger(INITIAL_CACHE_SIZE, DEFAULT_INITIAL_CACHE_SIZE); }
/** * Configuration of the handler under which the minimum pool size * is established. * @param configuration the configuration fragment */ public void configure( final Configuration configuration ) { m_poolMin = configuration.getAttributeAsInteger( "pool-min", 10 ); }
/** * The toString() operation is used for debugging information. It does * not create a deep reproduction of this configuration and all child configurations, * instead it displays the name, value, and location. * * @return getName() + "::" + getValue() + ":@" + getLocation(); */ public String toString() { return getName() + "::" + getValue("<no value>") + ":@" + getLocation(); } }
/** * Return the first <code>Configuration</code> object child of this * associated with the given name. If no such child exists, a new one * will be created. * * @param name the name of the child * @return the child Configuration */ public Configuration getChild( final String name ) { return getChild( name, true ); }
/** * Set the value of this <code>Configuration</code> object to the specified string. * * @param value a <code>String</code> value */ public void setValue( final String value ) { checkWriteable(); m_value = value; }
/** * Create a Configuration Builder with your own XMLReader. * @param parser an <code>XMLReader</code> */ public DefaultConfigurationBuilder( XMLReader parser ) { setParser( parser ); }
public void configure(Configuration configuration) throws ConfigurationException { /* Read configuration nodes for recursive, parallel, recursive-parallel */ this.defaultRecursive = configuration.getChild("recursive").getValueAsBoolean(false); this.defaultParallel = configuration.getChild("parallel").getValueAsBoolean(false); this.defaultRecursiveParallel = configuration.getChild("recursive-parallel").getValueAsBoolean(false); /* Read configuration node for thread pool name */ this.threadPool = configuration.getChild("thread-pool").getValue("default"); this.defaultKey = configuration.getChild("key").getValue(null); }
/** * Helper method to obtain the subject line to use from the given * configuration object. * * @param config a <code>Configuration</code> instance * @return subject line */ private String getSubject( Configuration config ) throws ConfigurationException { return config.getChild( "subject" ).getValue(); }
public boolean hasConfiguredLazyInit() { return this.configuration != null && this.configuration.getAttribute("lazy-init", null) != null; } }