1/*
2 * Copyright 2012 castLabs, Berlin
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.googlecode.mp4parser.boxes.mp4.samplegrouping;
18
19import com.coremedia.iso.Hex;
20
21import java.nio.ByteBuffer;
22
23/**
24 *
25 */
26public class UnknownEntry extends GroupEntry {
27    private ByteBuffer content;
28
29    public UnknownEntry() {
30    }
31
32    public ByteBuffer getContent() {
33        return content;
34    }
35
36    public void setContent(ByteBuffer content) {
37        this.content = (ByteBuffer) content.duplicate().rewind();
38    }
39
40    @Override
41    public void parse(ByteBuffer byteBuffer) {
42        this.content = (ByteBuffer) byteBuffer.duplicate().rewind();
43    }
44
45    @Override
46    public ByteBuffer get() {
47        return content.duplicate();
48    }
49
50    @Override
51    public String toString() {
52        ByteBuffer bb = content.duplicate();
53        bb.rewind();
54        byte[] b = new byte[bb.limit()];
55        bb.get(b);
56        return "UnknownEntry{" +
57                "content=" + Hex.encodeHex(b) +
58                '}';
59    }
60
61    @Override
62    public boolean equals(Object o) {
63        if (this == o) {
64            return true;
65        }
66        if (o == null || getClass() != o.getClass()) {
67            return false;
68        }
69
70        UnknownEntry that = (UnknownEntry) o;
71
72        if (content != null ? !content.equals(that.content) : that.content != null) {
73            return false;
74        }
75
76        return true;
77    }
78
79    @Override
80    public int hashCode() {
81        return content != null ? content.hashCode() : 0;
82    }
83}
84