public MutableConfiguration getMutableChild( final String name, boolean autoCreate ) throws ConfigurationException { Configuration child = getChild( name, false ); if( child == null ) { // No child. Create? if( autoCreate ) { DefaultConfiguration config = new DefaultConfiguration( name, "-" ); addChild( config ); return config; } else { return null; } } // Child exists return toMutable( child ); }
/** * Recursivly replace the properties of a configuration object. * @param config The configuration. * @param settings The settings object to resolve the properties. * @throws ConfigurationException */ protected static void _replaceProperties(DefaultConfiguration config, Settings settings) throws ConfigurationException { final String[] names = config.getAttributeNames(); for (int i = 0; i < names.length; i++) { final String value = config.getAttribute(names[i]); config.setAttribute(names[i], PropertyHelper.replace(value, settings)); } final String value = config.getValue(null); if (value != null) { config.setValue(PropertyHelper.replace(value, settings)); } final Configuration[] children = config.getChildren(); for (int m = 0; m < children.length; m++) { _replaceProperties((DefaultConfiguration) children[m], settings); } }
/** * Returns the value of the configuration element as a <code>String</code>. * * @return a <code>String</code> value * @throws ConfigurationException If the value is not present. */ public String getValue() throws ConfigurationException { if( null != m_value ) { return m_value; } else { throw new ConfigurationException( "No value is associated with the " + "configuration element \"" + getName() + "\" at " + getLocation() ); } }
/** * 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 ); }
/** * Add all child <code>Configuration</code> objects from specified * configuration element to current configuration element. * * @param other the other {@link Configuration} value */ public void addAllChildren( final Configuration other ) { checkWriteable(); final Configuration[] children = other.getChildren(); for( int i = 0; i < children.length; i++ ) { addChild( children[ i ] ); } }
DefaultConfiguration cfg = new DefaultConfiguration("barcode"); DefaultConfiguration child = new DefaultConfiguration(type); cfg.addChild(child); attr = new DefaultConfiguration("height"); attr.setValue(height); child.addChild(attr); attr = new DefaultConfiguration("module-width"); attr.setValue(moduleWidth); child.addChild(attr); attr = new DefaultConfiguration("wide-factor"); attr.setValue(wideFactor); child.addChild(attr); attr = new DefaultConfiguration("quiet-zone"); if (quietZone.startsWith("disable")) { attr.setAttribute("enabled", "false"); } else { attr.setValue(quietZone); child.addChild(attr); && (humanReadableSize == null) && (humanReadableFont == null))) { attr = new DefaultConfiguration("human-readable");
componentConfig = new DefaultConfiguration("components", config.getLocation(), config.getNamespace(), final DefaultConfiguration c = new DefaultConfiguration(componentConfig.getName(), componentConfig.getLocation(), componentConfig.getNamespace(), ""); c.addAll(componentConfig); classPathConfig = c.getChild(CLASSLOADER_CONFIG_NAME, false); if ( classPathConfig != null ) { c.removeChild(classPathConfig); includeElement = new DefaultConfiguration("include", c.getLocation(), c.getNamespace(), ""); includeElement.setAttribute("dir", DEFAULT_CONFIG_XCONF); includeElement.setAttribute("pattern", "*.xconf"); includeElement.setAttribute("optional", "true"); c.addChild(includeElement);
result = new DefaultConfiguration(ServiceConstants.ROLE_NAME); DefaultConfiguration containerFlavourConfig = new DefaultConfiguration( ServiceConstants.CONTAINERFLAVOUR_CONFIG_KEY); containerFlavourConfig.setValue(this.getContainerFlavour()); result.addChild(containerFlavourConfig); DefaultConfiguration containerClazzNameConfig = new DefaultConfiguration( ServiceConstants.CONTAINERCLAZZNAME_CONFIG_KEY); containerClazzNameConfig.setValue(this.getServiceContainerClazzName()); result.addChild(containerClazzNameConfig); DefaultConfiguration componentRolesConfig = new DefaultConfiguration(ServiceConstants.COMPONENT_ROLE_KEYS); DefaultConfiguration componentRolesLocation = new DefaultConfiguration( ServiceConstants.COMPONENT_LOCATION_KEY); componentRolesLocation.setValue(this.getComponentRolesLocation()); DefaultConfiguration componentRolesIsEncrypted = new DefaultConfiguration( ServiceConstants.COMPONENT_ISENCRYPTED_KEY); componentRolesIsEncrypted.setValue(this.isComponentRolesEncrypted()); componentRolesConfig.addChild(componentRolesLocation);
private Configuration getConfiguration() { if (symbol != null) { DefaultConfiguration cfg = new DefaultConfiguration("cfg"); DefaultConfiguration child = new DefaultConfiguration(symbol); cfg.addChild(child); return cfg; } if (configurationFile != null) { try { if (!configurationFile.exists() || !configurationFile.isFile()) { throw new BuildException("Config file not found: " + configurationFile); } log("Using configuration: " + configurationFile); DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); return builder.buildFromFile(configurationFile); } catch (Exception e) { throw new BuildException("Error reading configuration file: " + e.getMessage()); } } return new DefaultConfiguration("cfg"); }
/** * Create a new <code>DefaultConfiguration</code> with the specified * local name and location. * * @param localName a <code>String</code> value * @param location a <code>String</code> value * @return a <code>DefaultConfiguration</code> value */ protected DefaultConfiguration createConfiguration( final String localName, final String location ) { return new DefaultConfiguration( localName, location ); }
( (StringBuffer)m_values.remove( depth ) ).toString(); if( finishedConfiguration.getChildren().length == 0 ) finishedConfiguration.setValue( finishedValue ); + "element " + finishedConfiguration.getName() + " at " + finishedConfiguration.getLocation() );
throws ConfigurationException checkWriteable(); addChild( new DefaultConfiguration( children[ i ], true ) ); addChild( children[ i ] );
DefaultConfiguration config = new DefaultConfiguration("sitemap"); config.setAttribute("file", sitemapURI); if (checkReloadStr != null) { boolean checkReload = BooleanUtils.toBoolean(checkReloadStr); config.setAttribute("check-reload", checkReload); if (passThroughStr != null) { boolean passThrough = BooleanUtils.toBoolean(passThroughStr); config.setAttribute("pass-through", passThrough);
parent.addChild( configuration ); configuration.setAttribute( name, value );
/** * Set the value of the specified attribute to the specified int. * * @param name name of the attribute to set * @param value an <code>int</code> value */ public void setAttribute( final String name, final int value ) { setAttribute( name, String.valueOf( value ) ); }
!( child instanceof DefaultConfiguration && ((DefaultConfiguration) child).isReadOnly() )) checkWriteable(); DefaultConfiguration config = new DefaultConfiguration( child );
return new DefaultConfiguration( name, "<generated>" + getLocation(), m_namespace, m_prefix );
/** * Set the value of this <code>Configuration</code> object to the specified long. * * @param value a <code>long</code> value */ public void setValue( final long value ) { setValue( String.valueOf( value ) ); }
/** * Add all attributes from specified configuration * element to current configuration element. * * @param other the {@link Configuration} element */ public void addAllAttributes( final Configuration other ) { checkWriteable(); final String[] attributes = other.getAttributeNames(); for( int i = 0; i < attributes.length; i++ ) { final String name = attributes[ i ]; final String value = other.getAttribute( name, null ); setAttribute( name, value ); } }
private static DefaultConfiguration processElement(Element el) { String name = el.getLocalName(); if (name == null) { name = el.getTagName(); } DefaultConfiguration cfg = new DefaultConfiguration(name); NamedNodeMap atts = el.getAttributes(); for (int i = 0; i < atts.getLength(); i++) { Attr attr = (Attr)atts.item(i); cfg.setAttribute(attr.getName(), attr.getValue()); } for (int i = 0; i < el.getChildNodes().getLength(); i++) { Node node = el.getChildNodes().item(i); if (node.getNodeType() == Node.ATTRIBUTE_NODE) { Attr attr = (Attr)node; cfg.setAttribute(attr.getName(), attr.getNodeValue()); } else if (node.getNodeType() == Node.ELEMENT_NODE) { cfg.addChild(processElement((Element)node)); } else if (node.getNodeType() == Node.TEXT_NODE) { String s = cfg.getValue("") + ((Text)node).getData(); cfg.setValue(s.trim()); } else { //ignore } } return cfg; }