// Path: java/com/google/devrel/gmscore/tools/apk/arsc/ArscBlamer.java
// @AutoValue
// public abstract static class ResourceEntry {
//   public abstract String packageName();
//   public abstract String typeName();
//   public abstract String entryName();
// 
//   static ResourceEntry create(TypeChunk.Entry entry) {
//     PackageChunk packageChunk = Preconditions.checkNotNull(entry.parent().getPackageChunk());
//     String packageName = packageChunk.getPackageName();
//     String typeName = entry.typeName();
//     String entryName = entry.key();
//     return new AutoValue_ArscBlamer_ResourceEntry(packageName, typeName, entryName);
//   }
// }


import com.google.common.base.Preconditions;
import com.google.devrel.gmscore.tools.apk.arsc.ArscBlamer.ResourceEntry;
import com.google.inject.Inject;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devrel.gmscore.tools.apk.arsc;



/**
 * Calculates extra information about an {@link ArscBlamer.ResourceEntry}, such as the total
 * APK size the entry is responsible for.
 *
 * This class is not thread-safe.
 */
public class ResourceEntryStatsCollector {

  /** The size in bytes of an offset in a chunk. */
  private static final int OFFSET_SIZE = 4;

  /** The size in bytes of overhead for styles, if present, in {@link StringPoolChunk}. */
  private static final int STYLE_OVERHEAD = 8;

  /**
   * The number of bytes, in addition to the header, that the {@link PackageChunk} has in overhead
   * excluding the chunks it contains.
   */
  private static final int PACKAGE_CHUNK_OVERHEAD = 8;

// Path: java/com/google/devrel/gmscore/tools/apk/arsc/ArscBlamer.java
// @AutoValue
// public abstract static class ResourceEntry {
//   public abstract String packageName();
//   public abstract String typeName();
//   public abstract String entryName();
// 
//   static ResourceEntry create(TypeChunk.Entry entry) {
//     PackageChunk packageChunk = Preconditions.checkNotNull(entry.parent().getPackageChunk());
//     String packageName = packageChunk.getPackageName();
//     String typeName = entry.typeName();
//     String entryName = entry.key();
//     return new AutoValue_ArscBlamer_ResourceEntry(packageName, typeName, entryName);
//   }
// }


// Path: java/com/google/devrel/gmscore/tools/apk/arsc/ResourceEntryStatsCollector.java
import com.google.common.base.Preconditions;
import com.google.devrel.gmscore.tools.apk.arsc.ArscBlamer.ResourceEntry;
import com.google.inject.Inject;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devrel.gmscore.tools.apk.arsc;



/**
 * Calculates extra information about an {@link ArscBlamer.ResourceEntry}, such as the total
 * APK size the entry is responsible for.
 *
 * This class is not thread-safe.
 */
public class ResourceEntryStatsCollector {

  /** The size in bytes of an offset in a chunk. */
  private static final int OFFSET_SIZE = 4;

  /** The size in bytes of overhead for styles, if present, in {@link StringPoolChunk}. */
  private static final int STYLE_OVERHEAD = 8;

  /**
   * The number of bytes, in addition to the header, that the {@link PackageChunk} has in overhead
   * excluding the chunks it contains.
   */
  private static final int PACKAGE_CHUNK_OVERHEAD = 8;

  private final Map<ResourceEntry, ResourceStatistics> stats = new HashMap<>();