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


Java Utils类代码示例

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


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

示例1: getRawContentDataOnly

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * Get raw content for the data component only
 *
 * @return
 * @throws UnsupportedEncodingException
 */
public byte[] getRawContentDataOnly() throws UnsupportedEncodingException
{
    logger.fine("Getting Raw data for:" + getId());
    try
    {
        //Create Data Box
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] data = getDataBytes();
        baos.write(Utils.getSizeBEInt32(Mp4DataBox.DATA_HEADER_LENGTH + data.length));
        baos.write(Mp4DataBox.IDENTIFIER.getBytes(StandardCharsets.ISO_8859_1));
        baos.write(new byte[]{0});
        baos.write(new byte[]{0, 0, (byte) getFieldType().getFileClassId()});
        baos.write(new byte[]{0, 0, 0, 0});
        baos.write(data);
        return baos.toByteArray();
    }
    catch (IOException ioe)
    {
        //This should never happen as were not actually writing to/from a file
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:29,代码来源:Mp4TagField.java

示例2: getRawContentDataOnly

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
@Override
public byte[] getRawContentDataOnly() throws UnsupportedEncodingException
{
    logger.fine("Getting Raw data for:" + getId());
    try
    {
        //Create DataBox data
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] dataRawData = content.getBytes(getEncoding());
        baos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + Mp4DataBox.PRE_DATA_LENGTH + dataRawData.length));
        baos.write(Mp4DataBox.IDENTIFIER.getBytes(StandardCharsets.ISO_8859_1));
        baos.write(new byte[]{0});
        baos.write(new byte[]{0, 0, (byte) getFieldType().getFileClassId()});
        baos.write(new byte[]{0, 0, 0, 0});
        baos.write(dataRawData);
        return baos.toByteArray();
    }
    catch (IOException ioe)
    {
        //This should never happen as were not actually writing to/from a file
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:Mp4TagReverseDnsField.java

示例3: getRawContent

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public byte[] getRawContent() throws UnsupportedEncodingException
{
    logger.fine("Getting Raw data for:" + getId());
    try
    {
        ByteArrayOutputStream outerbaos = new ByteArrayOutputStream();
        outerbaos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + dataSize));
        outerbaos.write(getId().getBytes(StandardCharsets.ISO_8859_1));
        outerbaos.write(dataBytes);
        return outerbaos.toByteArray();
    }
    catch (IOException ioe)
    {
        //This should never happen as were not actually writing to/from a file
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:Mp4TagRawBinaryField.java

示例4: getDataBytes

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * Recreate the raw data content from the list of numbers
 *
 * @return
 */
protected byte[] getDataBytes()
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    for (Short number : numbers)
    {
        try
        {
            baos.write(Utils.getSizeBEInt16(number));
        }
        catch (IOException e)
        {
            //This should never happen because we are not writing to file at this point.
            throw new RuntimeException(e);
        }
    }
    return baos.toByteArray();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4TagTextNumberField.java

示例5: Mp4MeanBox

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * @param header     parentHeader info
 * @param dataBuffer data of box (doesnt include parentHeader data)
 */
public Mp4MeanBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
    this.header = header;

    //Double check
    if (!header.getId().equals(IDENTIFIER))
    {
        throw new RuntimeException("Unable to process data box because identifier is:" + header.getId());
    }

    //Make slice so operations here don't effect position of main buffer
    this.dataBuffer = dataBuffer.slice();

    //issuer
    this.issuer = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding());

}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:22,代码来源:Mp4MeanBox.java

示例6: Mp4NameBox

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * @param header     parentHeader info
 * @param dataBuffer data of box (doesnt include parentHeader data)
 */
public Mp4NameBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
    this.header = header;

    //Double check
    if (!header.getId().equals(IDENTIFIER))
    {
        throw new RuntimeException("Unable to process name box because identifier is:" + header.getId());
    }

    //Make slice so operations here don't effect position of main buffer
    this.dataBuffer = dataBuffer.slice();

    //issuer
    this.name = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding());
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:21,代码来源:Mp4NameBox.java

示例7: getBytes

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public byte[] getBytes() {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        baos.write(Utils.getSizeBEInt32(pictureType));
        baos.write(Utils.getSizeBEInt32(mimeType.length()));
        baos.write(mimeType.getBytes("ISO-8859-1"));
        baos.write(Utils.getSizeBEInt32(description.length()));
        baos.write(description.getBytes("UTF-8"));
        baos.write(Utils.getSizeBEInt32(width));
        baos.write(Utils.getSizeBEInt32(height));
        baos.write(Utils.getSizeBEInt32(colourDepth));
        baos.write(Utils.getSizeBEInt32(indexedColouredCount));
        baos.write(Utils.getSizeBEInt32(imageData.length));
        baos.write(imageData);
        return baos.toByteArray();

    } catch (IOException ioe) {
        throw new RuntimeException(ioe.getMessage());
    }
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:21,代码来源:MetadataBlockDataPicture.java

示例8: 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] &lt;&lt;--- [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);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:AiffTagWriter.java

示例9: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * Reads a chunk and extracts information.
 *
 * @return <code>false</code> if the chunk is structurally
 * invalid, otherwise <code>true</code>
 */
public boolean readChunk() throws IOException
{
    final int numComments = Utils.u(chunkData.getShort());

    //For each comment
    for (int i = 0; i < numComments; i++)
    {
        final long timestamp  = Utils.u(chunkData.getInt());
        final Date jTimestamp = AiffUtil.timestampToDate(timestamp);
        final int marker      = Utils.u(chunkData.getShort());
        final int count       = Utils.u(chunkData.getShort());
        // Append a timestamp to the comment
        final String text = Utils.getString(chunkData, 0, count, StandardCharsets.ISO_8859_1) + " " + AiffUtil.formatDate(jTimestamp);
        if (count % 2 != 0) {
            // if count is odd, text is padded with an extra byte that we need to consume
            chunkData.get();
        }
        aiffHeader.addComment(text);
    }
    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:28,代码来源:CommentsChunk.java

示例10: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * Reads a chunk and puts an Application property into
 * the RepInfo object.
 *
 * @return <code>false</code> if the chunk is structurally
 * invalid, otherwise <code>true</code>
 */
public boolean readChunk() throws IOException
{
    final String applicationSignature = Utils.readFourBytesAsChars(chunkData);
    String applicationName = null;

    /* If the application signature is 'pdos' or 'stoc',
     * then the beginning of the data area is a Pascal
     * string naming the application.  Otherwise, we
     * ignore the data.  ('pdos' is for Apple II
     * applications, 'stoc' for the entire non-Apple world.)
     */
    if (SIGNATURE_STOC.equals(applicationSignature) || SIGNATURE_PDOS.equals(applicationSignature))
    {
        applicationName = Utils.readPascalString(chunkData);
    }
    aiffHeader.addApplicationIdentifier(applicationSignature + ": " + applicationName);

    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:27,代码来源:ApplicationChunk.java

示例11: isValidHeader

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public static boolean isValidHeader(FileChannel fc) throws IOException, CannotReadException
{
    if (fc.size() - fc.position() < HEADER_LENGTH)
    {
        throw new CannotReadException("This is not a WAV File (<12 bytes)");
    }
    ByteBuffer headerBuffer = Utils.readFileDataIntoBufferLE(fc, HEADER_LENGTH);
    if(Utils.readFourBytesAsChars(headerBuffer).equals(RIFF_SIGNATURE))
    {
        headerBuffer.getInt(); //Size
        if(Utils.readFourBytesAsChars(headerBuffer).equals(WAVE_SIGNATURE))
        {
            return true;
        }
    }
    return false;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:WavRIFFHeader.java

示例12: 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);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:26,代码来源:WavTagWriter.java

示例13: 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);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:WavTagWriter.java

示例14: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 *
 * @return true if successfully read chunks
 *
 * @throws IOException
 */
public boolean readChunk() throws IOException
{
    boolean result = false;
    String subIdentifier = Utils.readFourBytesAsChars(chunkData);
    if(subIdentifier.equals(WavChunkType.INFO.getCode()))
    {
        WavInfoChunk chunk = new WavInfoChunk(tag, loggingName);
        result = chunk.readChunks(chunkData);
        //This is the start of the enclosing LIST element
        tag.getInfoTag().setStartLocationInFile(chunkHeader.getStartLocationInFile());
        tag.getInfoTag().setEndLocationInFile(chunkHeader.getStartLocationInFile() + ChunkHeader.CHUNK_HEADER_SIZE + chunkHeader.getSize());
        tag.setExistingInfoTag(true);
    }
    return result;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:22,代码来源:WavListChunk.java

示例15: Mp4StcoBox

import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
 * Construct box from data and show contents
 *
 * @param header header info
 * @param buffer data of box (doesnt include header data)
 */
public Mp4StcoBox(Mp4BoxHeader header, ByteBuffer buffer) {
    this.header = header;

    //Make a slice of databuffer then we can work with relative or absolute methods safetly
    dataBuffer = buffer.slice();

    //Skip the flags
    dataBuffer.position(dataBuffer.position() + VERSION_FLAG_LENGTH + OTHER_FLAG_LENGTH);

    //No of offsets
    this.noOfOffSets = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + NO_OF_OFFSETS_LENGTH - 1));
    dataBuffer.position(dataBuffer.position() + NO_OF_OFFSETS_LENGTH);

    //First Offset, useful for sanity checks
    firstOffSet = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + OFFSET_LENGTH - 1));
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:Mp4StcoBox.java


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