View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.routeheader;
18  
19  import org.kuali.rice.core.util.xml.XmlException;
20  import org.kuali.rice.kew.rule.WorkflowAttribute;
21  import org.kuali.rice.kew.rule.web.RoutingReportAction;
22  import org.kuali.rice.kew.util.KEWConstants;
23  
24  import java.util.Iterator;
25  import java.util.List;
26  
27  
28  /**
29   * {@link DocumentContent} which is generated from a List of attributes.
30   * Used by the {@link RoutingReportAction} to aid in generation of 
31   * document content when running routing reports.
32   * 
33   * @see WorkflowAttribute
34   * @see RoutingReportAction
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public class AttributeDocumentContent extends StandardDocumentContent {
39      
40  	private static final long serialVersionUID = 6789132279492877000L;
41  
42  	public AttributeDocumentContent(List attributes) throws XmlException {
43          super(generateDocContent(attributes));
44      }
45      
46      private static String generateDocContent(List attributes) {
47          StringBuffer buffer = new StringBuffer();
48          buffer.append("<").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
49          buffer.append("<").append(KEWConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
50          for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
51              WorkflowAttribute attribute = (WorkflowAttribute) iterator.next();
52              buffer.append(attribute.getDocContent());
53          }
54          buffer.append("</").append(KEWConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
55          buffer.append("</").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
56          return buffer.toString();
57      }
58  
59  }