Package org.apache.hivemind.schema

Examples of org.apache.hivemind.schema.Translator


        }
    }

    public void testNoLocator()
    {
        Translator t = new BeanTranslator();

        try
        {
            t.translate(null, null, "foo:");
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertEquals(
View Full Code Here


        factory.get("my-bean,initialized");
        factoryControl.setReturnValue(result);

        replayControls();

        Translator t = new BeanTranslator();

        assertSame(result, t.translate(module, null, "factory:my-bean,initialized"));

        verifyControls();
    }
View Full Code Here

        Object target = processor.peek();

        try
        {
            Translator t =
                _translator == null
                    ? processor.getAttributeTranslator(_attributeName)
                    : processor.getTranslator(_translator);

            Class propertyType = PropertyUtils.getPropertyType(target, _propertyName);

            Object finalValue = t.translate(processor.getContributingModule(), propertyType, value);

            PropertyUtils.write(target, _propertyName, finalValue);

        }
        catch (Exception ex)
View Full Code Here

    {
        String value = RuleUtils.processText(processor, element, element.getContent());

        try
        {
            Translator t = processor.getContentTranslator();

            Object target = processor.peek();

            Class propertyType = PropertyUtils.getPropertyType(target, _propertyName);

            Object finalValue = t.translate(processor.getContributingModule(), propertyType, value);

            PropertyUtils.write(target, _propertyName, finalValue);
        }
        catch (Exception ex)
        {
View Full Code Here

        }
    }

    public synchronized Translator getTranslator(String constructor)
    {
        Translator result = (Translator) _translatorsCache.get(constructor);

        if (result == null)
        {
            result = constructTranslator(constructor);
            _translatorsCache.put(constructor, result);
View Full Code Here

     * Uses the translator to convert the specified attribute into an object and pushes
     * that object onto the processor stack.
     */
    public void begin(SchemaProcessor processor, Element element)
    {
        Translator t = processor.getAttributeTranslator(_attributeName);

        String attributeValue = element.getAttributeValue(_attributeName);

        Object finalValue =
            t.translate(processor.getContributingModule(), null, attributeValue);

        processor.push(finalValue);
    }
View Full Code Here

    private Translator newTranslator(Module module, String objectReference, Location location,
            Object result)
    {
        MockControl control = newControl(Translator.class);
        Translator translator = (Translator) control.getMock();

        translator.translate(module, Object.class, objectReference, location);
        control.setReturnValue(result);

        return translator;
    }
View Full Code Here

    public void testDeferredObject()
    {
        Object object = new Object();
        Module module = newModule();
        Location l = newLocation();
        Translator translator = newTranslator(module, "OBJ-REFERENCE", l, object);

        replayControls();

        DeferredObject deferred = new DeferredObjectImpl(translator, module, "OBJ-REFERENCE", l);
View Full Code Here

    public void testDeferredObjectTranslator()
    {
        Object object = new Object();
        Module module = newModule();
        Location l = newLocation();
        Translator objectTranslator = newTranslator(module, "OBJ-REFERENCE", l, object);

        replayControls();

        DeferredObjectTranslator translator = new DeferredObjectTranslator();
        translator.setObjectTranslator(objectTranslator);
View Full Code Here

    {
        MockControl moduleControl = newControl(Module.class);
        Module module = (Module) moduleControl.getMock();
       
        MockControl translatorControl = newControl(Translator.class);
        Translator translator = (Translator) translatorControl.getMock();

        MockControl paramsControl = newControl(ServiceImplementationFactoryParameters.class);
        ServiceImplementationFactoryParameters params = (ServiceImplementationFactoryParameters) paramsControl
                .getMock();
       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();

        BuilderPropertyFacet facet = new BuilderPropertyFacet();

        facet.setTranslator("foo");
        facet.setValue("bar");

        params.getInvokingModule();
        paramsControl.setDefaultReturnValue(module);
       
        module.getService(TranslatorManager.class);
        moduleControl.setReturnValue(tm);

        tm.getTranslator("foo");
        tmControl.setReturnValue(translator);

        translator.translate(module, Object.class, "bar", null);
        translatorControl.setReturnValue("BAR");

        replayControls();

        facet.isAssignableToType(params, Object.class);
View Full Code Here

TOP

Related Classes of org.apache.hivemind.schema.Translator

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.