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