/** * Return true if this is an array of a primitive type. */ public boolean isPrimitive() { return skipArrays().isPrimitive(); }
@Override public boolean isPrimitive() { return this.underlyingType().isPrimitive(); }
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(); } };
protected int getReturnTypeLength(ExecutableMemberDoc member) { if (member instanceof MethodDoc) { MethodDoc method = (MethodDoc)member; Type rettype = method.returnType(); if (rettype.isPrimitive()) { return rettype.typeName().length() + rettype.dimension().length(); } else { LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_MEMBER, rettype); writer.getLink(linkInfo); return linkInfo.displayLength; } } else { // it's a constructordoc return -1; } }
/** * For backward compatibility, include an anchor using the erasures of the * parameters. NOTE: We won't need this method anymore after we fix * see tags so that they use the type instead of the erasure. * * @param emd the ExecutableMemberDoc to anchor to. * @return the 1.4.x style anchor for the ExecutableMemberDoc. */ protected String getErasureAnchor(ExecutableMemberDoc emd) { StringBuffer buf = new StringBuffer(emd.name() + "("); Parameter[] params = emd.parameters(); boolean foundTypeVariable = false; for (int i = 0; i < params.length; i++) { if (i > 0) { buf.append(","); } Type t = params[i].type(); foundTypeVariable = foundTypeVariable || t.asTypeVariable() != null; buf.append(t.isPrimitive() ? t.typeName() : t.asClassDoc().qualifiedName()); buf.append(t.dimension()); } buf.append(")"); return foundTypeVariable ? buf.toString() : null; } }
/** * For backward compatibility, include an anchor using the erasures of the * parameters. NOTE: We won't need this method anymore after we fix * see tags so that they use the type instead of the erasure. * * @param emd the ExecutableMemberDoc to anchor to. * @return the 1.4.x style anchor for the ExecutableMemberDoc. */ protected String getErasureAnchor(ExecutableMemberDoc emd) { StringBuilder buf = new StringBuilder(emd.name() + "("); Parameter[] params = emd.parameters(); boolean foundTypeVariable = false; for (int i = 0; i < params.length; i++) { if (i > 0) { buf.append(","); } Type t = params[i].type(); foundTypeVariable = foundTypeVariable || t.asTypeVariable() != null; buf.append(t.isPrimitive() ? t.typeName() : t.asClassDoc().qualifiedName()); buf.append(t.dimension()); } buf.append(")"); return foundTypeVariable ? writer.getName(buf.toString()) : null; } }
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); }
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)); } }
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); }
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)); } } }
public static Method getMethodByDoc(Class<?> classz, MethodDoc methodDoc) throws Exception { Class<?>[] parameterTypes = new Class<?>[methodDoc.parameters().length]; for (int i = 0; i < methodDoc.parameters().length; i++) { Parameter parameter = methodDoc.parameters()[i]; if (parameter.type().isPrimitive()) { if (parameter.type().simpleTypeName().equals("byte")) parameterTypes[i] = byte.class; else if (parameter.type().simpleTypeName().equals("boolean")) parameterTypes[i] = boolean.class; else if (parameter.type().simpleTypeName().equals("short")) parameterTypes[i] = short.class; else if (parameter.type().simpleTypeName().equals("char")) parameterTypes[i] = char.class; else if (parameter.type().simpleTypeName().equals("int")) parameterTypes[i] = int.class; else if (parameter.type().simpleTypeName().equals("long")) parameterTypes[i] = long.class; else if (parameter.type().simpleTypeName().equals("float")) parameterTypes[i] = float.class; else if (parameter.type().simpleTypeName().equals("double")) parameterTypes[i] = double.class; } else { parameterTypes[i] = Class.forName(parameter.type().qualifiedTypeName()); } if (!StringUtils.isEmpty(parameter.type().dimension())) { int dimension = StringUtil.getStrCount(parameter.type().dimension(), "[]"); parameterTypes[i] = Array.newInstance(parameterTypes[i], (int[])Array.newInstance(int.class, dimension)).getClass(); } } return classz.getDeclaredMethod(methodDoc.name(), parameterTypes); }
Type pcd = params[k].type(); if ((! params[k].type().isPrimitive()) && ! classArgs.contains(pcd) && ! (pcd instanceof TypeVariable)) {
Type pcd = params[k].type(); if ((! params[k].type().isPrimitive()) && ! classArgs.contains(pcd) && ! (pcd instanceof TypeVariable)) {
if (type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable || c.toString().equals(type.asClassDoc().toString())) continue;
annotationArgumentNode.setPrimitive(annotationArgumentType.isPrimitive()); annotationArgumentNode.setArray(annotationArgumentType.dimension().length() > 0);
/** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { Type returnType = ((MethodDoc) holder).returnType(); Tag[] tags = holder.tags(name); //Make sure we are not using @return tag on method with void return type. if (returnType.isPrimitive() && returnType.typeName().equals("void")) { if (tags.length > 0) { writer.getMsgRetriever().warning(holder.position(), "doclet.Return_tag_on_void_method"); } return null; } //Inherit @return tag if necessary. if (tags.length == 0) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag}; } return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null; } }
/** * {@inheritDoc} */ public Content getTagletOutput(Doc holder, TagletWriter writer) { Type returnType = ((MethodDoc) holder).returnType(); Tag[] tags = holder.tags(name); //Make sure we are not using @return tag on method with void return type. if (returnType.isPrimitive() && returnType.typeName().equals("void")) { if (tags.length > 0) { writer.getMsgRetriever().warning(holder.position(), "doclet.Return_tag_on_void_method"); } return null; } //Inherit @return tag if necessary. if (tags.length == 0) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag}; } return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null; } }
mapTypeParameters(classToFieldDocTypeParam, fd, fd); mapAnnotations(annotationToFieldDoc, fd, fd); if (! fd.type().isPrimitive()) { add(classToField, fd.type().asClassDoc(), fd); mapTypeParameters(classToExecMemberDocTypeParam, md, md); mapAnnotations(classToExecMemberDocAnnotations, md, md); if (! (md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) { mapTypeParameters(classToExecMemberDocReturnTypeParam, md.returnType(), md);
mapTypeParameters(classToFieldDocTypeParam, fd, fd); mapAnnotations(annotationToFieldDoc, fd, fd); if (! fd.type().isPrimitive()) { add(classToField, fd.type().asClassDoc(), fd); mapTypeParameters(classToExecMemberDocTypeParam, md, md); mapAnnotations(classToExecMemberDocAnnotations, md, md); if (! (md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) { mapTypeParameters(classToExecMemberDocReturnTypeParam, md.returnType(), md);