Coverage Report - org.jaudiotagger.audio.asf.tag.AsfTagField
 
Classes in this File Line Coverage Branch Coverage Complexity
AsfTagField
50%
9/18
0%
0/6
1.273
 
 1  
 /*
 2  
  * Entagged Audio Tag library
 3  
  * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
 4  
  * 
 5  
  * This library is free software; you can redistribute it and/or
 6  
  * modify it under the terms of the GNU Lesser General Public
 7  
  * License as published by the Free Software Foundation; either
 8  
  * version 2.1 of the License, or (at your option) any later version.
 9  
  *  
 10  
  * This library is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  * Lesser General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU Lesser General Public
 16  
  * License along with this library; if not, write to the Free Software
 17  
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.jaudiotagger.audio.asf.tag;
 20  
 
 21  
 import org.jaudiotagger.audio.asf.data.ContentDescriptor;
 22  
 import org.jaudiotagger.tag.TagField;
 23  
 
 24  
 import java.io.UnsupportedEncodingException;
 25  
 
 26  
 /**
 27  
  * This class encapsulates a
 28  
  * {@link org.jaudiotagger.audio.asf.data.ContentDescriptor}and provides access
 29  
  * to it. <br>
 30  
  * The content descriptor used for construction is copied.
 31  
  *
 32  
  * @author Christian Laireiter (liree)
 33  
  */
 34  
 public class AsfTagField implements TagField
 35  
 {
 36  
 
 37  
     /**
 38  
      * This descriptor is wrapped.
 39  
      */
 40  
     protected ContentDescriptor toWrap;
 41  
 
 42  
     /**
 43  
      * Creates an instance.
 44  
      *
 45  
      * @param source The descriptor which should be represented as a
 46  
      *               {@link TagField}.
 47  
      */
 48  
     public AsfTagField(ContentDescriptor source)
 49  2620
     {
 50  2620
         this.toWrap = source.createCopy();
 51  2620
     }
 52  
 
 53  
     /**
 54  
      * Creates a tag field.
 55  
      * @param fieldKey The field identifier to use. 
 56  
      */
 57  
     public AsfTagField(String fieldKey)
 58  0
     {
 59  0
         this.toWrap = new ContentDescriptor(fieldKey, ContentDescriptor.TYPE_STRING);
 60  0
     }
 61  
 
 62  
     /**
 63  
      * {@inheritDoc}
 64  
      */
 65  
     public void copyContent(TagField field)
 66  
     {
 67  0
         throw new UnsupportedOperationException("Not implemented yet.");
 68  
     }
 69  
 
 70  
     /**
 71  
      * Returns the wrapped content descriptor (which actually stores the values).
 72  
      * @return the wrapped content descriptor 
 73  
      */
 74  
     public ContentDescriptor getDescriptor()
 75  
     {
 76  5127
         return this.toWrap;
 77  
     }
 78  
 
 79  
     /**
 80  
      * {@inheritDoc}
 81  
      */
 82  
     public String getId()
 83  
     {
 84  6637
         return toWrap.getName();
 85  
     }
 86  
 
 87  
     /**
 88  
      * {@inheritDoc}
 89  
      */
 90  
     public byte[] getRawContent()
 91  
     {
 92  1840
         return toWrap.getRawData();
 93  
     }
 94  
 
 95  
     /**
 96  
      * {@inheritDoc}
 97  
      */
 98  
     public boolean isBinary()
 99  
     {
 100  0
         return toWrap.getType() == ContentDescriptor.TYPE_BINARY;
 101  
     }
 102  
 
 103  
     /**
 104  
      * {@inheritDoc}
 105  
      */
 106  
     public void isBinary(boolean b)
 107  
     {
 108  0
         if (!b && isBinary())
 109  
         {
 110  0
             throw new UnsupportedOperationException("No conversion supported.");
 111  
         }
 112  0
         toWrap.setBinaryValue(toWrap.getRawData());
 113  0
     }
 114  
 
 115  
     /**
 116  
      * {@inheritDoc}
 117  
      */
 118  
     public boolean isCommon()
 119  
     {
 120  
         // HashSet is safe against null comparison 
 121  1350
         return AsfTag.COMMON_FIELDS.contains(AsfFieldKey.getAsfFieldKey(getId()));
 122  
     }
 123  
 
 124  
     /**
 125  
      * {@inheritDoc}
 126  
      */
 127  
     public boolean isEmpty()
 128  
     {
 129  18
         return toWrap.isEmpty();
 130  
     }
 131  
 
 132  
     /**
 133  
      * {@inheritDoc}
 134  
      */
 135  
     public String toString()
 136  
     {
 137  338
         return toWrap.getString();
 138  
     }
 139  
 
 140  
 }