All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.apk.parser.struct.resource.ResourcePackage Maven / Gradle / Ivy

There is a newer version: 2.6.10
Show newest version
package net.dongliu.apk.parser.struct.resource;

import net.dongliu.apk.parser.struct.StringPool;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Resource packge.
 *
 * @author dongliu
 */
public class ResourcePackage {
    // the packageName
    private String name;
    private short id;
    // contains the names of the types of the Resources defined in the ResourcePackage
    private StringPool typeStringPool;
    //  contains the names (keys) of the Resources defined in the ResourcePackage.
    private StringPool keyStringPool;

    public ResourcePackage(PackageHeader header) {
        this.name = header.getName();
        this.id = (short) header.getId();
    }

    private Map typeSpecMap = new HashMap<>();

    private Map> typesMap = new HashMap<>();

    public void addTypeSpec(TypeSpec typeSpec) {
        this.typeSpecMap.put(typeSpec.getId(), typeSpec);
    }

    public TypeSpec getTypeSpec(Short id) {
        return this.typeSpecMap.get(id);
    }

    public void addType(Type type) {
        List types = this.typesMap.get(type.getId());
        if (types == null) {
            types = new ArrayList<>();
            this.typesMap.put(type.getId(), types);
        }
        types.add(type);
    }

    public List getTypes(Short id) {
        return this.typesMap.get(id);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public short getId() {
        return id;
    }

    public void setId(short id) {
        this.id = id;
    }

    public StringPool getTypeStringPool() {
        return typeStringPool;
    }

    public void setTypeStringPool(StringPool typeStringPool) {
        this.typeStringPool = typeStringPool;
    }

    public StringPool getKeyStringPool() {
        return keyStringPool;
    }

    public void setKeyStringPool(StringPool keyStringPool) {
        this.keyStringPool = keyStringPool;
    }

    public Map getTypeSpecMap() {
        return typeSpecMap;
    }

    public void setTypeSpecMap(Map typeSpecMap) {
        this.typeSpecMap = typeSpecMap;
    }

    public Map> getTypesMap() {
        return typesMap;
    }

    public void setTypesMap(Map> typesMap) {
        this.typesMap = typesMap;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy