/** * Return this type as a class. Array dimensions are ignored. * * @return a ClassDocImpl if the type is a Class. * Return null if it is a primitive type.. */ public ClassDoc asClassDoc() { return skipArrays().asClassDoc(); }
@Override public ClassDoc asClassDoc() { return this.underlyingType().asClassDoc(); }
/** * Return the class that originally defined the method that * is overridden by the current definition, or null if no * such class exists. * * @return a ClassDocImpl representing the superclass that * originally defined this method, null if this method does * not override a definition in a superclass. */ public ClassDoc overriddenClass() { com.sun.javadoc.Type t = overriddenType(); return (t != null) ? t.asClassDoc() : null; }
private static boolean equalParameters(@Nullable List<Object> expected, Parameter[] actual) { if (expected == null) return true; if (expected.size() != actual.length) return false; for (int i = 0; i < expected.size(); i++) { Object parameterType = expected.get(i); Type mdParameterType = actual[i].type(); ClassDoc mdParameterClassDoc = mdParameterType.asClassDoc(); if (mdParameterClassDoc == null) { if (!mdParameterType.toString().equals(parameterType)) return false; } else { if (!mdParameterClassDoc.equals(parameterType)) return false; } } return true; }
private static boolean equalParameters(@Nullable List<Object> expected, Parameter[] actual) { if (expected == null) return true; if (expected.size() != actual.length) return false; for (int i = 0; i < expected.size(); i++) { Object parameterType = expected.get(i); Type mdParameterType = actual[i].type(); ClassDoc mdParameterClassDoc = mdParameterType.asClassDoc(); if (mdParameterClassDoc == null) { if (!mdParameterType.toString().equals(parameterType)) return false; } else { if (!mdParameterClassDoc.equals(parameterType)) return false; } } return true; }
private static void addAllInterfaceTypes(Map<ClassDoc,Type> results, Type type, Type[] interfaceTypes, boolean raw, Configuration configuration) { for (int i = 0; i < interfaceTypes.length; i++) { Type interfaceType = interfaceTypes[i]; ClassDoc interfaceClassDoc = interfaceType.asClassDoc(); if (! (interfaceClassDoc.isPublic() || (configuration != null && isLinkable(interfaceClassDoc, configuration)))) { continue; } if (raw) interfaceType = interfaceType.asClassDoc(); results.put(interfaceClassDoc, interfaceType); List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration); for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) { Type superInterface = iter.next(); results.put(superInterface.asClassDoc(), superInterface); } } if (type instanceof ParameterizedType) findAllInterfaceTypes(results, (ParameterizedType) type, configuration); else if (((ClassDoc) type).typeParameters().length == 0) findAllInterfaceTypes(results, (ClassDoc) type, raw, configuration); else findAllInterfaceTypes(results, (ClassDoc) type, true, configuration); }
/** * Search for the method in the array of interfaces. If found check if it is * overridden by any other subinterface method which this class * implements. If it is not overidden, add it in the method list. * Do this recursively for all the extended interfaces for each interface * from the array passed. */ private void buildImplementedMethodList(boolean sort) { List<Type> intfacs = Util.getAllInterfaces(classdoc, configuration, sort); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext(); ) { Type interfaceType = iter.next(); MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); if (!overridingMethodFound(found)) { methlist.add(found); interfaces.put(found, interfaceType); } } } }
/** * Search for the method in the array of interfaces. If found check if it is * overridden by any other subinterface method which this class * implements. If it is not overidden, add it in the method list. * Do this recursively for all the extended interfaces for each interface * from the array passed. */ private void buildImplementedMethodList(boolean sort) { List<Type> intfacs = Util.getAllInterfaces(classdoc, configuration, sort); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext(); ) { Type interfaceType = iter.next(); MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); if (!overridingMethodFound(found)) { methlist.add(found); interfaces.put(found, interfaceType); } } } }
private String prettyPrintParameterList(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) { result.append(", "); } Type pt = parameter.type(); if (pt.isPrimitive()) { result.append(pt.toString()); continue; } // Show erasure type, not type variable name. ClassDoc cd = pt.asClassDoc(); assert cd != null : parameter; result.append(cd.name()); } result.append(')'); return result.toString(); } };
private String prettyPrintParameterList(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) { result.append(", "); } Type pt = parameter.type(); if (pt.isPrimitive()) { result.append(pt.toString()); continue; } // Show erasure type, not type variable name. ClassDoc cd = pt.asClassDoc(); assert cd != null : parameter; result.append(cd.name()); } result.append(')'); return result.toString(); } };
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); }
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); }
/** * Print next package link */ protected void navLinkNext() { if( next == null ) { printText( "doclet.Next_Class" ); } else { printLink( new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "", configuration.getText( "doclet.Next_Class" ), true ) ); } }
/** * Print previous package link */ protected void navLinkPrevious() { if( prev == null ) { printText( "doclet.Prev_Class" ); } else { printLink( new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "", configuration.getText( "doclet.Prev_Class" ), true ) ); } }
protected void printTypeLinkNoDimension(Type type) { ClassDoc cd = type.asClassDoc(); if (type.isPrimitive() || cd.isPackagePrivate()) { print(type.typeName()); } else { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type)); } } }
protected void printTypeLinkNoDimension(Type type) { ClassDoc cd = type.asClassDoc(); //Linking to package private classes in serialized for causes //broken links. Don't link to them. if (type.isPrimitive() || cd.isPackagePrivate()) { print(type.typeName()); } else { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type)); } }
/** * Get link to next class. * * @return a content tree for the next class link */ public Content getNavLinkNext() { Content li; if (next != null) { Content nextLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, next.asClassDoc()) .label(nextclassLabel).strong(true)); li = HtmlTree.LI(nextLink); } else li = HtmlTree.LI(nextclassLabel); return li; }
/** * Get link to previous class. * * @return a content tree for the previous class link */ public Content getNavLinkPrevious() { Content li; if (prev != null) { Content prevLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, prev.asClassDoc()) .label(prevclassLabel).strong(true)); li = HtmlTree.LI(prevLink); } else li = HtmlTree.LI(prevclassLabel); return li; }
/** * Build the field sub header. */ public void buildFieldSubHeader() { if (! currentClass.definesSerializableFields() ){ FieldDoc field = (FieldDoc) currentMember; fieldWriter.writeMemberHeader(field.type().asClassDoc(), field.type().typeName(), field.type().dimension(), field.name()); } }
/** * Build the field sub header. * * @param node the XML element that specifies which components to document * @param fieldsContentTree content tree to which the documentation will be added */ public void buildFieldSubHeader(XMLNode node, Content fieldsContentTree) { if (!currentClass.definesSerializableFields()) { FieldDoc field = (FieldDoc) currentMember; fieldWriter.addMemberHeader(field.type().asClassDoc(), field.type().typeName(), field.type().dimension(), field.name(), fieldsContentTree); } }