Package com.thoughtworks.qdox.model

Examples of com.thoughtworks.qdox.model.Type


                                    ((vTag != null) && ((vTag.getAggregate() != null) || (vTag.getCompose() != null)))) {
                                // This is a value-object relation
                                // vTag must be non-null, because we need values from it
                                if ((vTag != null) && ((vTag.getAggregate() != null) ^ (vTag.getCompose() != null))) {
                                    JavaClass relationEjb = null;
                                    Type collectionType = null;

                                    if (relation != null) {
                                        if (!method.equals(relation.getLeftMethod())) {
                                            log.debug(
                                                "Current method doesn't match relations' left method. Reversing relation");
                                            relation = relation.reverse();

                                            if (log.isDebugEnabled()) {
                                                log.debug("Reversed relation is relation=" + relation);
                                            }
                                        }

                                        if (log.isDebugEnabled()) {
                                            log.debug("Using relation information. relation=" + relation);
                                            log.debug("1# Left bean=" +
                                                ((relation.getLeftBean() != null)
                                                ? relation.getLeftBean().getFullyQualifiedName() : null));
                                            log.debug("1# Rigth bean=" +
                                                ((relation.getRightBean() != null)
                                                ? relation.getRightBean().getFullyQualifiedName() : null));
                                        }

                                        String relationEjbName = relation.getRightEJBName();
                                        relationEjb = getBeanResolver().findEjbByName(relationEjbName);
                                        collectionType = relation.getLeftMethod().getReturns();
                                    } else {
                                        log.debug("We don't have relation information for this method");
                                        Type returnType = method.getReturns();
                                        Type relationType = null;

                                        if (returnType.isA(COLLECTION_TYPE) || returnType.isA(SET_TYPE)) {
                                            String members = vTag.getMembers();

                                            if (log.isDebugEnabled()) {
                                                log.debug(returnType + ": Is a Set or Collection. Using members='" +
                                                    members + "'");
                                            }

                                            if (members == null) {
                                                if (log.isWarnEnabled()) {
                                                    log.warn(EjbUtils.getMessageWithTagLocation(vTag,
                                                            "members is null. Skipping."));
                                                }

                                                continue;
                                            }

                                            relationType = new Type(members);
                                            collectionType = returnType.isA(COLLECTION_TYPE) ? COLLECTION_TYPE : SET_TYPE;
                                        } else {
                                            if (log.isDebugEnabled()) {
                                                log.debug(returnType + ": Using it to find it's match!");
                                            }
View Full Code Here


        }

        public BeanProperty getProperty() {
            BeanProperty retVal;
            String propName;
            Type propType;

            if (isCollection()) {
                propName = getAggregateNamePlural();
                propType = getCollectionType();
            } else {
                propName = getAggregateName();
                propType = new Type(getAggregate());
            }

            retVal = new BeanProperty(propName);
            retVal.setType(propType);
            JavaMethod getter = new JavaMethod(propType, getGetterName(retVal));
View Full Code Here

            isCollection |= (relationCollectionType != null) && relationCollectionType.isA(SET_TYPE);
            return isCollection;
        }

        public Type getCollectionType() {
            Type retVal = null;

            if (relationCollectionType != null) {
                if (relationCollectionType.isA(COLLECTION_TYPE)) {
                    retVal = COLLECTION_TYPE;
                } else if (relationCollectionType.isA(SET_TYPE)) {
View Full Code Here

        public Type getCollectionTypeImpl() {
            String concreteType = vTag.getConcreteType();

            if (concreteType == null) {
                Type colType = getCollectionType();

                if ((colType != null) && relationCollectionType.isA(COLLECTION_TYPE)) {
                    concreteType = ArrayList.class.getName();
                } else if ((colType != null) && relationCollectionType.isA(SET_TYPE)) {
                    concreteType = HashSet.class.getName();
                } else if (log.isErrorEnabled()) {
                    log.error(EjbUtils.getMessageWithTagLocation(vTag, "Couldn't resolve concrete type for relation"));
                }
            }

            return (concreteType != null) ? new Type(concreteType) : null;
        }
View Full Code Here

        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata),
                getDestinationPackage(metadata), null, getMetadataProvider());
        retVal.setModifiers(new String[] { "public" });
        if (getEjbUtils().isMessageDrivenBean(metadata)) {
            field = new JavaField(new Type(String.class.getName()), "DESTINATION_JNDI_NAME");
            field.setModifiers(new String[] { "private", "final", "static" });
            retVal.addField(field);
            field = new JavaField(new Type(String.class.getName()), "CONNECTION_FACTORY_JNDI_NAME");
            field.setModifiers(new String[] { "private", "final", "static" });
            retVal.addField(field);
        }
        if (isCachehomes()) {
            if (getEjbUtils().isMessageDrivenBean(metadata)) {
                field = new JavaField(new Type("javax.jms.Queue"), "cachedQueue");
                field.setModifiers(new String[] { "private", "static" });
                retVal.addField(field);
                field = new JavaField(new Type("javax.jms.QueueConnectionFactory"), "cachedConnectionFactory");
                field.setModifiers(new String[] { "private", "static" });
                retVal.addField(field);
            } else {
                if (hasRemoteView(metadata)) {
                    field = new JavaField(new Type(getRemoteHomeInterfacePlugin().getVirtualType(metadata)
                            .toString()), "cachedRemoteHome");
                    field.setModifiers(new String[] { "private", "static" });
                    retVal.addField(field);
                }
                if (hasLocalView(metadata)) {
                    field = new JavaField(new Type(getLocalHomeInterfacePlugin().getVirtualType(metadata)
                            .toString()), "cachedHome");
                    field.setModifiers(new String[] { "private", "static" });
                    retVal.addField(field);
                }
            }
        }

        method = new JavaMethod(getDestinationClassname(metadata));
        method.setConstructor(true);
        method.setModifiers(new String[] { "private" });
        retVal.addMethod(method);

        if (getEjbUtils().isMessageDrivenBean(metadata)) {
            method = new JavaMethod("getQueue");
            method.setModifiers(new String[] { "public", "static" });
            method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
            method.setReturns(new Type("javax.jms.Queue"));
            retVal.addMethod(method);
            method = new JavaMethod("getQueue");
            method.setModifiers(new String[] { "public", "static" });
            method.setParameters(new JavaParameter[] { new JavaParameter(new Type("java.util.Hashtable"),
                    "environment") });
            method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
            method.setReturns(new Type("javax.jms.Queue"));
            retVal.addMethod(method);
            method = new JavaMethod("getQueueConnection");
            method.setModifiers(new String[] { "public", "static" });
            method.setExceptions(new Type[] { new Type("javax.naming.NamingException"),
                    new Type("javax.jms.JMSException") });
            method.setReturns(new Type("javax.jms.QueueConnection"));
            retVal.addMethod(method);
            method = new JavaMethod("getQueueConnection");
            method.setModifiers(new String[] { "public", "static" });
            method.setParameters(new JavaParameter[] { new JavaParameter(new Type("java.util.Hashtable"),
                    "environment") });
            method.setExceptions(new Type[] { new Type("javax.naming.NamingException"),
                    new Type("javax.jms.JMSException") });
            method.setReturns(new Type("javax.jms.QueueConnection"));
            retVal.addMethod(method);
        } else {
            if (hasRemoteView(metadata)) {
                method = new JavaMethod("getHome");
                method.setModifiers(new String[] { "public", "static" });
                method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
                method
                        .setReturns(new Type(getRemoteHomeInterfacePlugin().getVirtualType(metadata)
                                .toString()));
                retVal.addMethod(method);
                method = new JavaMethod("getHome");
                method.setModifiers(new String[] { "public", "static" });
                method.setParameters(new JavaParameter[] { new JavaParameter(new Type("java.util.Hashtable"),
                        "env") });
                method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
                method
                        .setReturns(new Type(getRemoteHomeInterfacePlugin().getVirtualType(metadata)
                                .toString()));
                retVal.addMethod(method);
            }
            if (hasLocalView(metadata)) {
                method = new JavaMethod("getLocalHome");
                method.setModifiers(new String[] { "public", "static" });
                method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
                method
                        .setReturns(new Type(getLocalHomeInterfacePlugin().getVirtualType(metadata)
                                .toString()));
                retVal.addMethod(method);
                method = new JavaMethod("getLocalHome");
                method.setModifiers(new String[] { "public", "static" });
                method.setParameters(new JavaParameter[] { new JavaParameter(new Type("java.util.Hashtable"),
                        "env") });
                method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
                method
                        .setReturns(new Type(getLocalHomeInterfacePlugin().getVirtualType(metadata)
                                .toString()));
                retVal.addMethod(method);
            }
            method = new JavaMethod("lookupHome");
            method.setModifiers(new String[] { "private", "static" });
            method.setParameters(new JavaParameter[] {
                    new JavaParameter(new Type("java.util.Hashtable"), "env"),
                    new JavaParameter(new Type("java.lang.String"), "jndiName"),
                    new JavaParameter(new Type("java.lang.Class"), "narrowTo") });
            method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
            method.setReturns(new Type("java.lang.Object"));
            retVal.addMethod(method);
        }

        method = new JavaMethod("lookup");
        method.setModifiers(new String[] { "public", "static" });
        method.setParameters(new JavaParameter[] { new JavaParameter(new Type("java.util.Hashtable"), "env"),
                new JavaParameter(new Type("java.lang.String"), "jndiName") });
        method.setExceptions(new Type[] { new Type("javax.naming.NamingException") });
        method.setReturns(new Type("java.lang.Object"));
        retVal.addMethod(method);

        if (isIncludeGUID()) {
            method = new JavaMethod("generateGUID");
            method.setModifiers(new String[] { "public", "final", "static" });
            method.setParameters(new JavaParameter[] {

            new JavaParameter(new Type("java.lang.Object"), "o") });

            method.setReturns(new Type("java.lang.String"));
            retVal.addMethod(method);
            field = new JavaField(new Type("java.lang.String"), "hexServerIP");
            field.setModifiers(new String[] { "private", "static" });
            retVal.addField(field);
            field = new JavaField(new Type("java.security.SecureRandom"), "seeder");
            field.setModifiers(new String[] { "private", "final", "static" });
            retVal.addField(field);
            method = new JavaMethod("hexFormat");
            method.setModifiers(new String[] { "private", "static" });
            method.setParameters(new JavaParameter[] {

            new JavaParameter(new Type("byte", 1), "value"), new JavaParameter(new Type("int"), "length") });

            method.setReturns(new Type("java.lang.String"));
            retVal.addMethod(method);
            method = new JavaMethod("hexFormat");
            method.setModifiers(new String[] { "private", "static" });
            method.setParameters(new JavaParameter[] {

            new JavaParameter(new Type("int"), "value"), new JavaParameter(new Type("int"), "length") });

            method.setReturns(new Type("java.lang.String"));
            retVal.addMethod(method);
        }

        return new JavaClass[] { retVal };
    }
View Full Code Here

            String type = params.get(i).getType();
            varArgs = VARARGS_REGEX.matcher(type).find();
            // QDox ignores varargs and generics, so we strip them out to help QDox.
            type = GENERIC_REGEX.matcher(type).replaceAll("");
            type = VARARGS_REGEX.matcher(type).replaceAll("");
            types[i] = new Type(type);
        }
        JavaMethod[] methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs);
        return methods.length == 1 ?  methods[0] : null;
    }
View Full Code Here

        }
        if ( fixTag( THROWS_TAG ) && javaMethod.getExceptions() != null && javaMethod.getExceptions().length > 0 )
        {
            for ( int i = 0; i < javaMethod.getExceptions().length; i++ )
            {
                Type exception = javaMethod.getExceptions()[i];

                separatorAdded = appendDefaultThrowsTag( sb, indent, separatorAdded, exception );
            }
        }
        if ( fixTag( SINCE_TAG ) && isNewMethodFromLastRevision( javaMethod ) )
View Full Code Here

        if ( javaMethod.getExceptions() != null )
        {
            for ( int j = 0; j < javaMethod.getExceptions().length; j++ )
            {
                Type exception = javaMethod.getExceptions()[j];

                if ( exception.getValue().endsWith( exceptionClassName ) )
                {
                    originalJavadocTag =
                        StringUtils.replace( originalJavadocTag, exceptionClassName, exception.getValue() );
                    if ( StringUtils.removeDuplicateWhitespace( originalJavadocTag ).trim().endsWith(
                        "@" + THROWS_TAG + " " + exception.getValue() ) )
                    {
                        originalJavadocTag += " if any.";
                    }

                    sb.append( originalJavadocTag );

                    // added qualified name
                    javaEntityTags.putJavadocThrowsTag( exception.getValue(), originalJavadocTag );

                    return;
                }
            }
        }
View Full Code Here

            if ( fixTag( THROWS_TAG ) && javaMethod.getExceptions() != null )
            {
                for ( int i = 0; i < javaMethod.getExceptions().length; i++ )
                {
                    Type exception = javaMethod.getExceptions()[i];

                    if ( javaEntityTags.getJavadocThrowsTag( exception.getValue(), true ) == null )
                    {
                        appendDefaultThrowsTag( sb, indent, exception );
                    }
                }
            }
View Full Code Here

            if ( fixTag( THROWS_TAG ) && javaMethod.getExceptions() != null )
            {
                for ( int i = 0; i < javaMethod.getExceptions().length; i++ )
                {
                    Type exception = javaMethod.getExceptions()[i];

                    separatorAdded = appendDefaultThrowsTag( sb, indent, separatorAdded, exception );
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.thoughtworks.qdox.model.Type

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.