~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic-proposed

« back to all changes in this revision

Viewing changes to src/org/jaudiotagger/audio/asf/io/RandomAccessFileInputstream.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-12-30 21:58:38 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091230215838-113vy313ak2ap51i
Tags: 2.0.0-1
* New upstream release
* Update my email address
* Bump debhelper version to >= 7
* Bump Standards-Version to 3.8.3 (no changes needed)
* Depends on java5-runtime-headless as we build java5 bytecode
* Maven POMs:
  - Add a Build-Depends-Indep dependency on maven-repo-helper
  - Use mh_installpoms and mh_installjar to install the POM and the jar to the
    Maven repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
/**
8
8
 * Wraps a {@link RandomAccessFile} into an {@link InputStream}.<br>
 
9
 * 
9
10
 * @author Christian Laireiter
10
11
 */
11
 
public final class RandomAccessFileInputstream extends InputStream
12
 
{
 
12
public final class RandomAccessFileInputstream extends InputStream {
13
13
 
14
14
    /**
15
15
     * The file access to read from.<br>
17
17
    private final RandomAccessFile source;
18
18
 
19
19
    /**
20
 
     * Creates an instance that will provide {@link InputStream} functionality on the given
21
 
     * {@link RandomAccessFile} by delegating calls.<br>
 
20
     * Creates an instance that will provide {@link InputStream} functionality
 
21
     * on the given {@link RandomAccessFile} by delegating calls.<br>
22
22
     * 
23
 
     * @param file The file to read.
 
23
     * @param file
 
24
     *            The file to read.
24
25
     */
25
 
    public RandomAccessFileInputstream(final RandomAccessFile file)
26
 
    {
27
 
        if (file == null)
28
 
        {
29
 
            throw new NullPointerException();
 
26
    public RandomAccessFileInputstream(final RandomAccessFile file) {
 
27
        super();
 
28
        if (file == null) {
 
29
            throw new IllegalArgumentException("null");
30
30
        }
31
31
        this.source = file;
32
32
    }
35
35
     * {@inheritDoc}
36
36
     */
37
37
    @Override
38
 
    public int read() throws IOException
39
 
    {
 
38
    public int read() throws IOException {
40
39
        return this.source.read();
41
40
    }
42
41
 
44
43
     * {@inheritDoc}
45
44
     */
46
45
    @Override
47
 
    public int read(byte[] b, int off, int len) throws IOException
48
 
    {
49
 
        return this.source.read(b, off, len);
 
46
    public int read(final byte[] buffer, final int off, final int len)
 
47
            throws IOException {
 
48
        return this.source.read(buffer, off, len);
50
49
    }
51
50
 
52
 
   /**
 
51
    /**
53
52
     * {@inheritDoc}
54
53
     */
55
54
    @Override
56
 
    public long skip(long n) throws IOException
57
 
    {
58
 
        if (n <= 0)
59
 
        {
60
 
            return 0;
 
55
    public long skip(final long amount) throws IOException {
 
56
        if (amount < 0) {
 
57
            throw new IllegalArgumentException("invalid negative value");
61
58
        }
62
 
        while (n > Integer.MAX_VALUE)
63
 
        {
 
59
        long left = amount;
 
60
        while (left > Integer.MAX_VALUE) {
64
61
            this.source.skipBytes(Integer.MAX_VALUE);
65
 
            n -= Integer.MAX_VALUE;
 
62
            left -= Integer.MAX_VALUE;
66
63
        }
67
 
        return this.source.skipBytes((int) n);
 
64
        return this.source.skipBytes((int) left);
68
65
    }
69
66
 
70
67
}