Coverage Report - org.jaudiotagger.logging.PlainTextTagDisplayFormatter
 
Classes in this File Line Coverage Branch Coverage Complexity
PlainTextTagDisplayFormatter
0%
0/29
0%
0/2
1.083
 
 1  
 /**
 2  
  *  @author : Paul Taylor
 3  
  *
 4  
  *  Version @version:$Id: PlainTextTagDisplayFormatter.java 792 2009-05-05 15:59:19Z paultaylor $
 5  
  *
 6  
  *  MusicTag Copyright (C)2003,2004
 7  
  *
 8  
  *  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
 9  
  *  General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
 10  
  *  or (at your option) any later version.
 11  
  *
 12  
  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 13  
  *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 14  
  *  See the GNU Lesser General Public License for more details.
 15  
  *
 16  
  *  You should have received a copy of the GNU Lesser General Public License along with this library; if not,
 17  
  *  you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
 18  
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 19  
  */
 20  
 package org.jaudiotagger.logging;
 21  
 
 22  
 
 23  
 /*
 24  
  * For Formatting metadata contents of a file as simple text
 25  
 */
 26  
 public class PlainTextTagDisplayFormatter extends AbstractTagDisplayFormatter
 27  
 {
 28  
     private static PlainTextTagDisplayFormatter formatter;
 29  
 
 30  0
     StringBuffer sb = new StringBuffer();
 31  0
     StringBuffer indent = new StringBuffer();
 32  
 
 33  
     public PlainTextTagDisplayFormatter()
 34  0
     {
 35  
 
 36  0
     }
 37  
 
 38  
     public void openHeadingElement(String type, String value)
 39  
     {
 40  0
         addElement(type, value);
 41  0
         increaseLevel();
 42  0
     }
 43  
 
 44  
     public void openHeadingElement(String type, boolean value)
 45  
     {
 46  0
         openHeadingElement(type, String.valueOf(value));
 47  0
     }
 48  
 
 49  
     public void openHeadingElement(String type, int value)
 50  
     {
 51  0
         openHeadingElement(type, String.valueOf(value));
 52  0
     }
 53  
 
 54  
     public void closeHeadingElement(String type)
 55  
     {
 56  0
         decreaseLevel();
 57  0
     }
 58  
 
 59  
     public void increaseLevel()
 60  
     {
 61  0
         level++;
 62  0
         indent.append("  ");
 63  0
     }
 64  
 
 65  
     public void decreaseLevel()
 66  
     {
 67  0
         level--;
 68  0
         indent = new StringBuffer(indent.substring(0, indent.length() - 2));
 69  0
     }
 70  
 
 71  
     public void addElement(String type, String value)
 72  
     {
 73  0
         sb.append(indent).append(type).append(":").append(value).append('\n');
 74  0
     }
 75  
 
 76  
     public void addElement(String type, int value)
 77  
     {
 78  0
         addElement(type, String.valueOf(value));
 79  0
     }
 80  
 
 81  
     public void addElement(String type, boolean value)
 82  
     {
 83  0
         addElement(type, String.valueOf(value));
 84  0
     }
 85  
 
 86  
     public String toString()
 87  
     {
 88  0
         return sb.toString();
 89  
     }
 90  
 
 91  
     public static AbstractTagDisplayFormatter getInstanceOf()
 92  
     {
 93  0
         if (formatter == null)
 94  
         {
 95  0
             formatter = new PlainTextTagDisplayFormatter();
 96  
         }
 97  0
         return formatter;
 98  
     }
 99  
 }