Package org.apache.commons.configuration2.interpol

Examples of org.apache.commons.configuration2.interpol.Lookup


    @Override
    public final void installInterpolator(
            Map<String, ? extends Lookup> prefixLookups,
            Collection<? extends Lookup> defLookups)
    {
        InterpolatorSpecification spec =
                new InterpolatorSpecification.Builder()
                        .withPrefixLookups(prefixLookups)
                        .withDefaultLookups(defLookups)
                        .withDefaultLookup(new ConfigurationLookup(this))
                        .create();
View Full Code Here


        parent.addProperty("tablespaces.tablespace.name", "default");
        parent.addProperty("tablespaces.tablespace(-1).name", "test");
        parent.addProperty("tables.table(0).var", "${brackets:x}");

        ConfigurationInterpolator interpolator = parent.getInterpolator();
        interpolator.registerLookup("brackets", new Lookup() {

            public String lookup(String key) {
                return "(" + key + ")";
            }
View Full Code Here

        do
        {
            ConfigurationInterpolator ciOld = getInterpolator();
            ConfigurationInterpolator ciNew =
                    (ciOld != null) ? ciOld : new ConfigurationInterpolator();
            Lookup confLookup = findConfigurationLookup(ciNew);
            if (confLookup == null)
            {
                confLookup = new ConfigurationLookup(this);
            }
            else
View Full Code Here

    protected void cloneInterpolator(AbstractConfiguration orgConfig)
    {
        interpolator = new AtomicReference<ConfigurationInterpolator>();
        ConfigurationInterpolator orgInterpolator = orgConfig.getInterpolator();
        List<Lookup> defaultLookups = orgInterpolator.getDefaultLookups();
        Lookup lookup = findConfigurationLookup(orgInterpolator, orgConfig);
        if (lookup != null)
        {
            defaultLookups.remove(lookup);
        }
View Full Code Here

     */
    public static void testGetInterpolator(AbstractConfiguration config)
    {
        config.addProperty("var", "${echo:testVar}");
        ConfigurationInterpolator interpol = config.getInterpolator();
        interpol.registerLookup("echo", new Lookup()
        {
            @Override
            public Object lookup(String varName)
            {
                return "Value of variable " + varName;
View Full Code Here

                defConfig.configurationsAt(KEY_CONFIGURATION_LOOKUPS);
        for (HierarchicalConfiguration<?> config : nodes)
        {
            XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
            String key = config.getString(KEY_LOOKUP_KEY);
            Lookup lookup = (Lookup) fetchBeanHelper().createBean(decl);
            lookups.put(key, lookup);
        }

        if (!lookups.isEmpty())
        {
View Full Code Here

     * Tests whether prefix lookups can be set.
     */
    @Test
    public void testSetPrefixLookups()
    {
        Lookup look = EasyMock.createMock(Lookup.class);
        Map<String, Lookup> lookups = Collections.singletonMap("test", look);
        assertSame("Wrong result", params, params.setPrefixLookups(lookups));
        Map<?, ?> map = (Map<?, ?>) params.getParameters().get("prefixLookups");
        assertNotSame("No copy was created", lookups, map);
        assertEquals("Wrong lookup", look, map.get("test"));
View Full Code Here

     * Tests whether default lookups can be set.
     */
    @Test
    public void testSetDefaultLookups()
    {
        Lookup look = EasyMock.createMock(Lookup.class);
        Collection<Lookup> looks = Collections.singleton(look);
        assertSame("Wrong result", params, params.setDefaultLookups(looks));
        Collection<?> col =
                (Collection<?>) params.getParameters().get("defaultLookups");
        assertNotSame("No copy was created", col, looks);
View Full Code Here

     * settings for custom lookups.
     */
    @Test
    public void testSetLookupsAndInterpolator()
    {
        Lookup look1 = EasyMock.createMock(Lookup.class);
        Lookup look2 = EasyMock.createMock(Lookup.class);
        ConfigurationInterpolator parent =
                EasyMock.createMock(ConfigurationInterpolator.class);
        ConfigurationInterpolator ci =
                EasyMock.createMock(ConfigurationInterpolator.class);
        params.setDefaultLookups(Collections.singleton(look1));
View Full Code Here

    @Test
    public void testFetchInterpolatorSpecification()
    {
        ConfigurationInterpolator parent =
                EasyMock.createMock(ConfigurationInterpolator.class);
        Lookup l1 = EasyMock.createMock(Lookup.class);
        Lookup l2 = EasyMock.createMock(Lookup.class);
        Lookup l3 = EasyMock.createMock(Lookup.class);
        Map<String, Lookup> prefixLookups = new HashMap<String, Lookup>();
        prefixLookups.put("p1", l1);
        prefixLookups.put("p2", l2);
        Collection<Lookup> defLookups = Collections.singleton(l3);
        params.setParentInterpolator(parent);
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.interpol.Lookup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.