Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.IParameterSpecification


        Iterator i = spec.getParameterNames().iterator();
        while (i.hasNext())
        {
            String name = (String) i.next();

            IParameterSpecification ps = spec.getParameter(name);

            try
            {
                performEnhancement(op, name, ps);
            }
            catch (RuntimeException ex)
            {
                _errorLog.error(EnhanceMessages.errorAddingProperty(ps.getPropertyName(), op
                        .getBaseClass(), ex), ps.getLocation(), ex);
            }
        }
    }
View Full Code Here


        __CLOVER_200_0.S[4767]++;Iterator i = spec.getParameterNames().iterator();

        __CLOVER_200_0.S[4768]++;while ((((i.hasNext()) && (++__CLOVER_200_0.CT[864] != 0)) || (++__CLOVER_200_0.CF[864] == 0))){
        {
            __CLOVER_200_0.S[4769]++;String name = (String) i.next();
            __CLOVER_200_0.S[4770]++;IParameterSpecification parameterSpec = spec.getParameter(name);

            __CLOVER_200_0.S[4771]++;if ((((parameterSpec.isRequired() && component.getBinding(name) == null) && (++__CLOVER_200_0.CT[865] != 0)) || (++__CLOVER_200_0.CF[865] == 0))){
                __CLOVER_200_0.S[4772]++;throw new ApplicationRuntimeException(
                    PageloadMessages.requiredParameterNotBound(name, component),
                    component,
                    component.getLocation(),
                    null);}
View Full Code Here

    {try { __CLOVER_203_0.M[1015]++;
        __CLOVER_203_0.S[4779]++;_component = component;
        __CLOVER_203_0.S[4780]++;_parameterName = parameterName;
        __CLOVER_203_0.S[4781]++;_binding = binding;

        __CLOVER_203_0.S[4782]++;IParameterSpecification pspec = _component.getSpecification().getParameter(_parameterName);
        __CLOVER_203_0.S[4783]++;_required = pspec.isRequired();
        __CLOVER_203_0.S[4784]++;_propertyName = pspec.getPropertyName();
        __CLOVER_203_0.S[4785]++;_direction = pspec.getDirection();

        __CLOVER_203_0.S[4786]++;_clearValue = readCurrentPropertyValue();
    } finally { }}
View Full Code Here

        __CLOVER_191_0.S[4481]++;Iterator i = spec.getParameterNames().iterator();

        __CLOVER_191_0.S[4482]++;while ((((i.hasNext()) && (++__CLOVER_191_0.CT[826] != 0)) || (++__CLOVER_191_0.CF[826] == 0))){
        {
            __CLOVER_191_0.S[4483]++;String name = (String) i.next();
            __CLOVER_191_0.S[4484]++;IParameterSpecification parameterSpec = spec.getParameter(name);

            __CLOVER_191_0.S[4485]++;String defaultValue = parameterSpec.getDefaultValue();
            __CLOVER_191_0.S[4486]++;if ((((defaultValue == null) && (++__CLOVER_191_0.CT[827] != 0)) || (++__CLOVER_191_0.CF[827] == 0))){
                __CLOVER_191_0.S[4487]++;continue;}

            // the parameter has a default value, so it must not be required
            __CLOVER_191_0.S[4488]++;if ((((parameterSpec.isRequired()) && (++__CLOVER_191_0.CT[828] != 0)) || (++__CLOVER_191_0.CF[828] == 0))){
                __CLOVER_191_0.S[4489]++;throw new ApplicationRuntimeException(
                    PageloadMessages.parameterMustHaveNoDefaultValue(component, name),
                    component,
                    parameterSpec.getLocation(),
                    null);}

            // if there is no binding for this parameter, bind it to the default value
            __CLOVER_191_0.S[4490]++;if ((((component.getBinding(name) == null) && (++__CLOVER_191_0.CT[829] != 0)) || (++__CLOVER_191_0.CF[829] == 0))){
            {
                __CLOVER_191_0.S[4491]++;IBinding binding =
                    new ExpressionBinding(
                        _resolver,
                        component,
                        defaultValue,
                        parameterSpec.getLocation());
                __CLOVER_191_0.S[4492]++;component.setBinding(name, binding);
            }}

        }}
    } finally { }}
View Full Code Here

                    __CLOVER_210_0.S[4884]++;LOG.debug("Not bound.");}

                __CLOVER_210_0.S[4885]++;continue;
            }}

            __CLOVER_210_0.S[4886]++;IParameterSpecification pspec = spec.getParameter(name);
            __CLOVER_210_0.S[4887]++;Direction direction = pspec.getDirection();

            __CLOVER_210_0.S[4888]++;if ((((direction != Direction.IN && direction != Direction.FORM) && (++__CLOVER_210_0.CT[886] != 0)) || (++__CLOVER_210_0.CF[886] == 0))){
            {
                __CLOVER_210_0.S[4889]++;if ((((debug) && (++__CLOVER_210_0.CT[887] != 0)) || (++__CLOVER_210_0.CF[887] == 0))){
                    __CLOVER_210_0.S[4890]++;LOG.debug("Parameter is " + pspec.getDirection().getName() + ".");}

                __CLOVER_210_0.S[4891]++;continue;
            }}

            __CLOVER_210_0.S[4892]++;if ((((!direction.getAllowInvariant() && binding.isInvariant()) && (++__CLOVER_210_0.CT[888] != 0)) || (++__CLOVER_210_0.CF[888] == 0))){
                __CLOVER_210_0.S[4893]++;throw new ConnectedParameterException(Tapestry.format(
                        "ParameterManager.incompatible-direction-and-binding",
                        new Object[]
                        { name, _component.getExtendedId(), direction.getDisplayName(), binding }),
                        _component, name, null, binding.getLocation(), null);}

            __CLOVER_210_0.S[4894]++;String propertyName = pspec.getPropertyName();

            __CLOVER_210_0.S[4895]++;if ((((debug && !name.equals(propertyName)) && (++__CLOVER_210_0.CT[889] != 0)) || (++__CLOVER_210_0.CF[889] == 0))){
                __CLOVER_210_0.S[4896]++;LOG.debug("Connecting to property " + propertyName + ".");}

            // Next,verify that there is a writable property with the same
            // name as the parameter.

            __CLOVER_210_0.S[4897]++;PropertyAdaptor adaptor = null;

            __CLOVER_210_0.S[4898]++;try
            {
                __CLOVER_210_0.S[4899]++;adaptor = PropertyUtils.getPropertyAdaptor(_component, propertyName);
            }
            catch (Exception ex)
            {
                __CLOVER_210_0.S[4900]++;throw new ConnectedParameterException(ex.getMessage(), _component, name,
                        propertyName, binding.getLocation(), ex);
            }

            __CLOVER_210_0.S[4901]++;if ((((!(adaptor.isReadable() && adaptor.isWritable())) && (++__CLOVER_210_0.CT[890] != 0)) || (++__CLOVER_210_0.CF[890] == 0))){
            {
                __CLOVER_210_0.S[4902]++;throw new ConnectedParameterException(Tapestry.format(
                        "ParameterManager.property-not-read-write",
                        _component.getExtendedId(),
                        propertyName), _component, name, propertyName, binding.getLocation(), null);
            }}

            // Check if the parameter type matches the property type

            __CLOVER_210_0.S[4903]++;Class propertyType = adaptor.getPropertyType();
            __CLOVER_210_0.S[4904]++;Class parameterType = getType(pspec.getType(), resolver);

            __CLOVER_210_0.S[4905]++;if ((((parameterType == null) && (++__CLOVER_210_0.CT[891] != 0)) || (++__CLOVER_210_0.CF[891] == 0))){
            {
                __CLOVER_210_0.S[4906]++;throw new ConnectedParameterException(Tapestry.format(
                        "ParameterManager.java-type-not-specified",
View Full Code Here

        while (i.hasNext())
        {
            String name = (String) i.next();

            IParameterSpecification pspec = spec.getParameter(name);

            boolean isFormal = pspec != null;

            String parameterName = isFormal ? pspec.getParameterName() : name;

            IBindingSpecification bspec = contained.getBinding(name);

            // If not allowing informal parameters, check that each binding
            // matches
            // a formal parameter.

            if (formalOnly && !isFormal)
                throw new ApplicationRuntimeException(PageloadMessages.formalParametersOnly(
                        component,
                        name), component, bspec.getLocation(), null);

            // If an informal parameter that conflicts with a reserved name,
            // then skip it.

            if (!isFormal && spec.isReservedParameterName(name))
                continue;

            if (isFormal)
            {
                if (!name.equals(parameterName))
                {
                    _log.error(PageloadMessages.usedParameterAlias(
                            contained,
                            name,
                            parameterName,
                            bspec.getLocation()));
                }
                else if (pspec.isDeprecated())
                    _log.error(PageloadMessages.deprecatedParameter(
                            name,
                            bspec.getLocation(),
                            contained.getType()));
            }
View Full Code Here

                Map.Entry entry = (Map.Entry) i.next();

                String attributeName = (String) entry.getKey();
                String value = (String) entry.getValue();

                IParameterSpecification pspec = spec.getParameter(attributeName);
                String parameterName = pspec == null ? attributeName : pspec.getParameterName();

                if (!attributeName.equals(parameterName))
                    _log.error(ImplMessages.usedTemplateParameterAlias(
                            token,
                            attributeName,
View Full Code Here

        push(_elementName, null, STATE_NO_CONTENT);
    }

    private void enterParameter()
    {
        IParameterSpecification ps = _factory.createParameterSpecification();

        String name = getValidatedAttribute(
                "name",
                PARAMETER_NAME_PATTERN,
                "invalid-parameter-name");

        String attributeName = _DTD_4_0 ? "property" : "property-name";

        String propertyName = getValidatedAttribute(
                attributeName,
                PROPERTY_NAME_PATTERN,
                "invalid-property-name");

        if (propertyName == null)
            propertyName = name;

        ps.setParameterName(name);
        ps.setPropertyName(propertyName);

        ps.setRequired(getBooleanAttribute("required", false));

        // In the 3.0 DTD, default-value was always an OGNL expression.
        // Starting with 4.0, it's like a binding (prefixed). For a 3.0
        // DTD, we supply the "ognl:" prefix.

        String defaultValue = getAttribute("default-value");

        if (defaultValue != null && !_DTD_4_0)
            defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue;

        ps.setDefaultValue(defaultValue);

        if (!_DTD_4_0)
        {
            // When direction=auto (in a 3.0 DTD), turn caching off

            String direction = getAttribute("direction");
            ps.setCache(!"auto".equals(direction));
        }
        else
        {
            boolean cache = getBooleanAttribute("cache", true);
            ps.setCache(cache);
        }

        // type will only be specified in a 3.0 DTD.

        String type = getAttribute("type");

        if (type != null)
            ps.setType(type);

        // aliases is new in the 4.0 DTD

        String aliases = getAttribute("aliases");

        ps.setAliases(aliases);
        ps.setDeprecated(getBooleanAttribute("deprecated", false));

        IComponentSpecification cs = (IComponentSpecification) peekObject();

        cs.addParameter(ps);
View Full Code Here

        while (i.hasNext())
        {
            String name = (String) i.next();

            IParameterSpecification pspec = spec.getParameter(name);

            boolean isFormal = pspec != null;

            String parameterName = isFormal ? pspec.getParameterName() : name;

            IBindingSpecification bspec = contained.getBinding(name);

            // If not allowing informal parameters, check that each binding
            // matches
            // a formal parameter.

            if (formalOnly && !isFormal)
                throw new ApplicationRuntimeException(PageloadMessages.formalParametersOnly(
                        component,
                        name), component, bspec.getLocation(), null);

            // If an informal parameter that conflicts with a reserved name,
            // then skip it.

            if (!isFormal && spec.isReservedParameterName(name))
                continue;

            if (isFormal)
            {
                if (!name.equals(parameterName))
                {
                    _log.warn(PageloadMessages.usedParameterAlias(
                            contained,
                            name,
                            parameterName,
                            bspec.getLocation()));
                }
                else if (pspec.isDeprecated())
                    _log.warn(PageloadMessages.deprecatedParameter(
                            name,
                            bspec.getLocation(),
                            contained.getType()));
            }
View Full Code Here

        return spec.getParameter(parameterName);
    }

    public void testSimple()
    {
        IParameterSpecification ps = attempt("simpleParameter");

        assertListsEqual(new Object[] {}, ps.getAliasNames().toArray());
        assertEquals(true, ps.getCache());
        assertEquals(null, ps.getDefaultBindingType());
        assertEquals(null, ps.getDefaultValue());
        assertEquals(null, ps.getDescription());
        assertNull(ps.getLocation());
        assertEquals("simpleParameter", ps.getParameterName());
        assertEquals("simpleParameter", ps.getPropertyName());
        assertEquals("java.lang.String", ps.getType());
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.spec.IParameterSpecification

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.