1 /* 2 * Copyright (C) 2016 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.ahat.heapdump; 18 19 /** 20 * Generic PlaceHolder instance to take the place of a real AhatInstance for 21 * the purposes of displaying diffs. 22 * 23 * This should be created through a call to AhatInstance.newPlaceHolder(); 24 */ 25 public class AhatPlaceHolderInstance extends AhatInstance { AhatPlaceHolderInstance(AhatInstance baseline)26 AhatPlaceHolderInstance(AhatInstance baseline) { 27 super(-1); 28 setBaseline(baseline); 29 baseline.setBaseline(this); 30 } 31 getSize()32 @Override public long getSize() { 33 return 0; 34 } 35 getRetainedSize(AhatHeap heap)36 @Override public long getRetainedSize(AhatHeap heap) { 37 return 0; 38 } 39 getTotalRetainedSize()40 @Override public long getTotalRetainedSize() { 41 return 0; 42 } 43 getHeap()44 @Override public AhatHeap getHeap() { 45 return getBaseline().getHeap().getBaseline(); 46 } 47 getClassName()48 @Override public String getClassName() { 49 return getBaseline().getClassName(); 50 } 51 asString(int maxChars)52 @Override public String asString(int maxChars) { 53 return getBaseline().asString(maxChars); 54 } 55 toString()56 @Override public String toString() { 57 return getBaseline().toString(); 58 } 59 isPlaceHolder()60 @Override public boolean isPlaceHolder() { 61 return true; 62 } 63 } 64