Package xjavadoc

Examples of xjavadoc.XMethod


     * @doc.tag                     type="content"
     */
    public String signatureFromMethod()
         throws XDocletException
    {
        XMethod method = getCurrentMethod();

        if (method == null)
            throw L.error(L.NO_CURRENT_METHOD);
        else
            return method.getNameWithSignature(false);
    }
View Full Code Here



    private String getMethodTagValue(String tagName, String paramName, boolean left)
         throws XDocletException
    {
        XMethod method = left ? currentRelation.getLeftMethod() : currentRelation.getRightMethod();

        if (method == null)
            return null;
        else
            return getTagValue(FOR_METHOD, method.getDoc(), tagName, paramName, null, null, false, false);
    }
View Full Code Here

            log.info("method name: " + method.getName());
            log.info("property name: " + propertyName);
            log.info("property type: " + propertyType);
        }

        XMethod getterMethod = null;

        //attempt to find an explicitly named getter method
        final String explicitMethodName = method.getDoc().getTag("javabean.property").getAttributeValue("getter");

        if ((explicitMethodName != null) && (explicitMethodName.length() > 0)) {
            //the method has an explicit attribute
            //there must be a bean property method with the given name
            java.util.List methodList = getCurrentClass().getMethods(
                new Predicate()
                {
                    public boolean evaluate(Object obj)
                    {
                        XMethod method = (XMethod) obj;

                        return isPossiblePropertyAccessor(method, propertyType) &&
                            method.getName().equals(explicitMethodName);
                    }
                }, false);

            //the method name, return, and arguments are known... there can be [0, 1]

            if (methodList.size() == 1) {
                getterMethod = (XMethod) methodList.get(0);
                if (log.isInfoEnabled()) {
                    log.info("found explicit getter " + getterMethod.getName());
                }
                if (isPossiblePropertyAccessor(method, propertyType)
                    && (getterMethod != method)) {
                    log.warn("explicit getter " + getterMethod.getName() + " (should be passed method)");
                }
            }
            else {
                //they gave an explicit method name but it could not be found
                log.warn("no explicit getter " + explicitMethodName);
            }
        }
        else if (isPossiblePropertyAccessor(method, propertyType)) {
            //this was put on the an accessor assume it was what they wanted
            getterMethod = method;
            log.info("using the passed method");
        }
        else {
            //attempt to find the standard bean method (Simple property JavaBeans API specification 8.3.1)
            //takes no params (isPropertyAccessor)
            java.util.List methodList = getCurrentClass().getMethods(
                new Predicate()
                {
                    public boolean evaluate(Object obj)
                    {
                        XMethod method = (XMethod) obj;

                        return isPossiblePropertyAccessor(method, propertyType) &&
                            method.getPropertyName().equals(propertyName);
                    }
                }, false);

            if (methodList.size() == 1) {
                getterMethod = (XMethod) methodList.get(0);
View Full Code Here

            log.error("invalid method: " + method);
            return null;
        }

        //get on with the real business
        XMethod setterMethod = null;

        if (log.isInfoEnabled()) {
            log.info("===find setter method===");
            log.info("method name: " + method.getName());
            log.info("property name: " + propertyName);
            log.info("property type: " + propertyType);
        }

        //attempt to find an explicitly named setter method
        final String explicitMethodName = method.getDoc().getTag("javabean.property").getAttributeValue("setter");

        if (isExplicitlyReadOnlyProperty(method)) {
            log.info("explicit read only");
        }
        else if ((explicitMethodName != null) && (explicitMethodName.length() > 0)) {
            //the method has an explicit attribute
            //there must be a bean property method with the given name
            java.util.List methodList = getCurrentClass().getMethods(
                new Predicate()
                {
                    public boolean evaluate(Object obj)
                    {
                        XMethod method = (XMethod) obj;

                        return isPossiblePropertyMutator(method, propertyType) &&
                            method.getName().equals(explicitMethodName);
                    }
                }, false);

            if (methodList.size() == 1) {
                setterMethod = (XMethod) methodList.get(0);
                if (log.isInfoEnabled()) {
                    log.info("found explicit setter " + setterMethod.getName());
                }
                if (isPossiblePropertyMutator(method, propertyType)
                    && (setterMethod != method)) {
                    log.warn("explicit setter " + setterMethod.getName() + " (should be passed method)");
                }
            }
            else {
                //they gave an explicit method name but it could not be found
                log.warn("no explicit setter " + explicitMethodName);
            }
        }
        else if (isPossiblePropertyMutator(method, propertyType)) {
            //this was put on a mutator assume it was what they wanted?
            setterMethod = method;
            log.info("using the passed method");
        }
        else {
            //attempt to find the standard bean method (Simple property JavaBeans API specification 8.3.1)
            //takes one param
            java.util.List methodList = getCurrentClass().getMethods(
                new Predicate()
                {
                    public boolean evaluate(Object obj)
                    {
                        XMethod method = (XMethod) obj;

                        return isPossiblePropertyMutator(method, propertyType) &&
                            propertyName.equals(method.getPropertyName());
                    }
                }, false);

            if (methodList.size() == 1) {
                setterMethod = (XMethod) methodList.get(0);
View Full Code Here

     *
     * @return
     */
    public String getGetterMethodNameQuoted()
    {
        XMethod currentMethod = getCurrentMethod();
        String propertyName = getPropertyName(currentMethod);
        XType propertyType = getPropertyType(currentMethod);

        if (propertyName != null) {
        }

        XMethod getterMethod = getGetterMethod(propertyName, propertyType, currentMethod);


        if (getterMethod == null) {
            return "null";
        }
        else {
            return "\"" + getterMethod.getName() + "\"";
        }
    }
View Full Code Here

     *
     * @return
     */
    public String getSetterMethodNameQuoted()
    {
        XMethod currentMethod = getCurrentMethod();
        String propertyName = getPropertyName(currentMethod);
        XType propertyType = getPropertyType(currentMethod);

        XMethod setterMethod = getSetterMethod(propertyName, propertyType, currentMethod);

        if (setterMethod == null) {
            return "null";
        }
        else {
            return "\"" + setterMethod.getName() + "\"";
        }
    }
View Full Code Here

        Map setters = getFields(clazz);

        for (Iterator iterator = setters.keySet().iterator(); iterator.hasNext(); ) {
            curFieldName = (String) iterator.next();

            XMethod field = (XMethod) setters.get(curFieldName);

            if (field.getDoc().hasTag("struts.validator")) {
                setCurrentMethod(field);
                loadFieldArguments();
                generate(template);
            }
        }
View Full Code Here

        Map setters = getFields(clazz);

        for (Iterator iterator = setters.keySet().iterator(); iterator.hasNext(); ) {
            curFieldName = (String) iterator.next();

            XMethod field = (XMethod) setters.get(curFieldName);

            setCurrentMethod(field);
            loadFieldArguments();
            generate(template);
        }
View Full Code Here

     * @return       validator types list
     * @doc.tag      type="content"
     */
    public String validatorList(Properties props)
    {
        XMethod method = getCurrentMethod();
        Collection tags = method.getDoc().getTags("struts.validator");
        StringBuffer buffer = new StringBuffer();

        for (Iterator iterator = tags.iterator(); iterator.hasNext(); ) {
            XTag tag = (XTag) iterator.next();

View Full Code Here

        // TODO: nested forms currently won't work unless
        // there is a setter for it, but that is not needed
        // as only the sub-forms must have setters.  The top-level
        // only requires a getter.
        for (Iterator iterator = curFields.iterator(); iterator.hasNext(); ) {
            XMethod method = (XMethod) iterator.next();
            XTag tag = method.getDoc().getTag("struts.validator");
            String override = null;

            if (tag != null) {
                override = tag.getAttributeValue("override");
            }

            if (tag != null) {
                List params = method.getParameters();
                String name = method.getPropertyName();
                XParameter param = null;

                if (MethodTagsHandler.isSetterMethod(method)) {
                    param = (XParameter) params.get(0);
                }
                else if (params.size() == 2) {
                    // Check for indexed setter setBlah(int index, <type> value)
                    if (!MethodTagsHandler.isSetter(method.getName()))
                        continue;

                    Iterator paramIter = params.iterator();

                    if (!((XParameter) paramIter.next()).getType().isA("int"))
View Full Code Here

TOP

Related Classes of xjavadoc.XMethod

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.