Debian Codegraph @

contribs/wadl-resourcedoc-doclet/src/main/java/com/sun/jersey/wadl/resourcedoc/DocProcessorWrapper.java

raw
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can
10 * obtain a copy of the License at
11 * http://glassfish.java.net/public/CDDL+GPL_1_1.html
12 * or packager/legal/LICENSE.txt. See the License for the specific
13 * language governing permissions and limitations under the License.
14 *
15 * When distributing the software, include this License Header Notice in each
16 * file and include the License file at packager/legal/LICENSE.txt.
17 *
18 * GPL Classpath Exception:
19 * Oracle designates this particular file as subject to the "Classpath"
20 * exception as provided by Oracle in the GPL Version 2 section of the License
21 * file that accompanied this code.
22 *
23 * Modifications:
24 * If applicable, add the following below the License Header, with the fields
25 * enclosed by brackets [] replaced by your own identifying information:
26 * "Portions Copyright [year] [name of copyright owner]"
27 *
28 * Contributor(s):
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40 package com.sun.jersey.wadl.resourcedoc;
41
42 import java.util.ArrayList;
43 import java.util.Arrays;
44 import java.util.List;
45
46 import com.sun.javadoc.ClassDoc;
47 import com.sun.javadoc.MethodDoc;
48 import com.sun.javadoc.ParamTag;
49 import com.sun.javadoc.Parameter;
50 import com.sun.jersey.server.wadl.generators.resourcedoc.model.ClassDocType;
51 import com.sun.jersey.server.wadl.generators.resourcedoc.model.MethodDocType;
52 import com.sun.jersey.server.wadl.generators.resourcedoc.model.ParamDocType;
53
54 /**
55 * This {@link DocProcessor} wraps multiple {@link DocProcessor}s.<br>
56 * Created on: Jul 27, 2008<br>
57 *
58 * @author <a href="mailto:[email protected]">Martin Grotzke</a>
59 * @version $Id$
60 */
61 public class DocProcessorWrapper implements DocProcessor {
62
63 private final List<DocProcessor> _docProcessors;
64
65 public DocProcessorWrapper() {
66 _docProcessors = new ArrayList<DocProcessor>();
67 }
68
69 void add( DocProcessor docProcessor ) {
70 _docProcessors.add( docProcessor );
71 }
72
73 /* (non-Javadoc)
74 * @see com.sun.jersey.wadl.resourcedoc.DocProcessor#getRequiredJaxbContextClasses()
75 */
76 public Class<?>[] getRequiredJaxbContextClasses() {
77 final List<Class<?>> result = new ArrayList<Class<?>>();
78 for( DocProcessor docProcessor : _docProcessors ) {
79 final Class<?>[] requiredJaxbContextClasses = docProcessor.getRequiredJaxbContextClasses();
80 if ( requiredJaxbContextClasses != null && requiredJaxbContextClasses.length > 0 ) {
81 result.addAll( Arrays.asList( requiredJaxbContextClasses ) );
82 }
83 }
84 return result.toArray( new Class<?>[0] );
85 }
86
87 public String[] getCDataElements() {
88 final List<String> result = new ArrayList<String>();
89 for( DocProcessor docProcessor : _docProcessors ) {
90 final String[] cdataElements = docProcessor.getCDataElements();
91 if ( cdataElements != null && cdataElements.length > 0 ) {
92 result.addAll( Arrays.asList( cdataElements ) );
93 }
94 }
95 return result.toArray( new String[0] );
96 }
97
98 /* (non-Javadoc)
99 * @see com.sun.jersey.wadl.resourcedoc.DocProcessor#processClassDoc(com.sun.javadoc.ClassDoc, com.sun.jersey.server.impl.wadl.generators.resourcedoc.model.ClassDocType)
100 */
101 public void processClassDoc( ClassDoc classDoc, ClassDocType classDocType ) {
102 for( DocProcessor docProcessor : _docProcessors ) {
103 docProcessor.processClassDoc( classDoc, classDocType );
104 }
105 }
106
107 /* (non-Javadoc)
108 * @see com.sun.jersey.wadl.resourcedoc.DocProcessor#processMethodDoc(com.sun.javadoc.MethodDoc, com.sun.jersey.server.impl.wadl.generators.resourcedoc.model.MethodDocType)
109 */
110 public void processMethodDoc( MethodDoc methodDoc,
111 MethodDocType methodDocType ) {
112 for( DocProcessor docProcessor : _docProcessors ) {
113 docProcessor.processMethodDoc( methodDoc, methodDocType );
114 }
115 }
116
117 /* (non-Javadoc)
118 * @see com.sun.jersey.wadl.resourcedoc.DocProcessor#processParamTag(com.sun.javadoc.ParamTag, com.sun.javadoc.Parameter, com.sun.jersey.server.impl.wadl.generators.resourcedoc.model.ParamDocType)
119 */
120 public void processParamTag( ParamTag paramTag, Parameter parameter,
121 ParamDocType paramDocType ) {
122 for( DocProcessor docProcessor : _docProcessors ) {
123 docProcessor.processParamTag( paramTag, parameter, paramDocType );
124 }
125 }
126
127 }