当前位置: 首页>>代码示例>>Java>>正文


Java TagOptionSingleton类代码示例

本文整理汇总了Java中org.farng.mp3.TagOptionSingleton的典型用法代码示例。如果您正苦于以下问题:Java TagOptionSingleton类的具体用法?Java TagOptionSingleton怎么用?Java TagOptionSingleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TagOptionSingleton类属于org.farng.mp3包,在下文中一共展示了TagOptionSingleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchAgainstKeyword

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Match all elements of this composite against the keywords for this class type found in
 * <code>TagOptionSingleton</code>. If the <code>FilenameToken</code> matches the keyword, the token's class is
 * set.
 *
 * @param matchId3v2FrameBodyClass Class of keywords to match against.
 */
public void matchAgainstKeyword(final Class matchId3v2FrameBodyClass) {
    if (AbstractID3v2FrameBody.class.isAssignableFrom(matchId3v2FrameBodyClass)) {
        if (TagOptionSingleton.getInstance().isCompositeMatchOverwrite() || id3v2FrameBodyClass == null) {
            final Iterator iterator = TagOptionSingleton.getInstance()
                    .getKeywordListIterator(matchId3v2FrameBodyClass);
            final String lowerCaseToken = token.toLowerCase();
            while (iterator.hasNext()) {
                final String matchString = ((String) iterator.next()).toLowerCase();
                if (matchString.equals(lowerCaseToken) ||
                    matchString.indexOf(lowerCaseToken) >= 0 ||
                    lowerCaseToken.indexOf(matchString) >= 0) {
                    setId3v2FrameBodyClass(matchId3v2FrameBodyClass);
                    break;
                }
            }
        }
    }
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:26,代码来源:FilenameToken.java

示例2: parseDelimiter

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Parses the given token into two halves with the delimiters found in <code> TagOptionSingleton</code>
 *
 * @param token token to split
 *
 * @return index 0 is the delimiter. index 1 and 2 are the before and after tokens respectively.
 */
private static String[] parseDelimiter(final String token) {
    String[] tokenArray = null;
    if (token != null && token.length() > 0) {
        final Iterator iterator = TagOptionSingleton.getInstance().getFilenameDelimiterIterator();
        int index;
        String delimiter;
        while (iterator.hasNext()) {
            delimiter = (String) iterator.next();
            index = token.indexOf(delimiter);
            if (index >= 0) {
                tokenArray = new String[3];
                tokenArray[0] = delimiter;
                tokenArray[1] = token.substring(0, index);
                tokenArray[2] = token.substring(index + delimiter.length());
            }
        }
    }
    return tokenArray;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:27,代码来源:FilenameTagBuilder.java

示例3: parseEndWordDelimiter

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Parses the given token into two halves with the delimiters found in <code> TagOptionSingleton</code>
 *
 * @param token token to split
 *
 * @return index 0 is the delimiter. index 1 and 2 are the before and after tokens respectively.
 */
private static String[] parseEndWordDelimiter(final String token) {
    String[] tokenArray = null;
    if (token != null && token.length() > 0) {
        final Iterator iterator = TagOptionSingleton.getInstance().getEndWordDelimiterIterator();
        int index;
        String delimiter;
        while (iterator.hasNext()) {
            delimiter = (String) iterator.next();
            if (token.endsWith(delimiter)) {
                index = token.substring(0, token.length() - delimiter.length()).indexOf(delimiter);
            } else {
                index = token.indexOf(delimiter);
            }
            if (index > 0) {
                tokenArray = new String[3];
                tokenArray[0] = delimiter;
                tokenArray[1] = token.substring(0, index);
                tokenArray[2] = token.substring(index);
            }
        }
    }
    return tokenArray;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:31,代码来源:FilenameTagBuilder.java

示例4: parseStartWordDelimiter

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Parses the given token into two halves with the delimiters found in <code> TagOptionSingleton</code>
 *
 * @param token token to split
 *
 * @return index 0 is the delimiter. index 1 and 2 are the before and after tokens respectively.
 */
private static String[] parseStartWordDelimiter(final String token) {
    String[] tokenArray = null;
    if (token != null && token.length() > 0) {
        final Iterator iterator = TagOptionSingleton.getInstance().getStartWordDelimiterIterator();
        int index;
        String delimiter;
        while (iterator.hasNext()) {
            delimiter = (String) iterator.next();
            if (token.startsWith(delimiter)) {
                index = token.indexOf(delimiter, delimiter.length());
            } else {
                index = token.indexOf(delimiter);
            }
            if (index > 0) {
                tokenArray = new String[3];
                tokenArray[0] = delimiter;
                tokenArray[1] = token.substring(0, index);
                tokenArray[2] = token.substring(index);
            }
        }
    }
    return tokenArray;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:31,代码来源:FilenameTagBuilder.java

示例5: composeFilename

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Reconstruct the filename that is represented by this composite.
 *
 * @return the filename that is represented by this composite.
 */
public String composeFilename() {
    final StringBuffer stringBuffer = new StringBuffer(128);
    if (getBeforeComposite() != null) {
        stringBuffer.append(getBeforeComposite().composeFilename());
    }
    stringBuffer.append(' ');
    stringBuffer.append(openDelimiter);
    if (middleComposite != null) {
        stringBuffer.append(middleComposite.composeFilename());
    }
    stringBuffer.append(TagOptionSingleton.getInstance().getCloseParenthesis(openDelimiter));
    stringBuffer.append(' ');
    if (getAfterComposite() != null) {
        stringBuffer.append(getAfterComposite().composeFilename());
    }
    return stringBuffer.toString().trim();
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:23,代码来源:FilenameParenthesis.java

示例6: read

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void read(final RandomAccessFile file) throws InvalidTagException, java.io.IOException {
    final String lineString;
    byte[] buffer = new byte[5];

    // read the 5 character size
    file.read(buffer, 0, 5);
    final int size = Integer.parseInt(new String(buffer, 0, 5));
    if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
        throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
    }
    buffer = new byte[size];

    // read the SIZE length description
    file.read(buffer);
    lineString = new String(buffer);
    readString(lineString);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:18,代码来源:FieldBodyLYR.java

示例7: read

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void read(final RandomAccessFile file) throws InvalidTagException, java.io.IOException {
    final String imageString;
    byte[] buffer = new byte[5];

    // read the 5 character size
    file.read(buffer, 0, 5);
    final int size = Integer.parseInt(new String(buffer, 0, 5));
    if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
        throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
    }
    buffer = new byte[size];

    // read the SIZE length description
    file.read(buffer);
    imageString = new String(buffer);
    readString(imageString);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:18,代码来源:FieldBodyIMG.java

示例8: append

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void append(final AbstractMP3Tag tag) {
    final ID3v1_1 oldTag = this;
    final ID3v1_1 newTag;
    if (tag != null) {
        if (tag instanceof ID3v1_1) {
            newTag = (ID3v1_1) tag;
        } else {
            newTag = new ID3v1_1(tag);
        }
        if (tag instanceof org.farng.mp3.lyrics3.AbstractLyrics3) {
            TagOptionSingleton.getInstance().setId3v1SaveTrack(false);
        }
        oldTag.track = (TagOptionSingleton.getInstance().isId3v1SaveTrack() && (oldTag.track <= 0)) ?
                       newTag.track :
                       oldTag.track;

        // we don't need to reset the tag options because
        // we want to save all fields (default)
    }

    // we can't send newTag here because we need to keep the lyrics3
    // class type ... check super.append and you'll see what i mean.
    super.append(tag);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:25,代码来源:ID3v1_1.java

示例9: overwrite

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void overwrite(final AbstractMP3Tag tag) {
    final ID3v1_1 oldTag = this;
    ID3v1_1 newTag = null;
    if (tag != null) {
        if (tag instanceof ID3v1_1) {
            newTag = (ID3v1_1) tag;
        } else {
            newTag = new ID3v1_1(tag);
        }
        if (tag instanceof org.farng.mp3.lyrics3.AbstractLyrics3) {
            TagOptionSingleton.getInstance().setId3v1SaveTrack(false);
        }
        oldTag.track = TagOptionSingleton.getInstance().isId3v1SaveTrack() ? newTag.track : oldTag.track;

        // we don't need to reset the tag options because
        // we want to save all fields (default)
    }
    super.overwrite(newTag);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:20,代码来源:ID3v1_1.java

示例10: overwrite

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void overwrite(final AbstractMP3Tag tag) {
    final ID3v1 oldTag = this;
    final ID3v1 newTag;
    if (tag != null) {
        if (tag instanceof ID3v1) {
            newTag = (ID3v1) tag;
        } else {
            newTag = new ID3v1();
        }
        if (tag instanceof org.farng.mp3.lyrics3.AbstractLyrics3) {
            TagOptionSingleton.getInstance().setId3v1SaveYear(false);
            TagOptionSingleton.getInstance().setId3v1SaveComment(false);
        }
        oldTag.title = TagOptionSingleton.getInstance().isId3v1SaveTitle() ? newTag.title : oldTag.artist;
        oldTag.artist = TagOptionSingleton.getInstance().isId3v1SaveArtist() ? newTag.artist : oldTag.artist;
        oldTag.album = TagOptionSingleton.getInstance().isId3v1SaveAlbum() ? newTag.album : oldTag.album;
        oldTag.year = TagOptionSingleton.getInstance().isId3v1SaveYear() ? newTag.year : oldTag.year;
        oldTag.comment = TagOptionSingleton.getInstance().isId3v1SaveComment() ? newTag.comment : oldTag.comment;
        oldTag.genre = TagOptionSingleton.getInstance().isId3v1SaveGenre() ? newTag.genre : oldTag.genre;

        // we don't need to reset the tag options because
        // we want to save all fields (default)
    }
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:25,代码来源:ID3v1.java

示例11: updateCompositeFromAllOption

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Traverse the composite and set the class field to match keywords found in TagOptionSingleton.
 *
 * @param composite composite to update.
 */
public static void updateCompositeFromAllOption(final AbstractFilenameComposite composite) {
    final Iterator iterator = TagOptionSingleton.getInstance().getKeywordIterator();
    while (iterator.hasNext()) {
        composite.matchAgainstKeyword((Class) iterator.next());
    }
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:12,代码来源:FilenameTagBuilder.java

示例12: parseParenthesis

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
/**
 * Given a specific token, parse it into halves according to the <code>TagOptionSingleton</code>
 *
 * @param token token to split.
 *
 * @return index 0 and 1 are the parenthesis delimiters. index 2, 3, 4 are before, middle, and after respectively.
 */
private static String[] parseParenthesis(final String token) throws TagException {
    String[] tokenArray = null;
    if (token != null && token.length() > 0) {
        final TagOptionSingleton option = TagOptionSingleton.getInstance();
        String tempOpen;
        String open = "";
        final String close;
        int openIndex = token.length();
        int tempIndex;
        final int closeIndex;
        final Iterator iterator = option.getOpenParenthesisIterator();

        // find first parenthesis
        while (iterator.hasNext()) {
            tempOpen = (String) iterator.next();
            tempIndex = token.indexOf(tempOpen);
            if (tempIndex >= 0 && tempIndex < openIndex) {
                openIndex = tempIndex;
                open = tempOpen;
            }
        }

        // we have a parenthesis
        if (openIndex >= 0 && openIndex < token.length()) {
            close = option.getCloseParenthesis(open);
            closeIndex = TagUtility.findMatchingParenthesis(token, openIndex);
            if (closeIndex < 0) {
                throw new TagException("Unmatched parenthesis in \"" + token + "\" at position : " + openIndex);
            }
            tokenArray = new String[5];
            tokenArray[0] = open;
            tokenArray[1] = close;
            tokenArray[2] = token.substring(0, openIndex);
            tokenArray[3] = token.substring(openIndex + open.length(), closeIndex);
            tokenArray[4] = token.substring(closeIndex + close.length());
        }
    }
    return tokenArray;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:47,代码来源:FilenameTagBuilder.java

示例13: readHeader

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
protected int readHeader(final RandomAccessFile file) throws InvalidTagException, IOException {
    final int size;
    final byte[] buffer = new byte[5];

    // read the 5 character size
    file.read(buffer, 0, 5);
    size = Integer.parseInt(new String(buffer, 0, 5));
    if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
        throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
    }
    return size;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:13,代码来源:AbstractLyrics3v2FieldBody.java

示例14: append

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void append(final AbstractMP3Tag tag) {
    final Lyrics3v2 oldTag = this;
    final Lyrics3v2 newTag;
    if (tag != null) {
        if (tag instanceof Lyrics3v2) {
            newTag = (Lyrics3v2) tag;
        } else {
            newTag = new Lyrics3v2(tag);
        }
        Iterator iterator = newTag.fieldMap.values().iterator();
        Lyrics3v2Field field;
        AbstractLyrics3v2FieldBody body;
        while (iterator.hasNext()) {
            field = (Lyrics3v2Field) iterator.next();
            if (oldTag.hasField(field.getIdentifier()) == false) {
                oldTag.setField(field);
            } else {
                body = (AbstractLyrics3v2FieldBody) oldTag.getField(field.getIdentifier()).getBody();
                final boolean save = TagOptionSingleton.getInstance().getLyrics3SaveField(field.getIdentifier());
                if ((body.getSize() == 0) && save) {
                    oldTag.setField(field);
                }
            }
        }

        // reset tag options to save all current fields.
        iterator = oldTag.fieldMap.keySet().iterator();
        String id;
        while (iterator.hasNext()) {
            id = (String) iterator.next();
            TagOptionSingleton.getInstance().setLyrics3SaveField(id, true);
        }
    }
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:35,代码来源:Lyrics3v2.java

示例15: overwrite

import org.farng.mp3.TagOptionSingleton; //导入依赖的package包/类
public void overwrite(final AbstractMP3Tag tag) {
    final Lyrics3v2 oldTag = this;
    final Lyrics3v2 newTag;
    if (tag != null) {
        if (tag instanceof Lyrics3v2) {
            newTag = (Lyrics3v2) tag;
        } else {
            newTag = new Lyrics3v2(tag);
        }
        Iterator iterator = newTag.fieldMap.values().iterator();
        Lyrics3v2Field field;
        while (iterator.hasNext()) {
            field = (Lyrics3v2Field) iterator.next();
            if (TagOptionSingleton.getInstance().getLyrics3SaveField(field.getIdentifier())) {
                oldTag.setField(field);
            }
        }

        // reset tag options to save all current fields.
        iterator = oldTag.fieldMap.keySet().iterator();
        String id;
        while (iterator.hasNext()) {
            id = (String) iterator.next();
            TagOptionSingleton.getInstance().setLyrics3SaveField(id, true);
        }
    }
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:28,代码来源:Lyrics3v2.java


注:本文中的org.farng.mp3.TagOptionSingleton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。