Package com.sun.javadoc

Examples of com.sun.javadoc.Type


    /** Print the parameters of the parameterized type t */
    private String typeParameters(Options opt, ParameterizedType t) {
  String tp = "";
  if (t == null)
      return tp;
  Type args[] = t.typeArguments();
  tp += "<";
  for (int i = 0; i < args.length; i++) {
      tp += type(opt, args[i]);
      if (i != args.length - 1)
    tp += ", ";
View Full Code Here


  if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations
      return;
  String className = c.toString();

  // Print generalization (through the Java superclass)
  Type s = c.superclassType();
  if (s != null &&
      !s.toString().equals("java.lang.Object") &&
      !c.isEnum() &&
      !hidden(s.asClassDoc())) {
        ClassDoc sc = s.asClassDoc();
    w.println("\t//" + c + " extends " + s + "\n" +
        "\t" + relationNode(sc) + " -> " + relationNode(c) + " [dir=back,arrowtail=empty];");
    getClassInfo(className).addRelation(sc.toString(), RelationType.EXTENDS, RelationDirection.OUT);
    getClassInfo(sc.toString()).addRelation(className, RelationType.EXTENDS, RelationDirection.IN);
  }
View Full Code Here

    }



    private FieldRelationInfo getFieldRelationInfo(FieldDoc field) {
  Type type = field.type();
  if(type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable)
      return null;
 
  if (type.dimension().endsWith("[]")) {
      return new FieldRelationInfo(type.asClassDoc(), true);
  }
 
  Options opt = optionProvider.getOptionsFor(type.asClassDoc());
  if (opt.matchesCollPackageExpression(type.qualifiedTypeName())) {
      Type[] argTypes = getInterfaceTypeArguments(collectionClassDoc, type);
      if (argTypes != null && argTypes.length == 1 && !argTypes[0].isPrimitive())
    return new FieldRelationInfo(argTypes[0].asClassDoc(), true);

      argTypes = getInterfaceTypeArguments(mapClassDoc, type);
      if (argTypes != null && argTypes.length == 2 && !argTypes[1].isPrimitive())
    return new FieldRelationInfo(argTypes[1].asClassDoc(), true);
  }

  return new FieldRelationInfo(type.asClassDoc(), false);
    }
View Full Code Here

    } else if (argument instanceof WildcardType) {
      types = argument.asWildcardType().extendsBounds();
      bounds.put("?", getType(Object.class.getCanonicalName(), generator, generator.getTypeMap())); // default, will be overridden
    }
    if (types != null) {
      Type boundType = types.length > 0 ? types[0] : null;

      if (boundType != null) {
        cc.catalysts.cdoclet.generator.Type bound = getType(boundType, generator, ignore, visited);

        if (bound != cc.catalysts.cdoclet.generator.Type.NULL) {
          logger.debug("Adding boundary {} extends {} <{}>", new Object[]{argument.qualifiedTypeName(), boundType.qualifiedTypeName(), boundType.getClass().getCanonicalName()});
          bounds.put(argument.qualifiedTypeName(), bound);
        }
      }
    }
  }
View Full Code Here

                    if (resource == null) {
                        resource = new Resource(clazz.qualifiedName());
                    }
                    ParamTag[] paramTags = method.paramTags();
                    for (Parameter parameter : method.parameters()) {
                        Type type = parameter.type();
                        String name = parameter.name();
                        String comment = null;
                        for (ParamTag paramTag : paramTags) {
                            if (paramTag.parameterName().equals(name)) {
                                comment = paramTag.parameterComment();
                                break;
                            }
                        }
                        if (comment == null) {
                            comment = getFirstSentence(root.classNamed(type.qualifiedTypeName()));
                        }
                        resource.addDependency(type.qualifiedTypeName(),
                                               type.dimension().equals("[]") ? "0..*" : "1",
                                               comment);
                    }
                }
            }
            if (resource != null) {
View Full Code Here

            /*
             * To be consistent with previous implementations, we use
             * the deprecated style of placing the "[]" for the return
             * type (if any) after the parameter list.
             */
            Type returnType = methodDoc.returnType();
            String op = returnType.qualifiedTypeName() + " " +
                methodDoc.name() + "(";
            Parameter[] parameters = methodDoc.parameters();
            for (int i = 0; i < parameters.length; i++) {
                if (i > 0) {
                    op += ", ";
                }
                op += parameters[i].type().toString();
            }
            op += ")" + returnType.dimension();
            return op;
        }
View Full Code Here

        Parameter[] parameters = method.parameters();
        for (int i = 0; i < parameters.length; i++) {
            if (i > 0) {
                sig += ", ";
            }
            Type paramType = parameters[i].type();
            sig += paramType.typeName() + paramType.dimension();
        }
        sig += ")";
        return sig;
    }
View Full Code Here

        RemoteClass.Method method = remoteMethods[opnum];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type[] paramTypes = method.parameterTypes();
        String paramNames[] = nameParameters(paramTypes);
        Type returnType = methodDoc.returnType();
        ClassDoc[] exceptions = method.exceptionTypes();

        /*
         * Declare stub method; throw exceptions declared in remote
         * interface(s).
         */
        p.pln("// implementation of " +
              Util.getFriendlyUnqualifiedSignature(methodDoc));
        p.p("public " + returnType.toString() + " " + methodName + "(");
        for (int i = 0; i < paramTypes.length; i++) {
            if (i > 0) {
                p.p(", ");
            }
            p.p(paramTypes[i].toString() + " " + paramNames[i]);
        }
        p.plnI(")");
        if (exceptions.length > 0) {
            p.p("throws ");
            for (int i = 0; i < exceptions.length; i++) {
                if (i > 0) {
                    p.p(", ");
                }
                p.p(exceptions[i].qualifiedName());
            }
            p.pln();
        }
        p.pOlnI("{");

        /*
         * The RemoteRef.invoke methods throw Exception, but unless
         * this stub method throws Exception as well, we must catch
         * Exceptions thrown from the invocation.  So we must catch
         * Exception and rethrow something we can throw:
         * UnexpectedException, which is a subclass of
         * RemoteException.  But for any subclasses of Exception that
         * we can throw, like RemoteException, RuntimeException, and
         * any of the exceptions declared by this stub method, we want
         * them to pass through unmodified, so first we must catch any
         * such exceptions and rethrow them directly.
         *
         * We have to be careful generating the rethrowing catch
         * blocks here, because javac will flag an error if there are
         * any unreachable catch blocks, i.e. if the catch of an
         * exception class follows a previous catch of it or of one of
         * its superclasses.  The following method invocation takes
         * care of these details.
         */
        List<ClassDoc> catchList = computeUniqueCatchList(exceptions);

        /*
         * If we need to catch any particular exceptions (i.e. this method
         * does not declare java.lang.Exception), put the entire stub
         * method in a try block.
         */
        if (catchList.size() > 0) {
            p.plnI("try {");
        }

        if (version == StubVersion.VCOMPAT) {
            p.plnI("if (useNewInvoke) {");
        }
        if (version == StubVersion.VCOMPAT ||
            version == StubVersion.V1_2)
        {
            if (!Util.isVoid(returnType)) {
                p.p("Object $result = ");               // REMIND: why $?
            }
            p.p("ref.invoke(this, " + methodFieldNames[opnum] + ", ");
            if (paramTypes.length > 0) {
                p.p("new java.lang.Object[] {");
                for (int i = 0; i < paramTypes.length; i++) {
                    if (i > 0)
                        p.p(", ");
                    p.p(wrapArgumentCode(paramTypes[i], paramNames[i]));
                }
                p.p("}");
            } else {
                p.p("null");
            }
            p.pln(", " + method.methodHash() + "L);");
            if (!Util.isVoid(returnType)) {
                p.pln("return " +
                    unwrapArgumentCode(returnType, "$result") + ";");
            }
        }
        if (version == StubVersion.VCOMPAT) {
            p.pOlnI("} else {");
        }
        if (version == StubVersion.V1_1 ||
            version == StubVersion.VCOMPAT)
        {
            p.pln(REMOTE_CALL + " call = ref.newCall((" + REMOTE_OBJECT +
                ") this, operations, " + opnum + ", interfaceHash);");

            if (paramTypes.length > 0) {
                p.plnI("try {");
                p.pln("java.io.ObjectOutput out = call.getOutputStream();");
                writeMarshalArguments(p, "out", paramTypes, paramNames);
                p.pOlnI("} catch (java.io.IOException e) {");
                p.pln("throw new " + MARSHAL_EXCEPTION +
                    "(\"error marshalling arguments\", e);");
                p.pOln("}");
            }

            p.pln("ref.invoke(call);");

            if (Util.isVoid(returnType)) {
                p.pln("ref.done(call);");
            } else {
                p.pln(returnType.toString() + " $result;");
                                                        // REMIND: why $?
                p.plnI("try {");
                p.pln("java.io.ObjectInput in = call.getInputStream();");
                boolean objectRead =
                    writeUnmarshalArgument(p, "in", returnType, "$result");
View Full Code Here

        throws IOException
    {
        RemoteClass.Method method = remoteMethods[opnum];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();
        String paramNames[] = nameParameters(paramTypes);
        Type returnType = methodDoc.returnType();

        p.pOlnI("case " + opnum + ": // " +
            Util.getFriendlyUnqualifiedSignature(methodDoc));
        /*
         * Use nested block statement inside case to provide an independent
         * namespace for local variables used to unmarshal parameters for
         * this remote method.
         */
        p.pOlnI("{");

        if (paramTypes.length > 0) {
            /*
             * Declare local variables to hold arguments.
             */
            for (int i = 0; i < paramTypes.length; i++) {
                p.pln(paramTypes[i].toString() + " " + paramNames[i] + ";");
            }

            /*
             * Unmarshal arguments from call stream.
             */
            p.plnI("try {");
            p.pln("java.io.ObjectInput in = call.getInputStream();");
            boolean objectsRead = writeUnmarshalArguments(p, "in",
                paramTypes, paramNames);
            p.pOlnI("} catch (java.io.IOException e) {");
            p.pln("throw new " + UNMARSHAL_EXCEPTION +
                "(\"error unmarshalling arguments\", e);");
            /*
             * If any only if readObject has been invoked, we must catch
             * ClassNotFoundException as well as IOException.
             */
            if (objectsRead) {
                p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
                p.pln("throw new " + UNMARSHAL_EXCEPTION +
                    "(\"error unmarshalling arguments\", e);");
            }
            p.pOlnI("} finally {");
            p.pln("call.releaseInputStream();");
            p.pOln("}");
        } else {
            p.pln("call.releaseInputStream();");
        }

        if (!Util.isVoid(returnType)) {
            /*
             * Declare variable to hold return type, if not void.
             */
            p.p(returnType.toString() + " $result = ");
                                                        // REMIND: why $?
        }

        /*
         * Invoke the method on the server object.  If the remote
View Full Code Here

             * interface that we find in the Method object.
             */
            RemoteClass.Method method = remoteMethods[i];
            MethodDoc methodDoc = method.methodDoc();
            String methodName = methodDoc.name();
            Type paramTypes[] = method.parameterTypes();

            p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
                methodName + "\", new java.lang.Class[] {");
            for (int j = 0; j < paramTypes.length; j++) {
                if (j > 0)
View Full Code Here

TOP

Related Classes of com.sun.javadoc.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.