Package org.apache.hivemind.schema

Examples of org.apache.hivemind.schema.Translator


    {
        Module m = getModule();

        replayControls();

        Translator t = new IdListTranslator();

        assertEquals("foo.bar.Baz,zip.Zap", t.translate(m, null, "Baz,zip.Zap", null));

        verifyControls();
    }
View Full Code Here


        symbolExpander.expandSymbols("${flintstone}", null);
        symbolExpanderControl.setReturnValue("flintstone");

        MockControl tControl = newControl(Translator.class);
        Translator t = (Translator) tControl.getMock();

        tm.getTranslator("cartoon");
        tmControl.setReturnValue(t);

        m.getService(TranslatorManager.class);
        control.setReturnValue(tm);

        Object flintstoneKey = new Object();
        t.translate(m, Object.class, "flintstone", element.getLocation());
        tControl.setReturnValue(flintstoneKey);

        replayControls();

        Map dest = new HashMap();
View Full Code Here

        element2.setLocation(location2);

        List elements2 = Collections.singletonList(element2);

        MockControl tControl1 = newControl(Translator.class);
        Translator t1 = (Translator) tControl1.getMock();
       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();
       
        m1.getRegistry();
        control1.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m1);

        m2.getRegistry();
        control2.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m2);
       
        m1.resolveType("StringHolderImpl");
        control1.setReturnValue(StringHolderImpl.class);

        m1.getService(SymbolExpander.class);
        control1.setReturnValue(symbolExpander);
       
        symbolExpander.expandSymbols("flintstone", location1);
        symbolExpanderControl.setReturnValue("flintstone");
       
        m1.getService(TranslatorManager.class);
        control1.setReturnValue(tm);
       
        symbolExpander.expandSymbols("flintstone", location1);
        symbolExpanderControl.setReturnValue("flintstone");

        String flintstoneKeyModule1 = "m1.flintstone";
        t1.translate(m1, String.class, "flintstone", element1.getLocation());
        tControl1.setReturnValue(flintstoneKeyModule1);

        t1.translate(m1, Object.class, "flintstone", element1.getLocation());
        tControl1.setReturnValue(flintstoneKeyModule1);

        m2.resolveType("StringHolderImpl");
        control2.setReturnValue(StringHolderImpl.class);

        symbolExpander.expandSymbols("flintstone", location2);
        symbolExpanderControl.setReturnValue("flintstone");
       
        symbolExpander.expandSymbols("flintstone", location2);
        symbolExpanderControl.setReturnValue("flintstone");

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t1);

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t1);

        MockControl tControl2 = newControl(Translator.class);
        Translator t2 = (Translator) tControl2.getMock();

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t2);
       
        String flintstoneKeyModule2 = "m2.flintstone";
        t2.translate(m2, String.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);
       
        t2.translate(m2, Object.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t2);
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();

        BuilderPropertyFacet facet = new BuilderPropertyFacet();

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

        params.getInvokingModule();
        paramsControl.setDefaultReturnValue(module);

        module.getTranslator("foo");
        moduleControl.setDefaultReturnValue(translator);

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

        replayControls();

        facet.isAssignableToType(params, Object.class);
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);
        String value = RuleUtils.processText(processor, element, attributeValue);

        Object finalValue = t.translate(
                processor.getContributingModule(),
                Object.class,
                value,
                element.getLocation());

View Full Code Here

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

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

        Object finalValue = t.translate(
                processor.getContributingModule(),
                Object.class,
                value,
                element.getLocation());

View Full Code Here

            String expandedKey = getContributingModule().expandSymbols(
                    currentElement.getAttributeValue(keyAttribute),
                    currentElement.getLocation());

            Translator t = getAttributeTranslator(keyAttribute);

            Object finalValue = t.translate(
                    getContributingModule(),
                    Object.class,
                    expandedKey,
                    currentElement.getLocation());
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,
                    element.getLocation());
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,
                    element.getLocation());
View Full Code Here

    {
        Object result = _valuesCache.get(targetType);

        if (result == null)
        {
            Translator translator = factoryParameters.getInvokingModule().getTranslator(
                    _translatorName);

            result = translator.translate(
                    factoryParameters.getInvokingModule(),
                    targetType,
                    _literalValue,
                    getLocation());
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.