本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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());
}
示例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());
}
示例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());
}
}
示例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] <<--- [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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}