1/*
2 * Copyright (C) 2007 The Android Open Source Project
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.android.dx.dex.file;
18
19import com.android.dx.rop.cst.Constant;
20
21import java.util.Collection;
22import java.util.Collections;
23import java.util.List;
24
25/**
26 * File header section of a {@code .dex} file.
27 */
28public final class HeaderSection extends UniformItemSection {
29    /** {@code non-null;} the list of the one item in the section */
30    private final List<HeaderItem> list;
31
32    /**
33     * Constructs an instance. The file offset is initially unknown.
34     *
35     * @param file {@code non-null;} file that this instance is part of
36     */
37    public HeaderSection(DexFile file) {
38        super(null, file, 4);
39
40        HeaderItem item = new HeaderItem();
41        item.setIndex(0);
42
43        this.list = Collections.singletonList(item);
44    }
45
46    /** {@inheritDoc} */
47    @Override
48    public IndexedItem get(Constant cst) {
49        return null;
50    }
51
52    /** {@inheritDoc} */
53    @Override
54    public Collection<? extends Item> items() {
55        return list;
56    }
57
58    /** {@inheritDoc} */
59    @Override
60    protected void orderItems() {
61        // Nothing to do here.
62    }
63}
64