001    /**
002     * Copyright 2004-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    /*
017     * To change this template, choose Tools | Templates
018     * and open the template in the editor.
019     */
020    package org.kuali.student.contract.model.util;
021    
022    import java.io.PrintStream;
023    
024    import org.kuali.student.contract.model.MessageStructure;
025    
026    /**
027     *
028     * @author nwright
029     */
030    public class MessageStructureDumper {
031    
032        private MessageStructure messageStructure;
033        private PrintStream out;
034    
035        public MessageStructureDumper(MessageStructure messageStructure,
036                PrintStream out) {
037            this.messageStructure = messageStructure;
038            this.out = out;
039        }
040    
041        public void dump() {
042            out.println(
043                    messageStructure.getXmlObject() + "." + messageStructure.getShortName()
044                    + " - " + messageStructure.getName() + " - " + messageStructure.getType()
045                    + " http:XXX" + messageStructure.getUrl() + " - " + messageStructure.getDescription());
046        }
047    
048        public void writeTabbedHeader() {
049            out.print("id");
050            out.print("\t");
051            out.print("Action");
052            out.print("\t");
053            out.print("xmlObject");
054            out.print("\t");
055            out.print("ShortName");
056            out.print("\t");
057            out.print("Name");
058            out.print("\t");
059            out.print("Type");
060            out.print("\t");
061            out.print("Description");
062            out.print("\t");
063            out.print("Required");
064            out.print("\t");
065            out.print("Cardinality");
066            out.print("\t");
067            out.print("XMLAttribute");
068            out.print("\t");
069            out.print("Status");
070            out.print("\t");
071            out.print("Feedback");
072            out.println("");
073        }
074    
075        private String clean(String str) {
076            str = str.replace("\n", " ");
077            str = str.replace("\t", " ");
078            str = str.replace("\r", str);
079            str = str.replace("\f", " ");
080            return str;
081        }
082    
083        public void writeTabbedData() {
084            out.print(messageStructure.getId());
085            out.print("\t");
086            out.print("");
087            out.print("\t");
088            out.print(messageStructure.getXmlObject());
089            out.print("\t");
090            out.print(messageStructure.getShortName());
091            out.print("\t");
092            out.print(messageStructure.getName());
093            out.print("\t");
094            out.print(messageStructure.getType());
095            out.print("\t");
096            out.print(clean(messageStructure.getDescription()));
097            out.print("\t");
098            out.print(messageStructure.getRequired());
099            out.print("\t");
100            out.print(messageStructure.getCardinality());
101            out.print("\t");
102            out.print(messageStructure.getXmlAttribute());
103            out.print("\t");
104            out.print(messageStructure.getStatus());
105            out.print("\t");
106            out.print(messageStructure.getImplNotes());
107            out.println("");
108        }
109    }