本文整理汇总了Java中org.jaudiotagger.audio.generic.Utils.isOddLength方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.isOddLength方法的具体用法?Java Utils.isOddLength怎么用?Java Utils.isOddLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jaudiotagger.audio.generic.Utils
的用法示例。
在下文中一共展示了Utils.isOddLength方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteTagChunk
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* <p>Deletes the given ID3-{@link Tag}/{@link Chunk} from the file by moving all following chunks up.</p>
* <pre>
* [chunk][-id3-][chunk][chunk]
* [chunk] <<--- [chunk][chunk]
* [chunk][chunk][chunk]
* </pre>
*
* @param fc, filechannel
* @param existingTag existing tag
* @param tagChunkHeader existing chunk header for the tag
* @throws IOException if something goes wrong
*/
private void deleteTagChunk(FileChannel fc, final AiffTag existingTag, final ChunkHeader tagChunkHeader, String fileName) throws IOException {
int lengthTagChunk = (int) tagChunkHeader.getSize() + ChunkHeader.CHUNK_HEADER_SIZE;
if (Utils.isOddLength(lengthTagChunk)) {
if (existingTag.getStartLocationInFileOfId3Chunk() + lengthTagChunk < fc.size()) {
lengthTagChunk++;
}
}
final long newLength = fc.size() - lengthTagChunk;
logger.severe(fileName + " Size of id3 chunk to delete is:" + lengthTagChunk + ":Location:" + existingTag.getStartLocationInFileOfId3Chunk());
// position for reading after the id3 tag
fc.position(existingTag.getStartLocationInFileOfId3Chunk() + lengthTagChunk);
deleteTagChunkUsingSmallByteBufferSegments(existingTag, fc, newLength, lengthTagChunk);
// truncate the file after the last chunk
logger.severe(fileName + " Setting new length to:" + newLength);
fc.truncate(newLength);
}
示例2: writeInfoDataToFile
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Write LISTINFOChunk of specified size to current file location
* ensuring it is on even file boundary
*
* @param fc random access file
* @param bb data to write
* @param chunkSize chunk size
* @throws java.io.IOException
*/
private void writeInfoDataToFile(FileChannel fc, final ByteBuffer bb, final long chunkSize) throws IOException {
if (Utils.isOddLength(fc.position())) {
writePaddingToFile(fc, 1);
}
//Write LIST header
final ByteBuffer listHeaderBuffer = ByteBuffer.allocate(ChunkHeader.CHUNK_HEADER_SIZE);
listHeaderBuffer.order(ByteOrder.LITTLE_ENDIAN);
listHeaderBuffer.put(WavChunkType.LIST.getCode().getBytes(StandardCharsets.US_ASCII));
listHeaderBuffer.putInt((int) chunkSize);
listHeaderBuffer.flip();
fc.write(listHeaderBuffer);
//Now write actual data
fc.write(bb);
writeExtraByteIfChunkOddSize(fc, chunkSize);
}
示例3: writeID3DataToFile
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Write Id3Chunk of specified size to current file location
* ensuring it is on even file boundary
*
* @param fc random access file
* @param bb data to write
* @throws java.io.IOException
*/
private void writeID3DataToFile(final FileChannel fc, final ByteBuffer bb) throws IOException {
if (Utils.isOddLength(fc.position())) {
writePaddingToFile(fc, 1);
}
//Write ID3Data header
final ByteBuffer listBuffer = ByteBuffer.allocate(ChunkHeader.CHUNK_HEADER_SIZE);
listBuffer.order(ByteOrder.LITTLE_ENDIAN);
listBuffer.put(WavChunkType.ID3.getCode().getBytes(StandardCharsets.US_ASCII));
listBuffer.putInt(bb.limit());
listBuffer.flip();
fc.write(listBuffer);
//Now write actual data
fc.write(bb);
}
示例4: isAtEndOfFileAllowingForPaddingByte
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* @param existingTag
* @param fc
* @return true if at end of file (also take into account padding byte)
* @throws IOException
*/
private boolean isAtEndOfFileAllowingForPaddingByte(AiffTag existingTag, FileChannel fc) throws IOException {
return (
(
existingTag.getID3Tag().getEndLocationInFile() == fc.size()
)
||
(
Utils.isOddLength(existingTag.getID3Tag().getEndLocationInFile())
&&
existingTag.getID3Tag().getEndLocationInFile() + 1 == fc.size()
)
);
}
示例5: deleteRemainderOfFile
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* If Metadata tags are corrupted and no other tags later in the file then just truncate ID3 tags and start again
*
* @param fc
* @param existingTag
* @throws IOException
*/
private void deleteRemainderOfFile(FileChannel fc, final AiffTag existingTag, String fileName) throws IOException {
ChunkSummary precedingChunk = AiffChunkSummary.getChunkBeforeStartingMetadataTag(existingTag);
if (!Utils.isOddLength(precedingChunk.getEndLocation())) {
logger.severe(fileName + " Truncating corrupted ID3 tags from:" + (existingTag.getStartLocationInFileOfId3Chunk() - 1));
fc.truncate(existingTag.getStartLocationInFileOfId3Chunk() - 1);
} else {
logger.severe(fileName + " Truncating corrupted ID3 tags from:" + (existingTag.getStartLocationInFileOfId3Chunk()));
fc.truncate(existingTag.getStartLocationInFileOfId3Chunk());
}
}
示例6: deleteExistingMetadataTagsToEndOfFile
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* If Info/ID3 Metadata tags are corrupted and only metadata tags later in the file then just truncate metadata tags and start again
*
* @param fc
* @param existingTag
* @throws IOException
*/
private void deleteExistingMetadataTagsToEndOfFile(final FileChannel fc, final WavTag existingTag) throws IOException {
ChunkSummary precedingChunk = WavChunkSummary.getChunkBeforeFirstMetadataTag(existingTag);
//Preceding chunk ends on odd boundary
if (!Utils.isOddLength(precedingChunk.getEndLocation())) {
logger.severe(loggingName + " Truncating corrupted metadata tags from:" + (existingTag.getInfoTag().getStartLocationInFile() - 1));
fc.truncate(existingTag.getInfoTag().getStartLocationInFile() - 1);
}
//Preceding chunk ends on even boundary
else {
logger.severe(loggingName + " Truncating corrupted metadata tags from:" + (existingTag.getInfoTag().getStartLocationInFile()));
fc.truncate(existingTag.getInfoTag().getStartLocationInFile());
}
}
示例7: ensureOnEqualBoundary
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* If Size is not even then we skip a byte, because chunks have to be aligned
*
* @param raf
* @param chunkHeader
* @throws java.io.IOException
*/
public static void ensureOnEqualBoundary(final RandomAccessFile raf,ChunkHeader chunkHeader) throws IOException
{
if (Utils.isOddLength(chunkHeader.getSize()))
{
// Must come out to an even byte boundary unless at end of file
if(raf.getFilePointer()<raf.length())
{
logger.config("Skipping Byte because on odd boundary");
raf.skipBytes(1);
}
}
}
示例8: readChunks
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Read Info chunk
* @param chunkData
*/
public boolean readChunks(ByteBuffer chunkData)
{
while(chunkData.remaining()>= IffHeaderChunk.TYPE_LENGTH)
{
String id = Utils.readFourBytesAsChars(chunkData);
//Padding
if(id.trim().isEmpty())
{
return true;
}
int size = chunkData.getInt();
if(
(!Character.isAlphabetic(id.charAt(0)))||
(!Character.isAlphabetic(id.charAt(1)))||
(!Character.isAlphabetic(id.charAt(2)))||
(!Character.isAlphabetic(id.charAt(3)))
)
{
logger.severe(loggingName + "LISTINFO appears corrupt, ignoring:"+id+":"+size);
return false;
}
String value =null;
try
{
value = Utils.getString(chunkData, 0, size, StandardCharsets.UTF_8);
}
catch(BufferUnderflowException bue)
{
logger.log(Level.SEVERE, loggingName + "LISTINFO appears corrupt, ignoring:"+bue.getMessage(), bue);
return false;
}
logger.config(loggingName + "Result:" + id + ":" + size + ":" + value + ":");
WavInfoIdentifier wii = WavInfoIdentifier.getByCode(id);
if(wii!=null && wii.getFieldKey()!=null)
{
try
{
wavInfoTag.setField(wii.getFieldKey(), value);
}
catch(FieldDataInvalidException fdie)
{
logger.log(Level.SEVERE, loggingName + fdie.getMessage(), fdie);
}
}
//Add unless just padding
else if(id!=null && !id.trim().isEmpty())
{
wavInfoTag.addUnRecognizedField(id, value);
}
//Each tuple aligned on even byte boundary
if (Utils.isOddLength(size) && chunkData.hasRemaining())
{
chunkData.get();
}
}
return true;
}
示例9: writeExtraByteIfChunkOddSize
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Chunk must also start on an even byte so if our chunksize is odd we need
* to write another byte. This should never happen as ID3Tag is now amended
* to ensure always write padding byte if needed to stop it being odd sized
* but we keep check in just incase.
*
* @param fc
* @param size
* @throws IOException
*/
private void writeExtraByteIfChunkOddSize(FileChannel fc, long size)
throws IOException {
if (Utils.isOddLength(size)) {
fc.write(ByteBuffer.allocateDirect(1));
}
}
示例10: writeExtraByteIfChunkOddSize
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Chunk must also start on an even byte so if our chinksize is odd we need
* to write another byte
*
* @param fc
* @param size
* @throws IOException
*/
private void writeExtraByteIfChunkOddSize(FileChannel fc, long size)
throws IOException {
if (Utils.isOddLength(size)) {
writePaddingToFile(fc, 1);
}
}