EMMA Coverage Report (generated Tue Mar 14 21:50:42 EST 2006)
[all classes][org.farng.mp3.filename]

COVERAGE SUMMARY FOR SOURCE FILE [FilenameDelimiter.java]

nameclass, %method, %block, %line, %
FilenameDelimiter.java100% (1/1)79%  (11/14)78%  (147/188)81%  (43.9/54)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FilenameDelimiter100% (1/1)79%  (11/14)78%  (147/188)81%  (43.9/54)
FilenameDelimiter (FilenameDelimiter): void 0%   (0/1)0%   (0/29)0%   (0/8)
getDelimiter (): String 0%   (0/1)0%   (0/3)0%   (0/1)
iterator (): Iterator 0%   (0/1)0%   (0/5)0%   (0/1)
createId3Tag (): ID3v2_4 100% (1/1)85%  (22/26)88%  (7/8)
FilenameDelimiter (): void 100% (1/1)100% (12/12)100% (5/5)
composeFilename (): String 100% (1/1)100% (35/35)100% (8/8)
getAfterComposite (): AbstractFilenameComposite 100% (1/1)100% (3/3)100% (1/1)
getBeforeComposite (): AbstractFilenameComposite 100% (1/1)100% (3/3)100% (1/1)
matchAgainstKeyword (Class): void 100% (1/1)100% (26/26)100% (6/6)
matchAgainstTag (AbstractMP3Tag): void 100% (1/1)100% (17/17)100% (6/6)
setAfterComposite (AbstractFilenameComposite): void 100% (1/1)100% (4/4)100% (2/2)
setBeforeComposite (AbstractFilenameComposite): void 100% (1/1)100% (4/4)100% (2/2)
setDelimiter (String): void 100% (1/1)100% (4/4)100% (2/2)
setFrame (AbstractID3v2Frame): void 100% (1/1)100% (17/17)100% (6/6)

1package org.farng.mp3.filename;
2 
3import org.farng.mp3.AbstractMP3Tag;
4import org.farng.mp3.TagUtility;
5import org.farng.mp3.id3.AbstractID3v2Frame;
6import org.farng.mp3.id3.AbstractID3v2FrameBody;
7import org.farng.mp3.id3.ID3v2_4;
8 
9import java.util.Iterator;
10 
11/**
12 * This class is a composite subclass which represents a delimiter within a filename. Delimiters are usually punctuation
13 * such as " - "
14 *
15 * @author Eric Farng
16 * @version $Revision: 1.5 $
17 */
18public class FilenameDelimiter extends AbstractFilenameComposite {
19 
20    /**
21     * The composite that comes before the delimiter
22     */
23    private AbstractFilenameComposite afterComposite = null;
24    /**
25     * The composite that comes after the delimiter
26     */
27    private AbstractFilenameComposite beforeComposite = null;
28    /**
29     * The delimiter that was used to split the token
30     */
31    private String delimiter = null;
32 
33    /**
34     * Creates a new FilenameDelimiter object.
35     */
36    public FilenameDelimiter() {
37        super();
38    }
39 
40    /**
41     * Creates a new FilenameDelimiter object.
42     */
43    public FilenameDelimiter(final FilenameDelimiter copyObject) {
44        super(copyObject);
45        delimiter = copyObject.delimiter;
46        afterComposite = (AbstractFilenameComposite) TagUtility.copyObject(copyObject.afterComposite);
47        beforeComposite = (AbstractFilenameComposite) TagUtility.copyObject(copyObject.beforeComposite);
48    }
49 
50    /**
51     * Sets the composite that comes after the delimiter.
52     *
53     * @param afterComposite The composite that comes after the delimiter.
54     */
55    public void setAfterComposite(final AbstractFilenameComposite afterComposite) {
56        this.afterComposite = afterComposite;
57    }
58 
59    /**
60     * Returns the composite that comes after the delimiter.
61     *
62     * @return the composite that comes after the delimiter.
63     */
64    public AbstractFilenameComposite getAfterComposite() {
65        return afterComposite;
66    }
67 
68    /**
69     * Sets the composite that comes before the delimiter
70     *
71     * @param beforeComposite the composite that comes before the delimiter
72     */
73    public void setBeforeComposite(final AbstractFilenameComposite beforeComposite) {
74        this.beforeComposite = beforeComposite;
75    }
76 
77    /**
78     * Returns the composite that comes before the delimiter
79     *
80     * @return the composite that comes before the delimiter
81     */
82    public AbstractFilenameComposite getBeforeComposite() {
83        return beforeComposite;
84    }
85 
86    /**
87     * Sets the delimiter that splits the two halves of this composite
88     *
89     * @param delimiter delimiter that splits the two halves of this composite
90     */
91    public void setDelimiter(final String delimiter) {
92        this.delimiter = delimiter;
93    }
94 
95    /**
96     * Returns the delimiter that splits the two halfs of this composite
97     *
98     * @return the delimiter that splits the two halfs of this composite
99     */
100    public String getDelimiter() {
101        return delimiter;
102    }
103 
104    public void setFrame(final AbstractID3v2Frame frame) {
105        if (frame != null) {
106            if (beforeComposite != null) {
107                beforeComposite.setFrame(frame);
108            }
109            if (afterComposite != null) {
110                afterComposite.setFrame(frame);
111            }
112        }
113    }
114 
115    /**
116     * Create the filename that this composite represents
117     *
118     * @return the filename that this composite represents
119     */
120    public String composeFilename() {
121        final StringBuffer stringBuffer = new StringBuffer(128);
122        if (beforeComposite != null) {
123            stringBuffer.append(beforeComposite.composeFilename());
124        }
125        stringBuffer.append(delimiter);
126        stringBuffer.append(' ');
127        if (afterComposite != null) {
128            stringBuffer.append(afterComposite.composeFilename());
129        }
130        return stringBuffer.toString();
131    }
132 
133    public ID3v2_4 createId3Tag() {
134        ID3v2_4 newTag = null;
135        if (beforeComposite != null) {
136            newTag = beforeComposite.createId3Tag();
137        }
138        if (afterComposite != null) {
139            if (newTag != null) {
140                newTag.append(afterComposite.createId3Tag());
141            } else {
142                newTag = afterComposite.createId3Tag();
143            }
144        }
145        return newTag;
146    }
147 
148    /**
149     * Returns an iterator through each <code>FilenameToken</code> in this composite in the correct order for the file
150     * name.
151     *
152     * @return an iterator through each <code>FilenameToken</code> in this composite
153     */
154    public Iterator iterator() {
155        return new FilenameDelimiterIterator(this);
156    }
157 
158    /**
159     * Match all elements of this composite against the keywords for this class type found in
160     * <code>TagOptionSingleton</code>. If the <code>FilenameToken</code> matches the keyword, the token's class is
161     * set.
162     *
163     * @param id3v2FrameBodyClass Class of keywords to match against.
164     */
165    public void matchAgainstKeyword(final Class id3v2FrameBodyClass) {
166        if (AbstractID3v2FrameBody.class.isAssignableFrom(id3v2FrameBodyClass)) {
167            if (beforeComposite != null) {
168                beforeComposite.matchAgainstKeyword(id3v2FrameBodyClass);
169            }
170            if (afterComposite != null) {
171                afterComposite.matchAgainstKeyword(id3v2FrameBodyClass);
172            }
173        }
174    }
175 
176    /**
177     * Match all elements of this composite against the given tag. If any element of <code>matchTag</code> matches any
178     * element of this tag's composite, then this tag's composite leaf node's class is set.
179     *
180     * @param matchTag Tag to match against
181     */
182    public void matchAgainstTag(final AbstractMP3Tag matchTag) {
183        if (matchTag != null) {
184            if (beforeComposite != null) {
185                beforeComposite.matchAgainstTag(matchTag);
186            }
187            if (afterComposite != null) {
188                afterComposite.matchAgainstTag(matchTag);
189            }
190        }
191    }
192}

[all classes][org.farng.mp3.filename]
EMMA 2.0.5312 (C) Vladimir Roubtsov