Collection<TypeDeclaration> typeDeclarations
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
EnunciateConfiguration config = this.enunciate.getConfig();
    AntPatternMatcher matcher = new AntPatternMatcher();
    matcher.setPathSeparator(".");
    if (!config.getApiExcludePatterns().isEmpty()) {
      Iterator<TypeDeclaration> typeDeclarationIt = typeDeclarations.iterator();
      while (typeDeclarationIt.hasNext()) {
        TypeDeclaration typeDeclaration = typeDeclarationIt.next();
        boolean exclude = false;
        if (config.getApiExcludePatterns().contains(typeDeclaration.getQualifiedName())) {
          exclude = true;
          debug("%s was explicitly excluded.", typeDeclaration.getQualifiedName());
void removeExcludedClasses(Collection<TypeDeclaration> typeDeclarations)
Collection<TypeDeclaration> typeDeclarations
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
EnunciateConfiguration config = this.enunciate.getConfig();
    AntPatternMatcher matcher = new AntPatternMatcher();
    matcher.setPathSeparator(".");
    if (!config.getApiIncludePatterns().isEmpty()) {
      Iterator<TypeDeclaration> typeDeclarationIt = typeDeclarations.iterator();
      while (typeDeclarationIt.hasNext()) {
        TypeDeclaration typeDeclaration = typeDeclarationIt.next();
        boolean include = false;
        if (config.getApiIncludePatterns().contains(typeDeclaration.getQualifiedName())) {
          include = true;
          debug("%s was explicitly included.", typeDeclaration.getQualifiedName());
void trimNotIncludedClasses(Collection<TypeDeclaration> typeDeclarations)
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
return this.enunciateConfig == null || this.enunciateConfig.isIncludeReferencedClasses();
    int position = Collections.binarySearch(this.typeDefinitions, typeDef, CLASS_COMPARATOR);
    if (position < 0 && !isKnownType(typeDef)) {
      this.typeDefinitions.add(-position - 1, typeDef);
      add(typeDef.getSchema());
      String namespace = typeDef.getNamespace();
      String prefix = addNamespace(namespace);
      SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
      if (schemaInfo == null) {
        schemaInfo = new SchemaInfo();
        schemaInfo.setId(prefix);
        schemaInfo.setNamespace(namespace);
        namespacesToSchemas.put(namespace, schemaInfo);
boolean includeReferencedClasses()
TypeDefinition typeDef
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
return knownTypes.containsKey(typeDef.getQualifiedName())
      || JAXBElement.class.getName().equals(typeDef.getQualifiedName())
      || ((DecoratedTypeMirror)typeDef.getSuperclass()).isInstanceOf(JAXBElement.class.getName());
boolean isKnownType(TypeDefinition typeDef)
Attribute attribute
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(attribute);
    addReferencedTypeDefinitions(attribute.isAdapted() ? attribute.getAdapterType() : attribute.getAccessorType());
void addReferencedTypeDefinitions(Attribute attribute)
Value value
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(value);
    addReferencedTypeDefinitions(value.isAdapted() ? value.getAdapterType() : value.getAccessorType());
void addReferencedTypeDefinitions(Value value)
Element element
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(element);
    for (Element chioce : element.getChoices()) {
      addReferencedTypeDefinitions(chioce.isAdapted() ? chioce.getAdapterType() : chioce.getAccessorType());


      if (includeReferencedClasses()) {
        addSeeAlsoTypeDefinitions(endpoint);
        addReferencedTypeDefinitions(restMethod);
void addReferencedTypeDefinitions(Element element)
RESTMethod restMethod
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(restMethod);
    RESTParameter nounValue = restMethod.getNounValue();
    if (nounValue != null) {
      TypeMirror nounValueType = nounValue.getType();
      if (nounValueType instanceof ClassType) {
        ClassDeclaration classDeclaration = ((ClassType) nounValueType).getDeclaration();
        if (classDeclaration.getAnnotation(XmlRootElement.class) != null) {
          //only add referenced type definitions for root elements.
          add(new RootElementDeclaration(classDeclaration, createTypeDefinition(classDeclaration)));
void addReferencedTypeDefinitions(RESTMethod restMethod)
ResourceMethod resourceMethod
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(resourceMethod);
    ParameterDeclaration ep = resourceMethod.getEntityParameter();
    if (ep != null) {
      TypeMirror type = ep.getType();
      if (type instanceof ClassType) {
        ClassDeclaration classDeclaration = ((ClassType) type).getDeclaration();
        if (classDeclaration.getAnnotation(XmlRootElement.class) != null) {
          //only add referenced type definitions for root elements.
          add(new RootElementDeclaration(classDeclaration, createTypeDefinition(classDeclaration)));
void addReferencedTypeDefinitions(ResourceMethod resourceMethod)
RootElementDeclaration rootEl
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
TypeDefinition typeDefinition = rootEl.getTypeDefinition();
    if (typeDefinition != null) {
      add(typeDefinition);
void addReferencedTypeDefinitions(RootElementDeclaration rootEl)
EndpointInterface ei
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(ei);
    for (WebMethod webMethod : ei.getWebMethods()) {
      addReferencedTypeDefinitions(webMethod);
void addReferencedTypeDefinitions(EndpointInterface ei)
WebMethod webMethod
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(webMethod);
    WebResult result = webMethod.getWebResult();
    addReferencedTypeDefinitions(result.isAdapted() ? result.getAdapterType() : result.getType());
    for (WebParam webParam : webMethod.getWebParameters()) {
      addReferencedTypeDefinitions(webParam.isAdapted() ? webParam.getAdapterType() : webParam.getType());
void addReferencedTypeDefinitions(WebMethod webMethod)
WebFault webFault
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
if (webFault.isImplicitSchemaElement()) {
      for (ImplicitChildElement childElement : webFault.getChildElements()) {
        WebFault.FaultBeanChildElement fbce = (WebFault.FaultBeanChildElement) childElement;
        addReferencedTypeDefinitions(fbce.isAdapted() ? fbce.getAdapterType() : fbce.getType());
void addReferencedTypeDefinitions(WebFault webFault)
TypeMirror type
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
type.accept(new ReferencedTypeDefinitionVisitor());
void addReferencedTypeDefinitions(TypeMirror type)
Declaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
XmlSeeAlso seeAlso = declaration.getAnnotation(XmlSeeAlso.class);
    if (seeAlso != null) {
      try {
        Class[] classes = seeAlso.value();
        AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
        for (Class clazz : classes) {
          ClassType type = (ClassType) ape.getTypeUtils().getDeclaredType(ape.getTypeDeclaration(clazz.getName()));
          ClassDeclaration typeDeclaration = type.getDeclaration();
          if (typeDeclaration != null) {
            add(createTypeDefinition(typeDeclaration));
void addSeeAlsoTypeDefinitions(Declaration declaration)
ClassDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
if (isEnumType(declaration)) {
      return new EnumTypeDefinition((EnumDeclaration) declaration);
TypeDefinition createTypeDefinition(ClassDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
return !(declaration instanceof InterfaceDeclaration) && !isEnumType(declaration) && !isSimpleType(declaration);
boolean isComplexType(TypeDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
return (declaration instanceof EnumDeclaration);
boolean isEnumType(TypeDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
if (declaration instanceof InterfaceDeclaration) {
      if (declaration.getAnnotation(javax.xml.bind.annotation.XmlType.class) != null) {
        throw new ValidationException(declaration.getPosition(), "An interface must not be annotated with @XmlType.");
boolean isSimpleType(TypeDeclaration declaration)
GenericTypeDefinition typeDef
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
boolean none = (typeDef.getAttributes().isEmpty()) && (typeDef.getElements().isEmpty());
    ClassDeclaration superDeclaration = ((ClassDeclaration) typeDef.getDelegate()).getSuperclass().getDeclaration();
    if (!Object.class.getName().equals(superDeclaration.getQualifiedName())) {
      none &= hasNeitherAttributesNorElements(new GenericTypeDefinition(superDeclaration));
    return none;
    addReferencedTypeDefinitions(registry);
  /**
   * Add the referenced type definitions for a registry..
   *
   * @param registry The registry.
   */
  protected void addReferencedTypeDefinitions(Registry registry) {
    addSeeAlsoTypeDefinitions(registry);
    for (MethodDeclaration methodDeclaration : registry.getInstanceFactoryMethods()) {
      addReferencedTypeDefinitions(methodDeclaration.getReturnType());
boolean hasNeitherAttributesNorElements(GenericTypeDefinition typeDef)
LocalElementDeclaration led
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
addSeeAlsoTypeDefinitions(led);
    TypeDeclaration scope = led.getElementScope();
    if (scope instanceof ClassDeclaration) {
      add(createTypeDefinition((ClassDeclaration) scope));
void addReferencedTypeDefinitions(LocalElementDeclaration led)
TypeMirror typeMirror
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitTypeMirror(TypeMirror typeMirror)
PrimitiveType primitiveType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitPrimitiveType(PrimitiveType primitiveType)
VoidType voidType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitVoidType(VoidType voidType)
ReferenceType referenceType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitReferenceType(ReferenceType referenceType)
DeclaredType declaredType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitDeclaredType(DeclaredType declaredType)
ClassType classType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
if (classType instanceof AdapterType) {
        ((AdapterType)classType).getAdaptingType().accept(this);
void visitClassType(ClassType classType)
EnumType enumType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
EnumDeclaration enumDeclaration = enumType.getDeclaration();
      if (enumDeclaration != null) {
        add(createTypeDefinition(enumDeclaration));
void visitEnumType(EnumType enumType)
InterfaceType interfaceType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
MapType mapType = MapTypeUtil.findMapType(interfaceType);
      if (mapType != null) {
        mapType.getKeyType().accept(this);
        mapType.getValueType().accept(this);
void visitInterfaceType(InterfaceType interfaceType)
AnnotationType annotationType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
//no-op
void visitAnnotationType(AnnotationType annotationType)
ArrayType arrayType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
arrayType.getComponentType().accept(this);
void visitArrayType(ArrayType arrayType)
TypeVariable typeVariable
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
Iterator<ReferenceType> bounds = typeVariable.getDeclaration().getBounds().iterator();
      if (bounds.hasNext()) {
        bounds.next().accept(this);
void visitTypeVariable(TypeVariable typeVariable)
WildcardType wildcardType
core/src/main/java/org/codehaus/enunciate/apt/EnunciateFreemarkerModel.java
Iterator<ReferenceType> upperBounds = wildcardType.getUpperBounds().iterator();
      if (upperBounds.hasNext()) {
        upperBounds.next().accept(this);
void visitWildcardType(WildcardType wildcardType)
core/src/main/java/org/codehaus/enunciate/config/EnunciateConfiguration.java
return includeReferencedClasses;
boolean isIncludeReferencedClasses()
boolean includeReferencedClasses
core/src/main/java/org/codehaus/enunciate/config/EnunciateConfiguration.java
this.includeReferencedClasses = includeReferencedClasses;
void setIncludeReferencedClasses(boolean includeReferencedClasses)
core/src/main/java/org/codehaus/enunciate/config/EnunciateConfiguration.java
return excludeUnreferencedClasses;
boolean isExcludeUnreferencedClasses()
boolean excludeUnreferencedClasses
core/src/main/java/org/codehaus/enunciate/config/EnunciateConfiguration.java
this.excludeUnreferencedClasses = excludeUnreferencedClasses;
void setExcludeUnreferencedClasses(boolean excludeUnreferencedClasses)
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
public void visit(File file) {
              String path = pathFile.toURI().relativize(file.toURI()).getPath();
              if (path.endsWith(".class")) {
                String classname = path.substring(0, path.length() - 6).replace('/', '.').replace('$', '.');
                debug("Noticed class %s at %s.", classname, file);
                foundClasses2Sources.put(classname, foundClasses2Sources.get(classname));
new FileVisitor()
Map<String  File> foundClasses2Sources  Map<String  File> classes2sources
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
if (this.config != null && this.config.getAPIImports() != null
      && !this.config.getAPIImports().isEmpty() && !foundClasses2Sources.isEmpty()) {
      AntPatternMatcher matcher = new AntPatternMatcher();
      matcher.setPathSeparator(".");
      for (APIImport apiImport : this.config.getAPIImports()) {
        String pattern = apiImport.getPattern();
        if (pattern != null) {
          for (Map.Entry<String, File> foundEntry : foundClasses2Sources.entrySet()) {
            if (!classes2sources.containsKey(foundEntry.getKey())) {
              if (pattern.equals(foundEntry.getKey())) {
                debug("Class %s will be imported because it was explicitly listed.", foundEntry.getKey());
                classes2sources.put(foundEntry.getKey(), apiImport.isSeekSource() ? foundEntry.getValue() : null);
void copyImportedClasses(Map<String, File> foundClasses2Sources, Map<String, File> classes2sources)
File dir  FileFilter filter  final Collection<String> filenames
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
visitFiles(dir, filter, new FileVisitor() {
      public void visit(File file) {
        filenames.add(file.getAbsolutePath());
void findFiles(File dir, FileFilter filter, final Collection<String> filenames)
File dir  FileFilter filter  FileVisitor visitor
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
visitor.visit(file);
        visitFiles(subdir, filter, visitor);
  /**
   * A scratch directory for Enunciate to use.
   *
   * @return A scratch directory for Enunciate to use.
   */
  public File getScratchDir() {
    return scratchDir;
void visitFiles(File dir, FileFilter filter, FileVisitor visitor)
File scratchDir
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
this.scratchDir = scratchDir;
void setScratchDir(File scratchDir)
core/src/main/java/org/codehaus/enunciate/main/Enunciate.java
public boolean accept(File file) {
      return file.getName().endsWith(".java");
new FileFilter()
File scratchDir
core/src/main/java/org/codehaus/enunciate/main/EnunciateTask.java
this.scratchDir = scratchDir;
void setScratchDir(File scratchDir)
typeMirror instanceof MapType
core/src/main/java/org/codehaus/enunciate/util/MapTypeUtil.java
return (MapType) typeMirror;
else if (typeMirror instanceof MapType)
ClassDeclaration declaration  EnunciateFreemarkerModel model
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
/**
   * Tests getting the root model.
   */
  public void testGetRootModelExcludingUnreferenced() throws Exception {
    EnunciateConfiguration config = new EnunciateConfiguration();
    config.putNamespace("urn:test", "test");
    config.putNamespace("http://enunciate.codehaus.org/samples/contract", "tContract");

    final boolean[] validated = new boolean[]{false
TypeDefinition createTypeDefinition(ClassDeclaration declaration, EnunciateFreemarkerModel model)
enunciate
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
@Override
      protected void validate(EnunciateFreemarkerModel model) {
        validated[0] = true;
new EnunciateAnnotationProcessor(enunciate)
TypeDeclaration declaration
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
return "org.codehaus.enunciate.samples.services.NamespacedWebService".equals(declaration.getQualifiedName());
boolean isEndpointInterface(TypeDeclaration declaration)
TypeDeclaration declaration
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
boolean potentialSchemaType = "org.codehaus.enunciate.samples.schema".equals(declaration.getPackage().getQualifiedName());
        String simpleName = declaration.getSimpleName();
        potentialSchemaType &= (simpleName.equals("BeanOne") || simpleName.equals("BeanTwo") || simpleName.equals("BeanThree"));
        return potentialSchemaType;
boolean isPotentialSchemaType(TypeDeclaration declaration)
ClassDeclaration declaration  EnunciateFreemarkerModel model
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
if ("org.codehaus.enunciate.samples.schema.BeanOne".equals(declaration.getQualifiedName())) {
          return new ComplexTypeDefinition(declaration);
TypeDefinition createTypeDefinition(ClassDeclaration declaration, EnunciateFreemarkerModel model)
ClassDeclaration declaration  TypeDefinition typeDefinition
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateAnnotationProcessor.java
if ("org.codehaus.enunciate.samples.schema.BeanThree".equals(declaration.getQualifiedName())) {
          return new RootElementDeclaration(declaration, typeDefinition);
RootElementDeclaration createRootElementDeclaration(ClassDeclaration declaration, TypeDefinition typeDefinition)
core/src/test/java/org/codehaus/enunciate/apt/TestEnunciateFreemarkerModel.java
@Override
      protected boolean includeReferencedClasses() {
        return false;
new EnunciateFreemarkerModel()
ClassDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
if (isEnumType(declaration)) {
      return new EnumTypeDefinition((EnumDeclaration) declaration);
TypeDefinition createTypeDefinition(ClassDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
return !(declaration instanceof InterfaceDeclaration) && !isEnumType(declaration) && !isSimpleType(declaration);
boolean isComplexType(TypeDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
return (declaration instanceof EnumDeclaration);
boolean isEnumType(TypeDeclaration declaration)
TypeDeclaration declaration
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
if (declaration instanceof InterfaceDeclaration) {
      if (declaration.getAnnotation(XmlType.class) != null) {
        throw new ValidationException(declaration.getPosition(), "An interface must not be annotated with @XmlType.");
boolean isSimpleType(TypeDeclaration declaration)
GenericTypeDefinition typeDef
core/src/main/java/org/codehaus/enunciate/apt/EnunciateAnnotationProcessor.java
boolean none = (typeDef.getAttributes().isEmpty()) && (typeDef.getElements().isEmpty());
    ClassDeclaration superDeclaration = ((ClassDeclaration) typeDef.getDelegate()).getSuperclass().getDeclaration();
    if (!Object.class.getName().equals(superDeclaration.getQualifiedName())) {
      none &= hasNeitherAttributesNorElements(new GenericTypeDefinition(superDeclaration));
boolean hasNeitherAttributesNorElements(GenericTypeDefinition typeDef)
core/src/main/java/org/codehaus/enunciate/config/APIImport.java
return clazz;
String getClassname()