001 /* 002 * Copyright 2005-2008 The Kuali Foundation 003 * 004 * 005 * Licensed under the Educational Community License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.opensource.org/licenses/ecl2.php 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.kuali.rice.kew.routeheader; 018 019 import org.kuali.rice.core.util.xml.XmlException; 020 import org.kuali.rice.kew.rule.WorkflowAttribute; 021 import org.kuali.rice.kew.rule.web.RoutingReportAction; 022 import org.kuali.rice.kew.util.KEWConstants; 023 024 import java.util.Iterator; 025 import java.util.List; 026 027 028 /** 029 * {@link DocumentContent} which is generated from a List of attributes. 030 * Used by the {@link RoutingReportAction} to aid in generation of 031 * document content when running routing reports. 032 * 033 * @see WorkflowAttribute 034 * @see RoutingReportAction 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038 public class AttributeDocumentContent extends StandardDocumentContent { 039 040 private static final long serialVersionUID = 6789132279492877000L; 041 042 public AttributeDocumentContent(List attributes) throws XmlException { 043 super(generateDocContent(attributes)); 044 } 045 046 private static String generateDocContent(List attributes) { 047 StringBuffer buffer = new StringBuffer(); 048 buffer.append("<").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">"); 049 buffer.append("<").append(KEWConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">"); 050 for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { 051 WorkflowAttribute attribute = (WorkflowAttribute) iterator.next(); 052 buffer.append(attribute.getDocContent()); 053 } 054 buffer.append("</").append(KEWConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">"); 055 buffer.append("</").append(KEWConstants.DOCUMENT_CONTENT_ELEMENT).append(">"); 056 return buffer.toString(); 057 } 058 059 }