001    package jp.osdl.jbento2.analyzer;
002    
003    public class GCSample extends GCTransition {
004        public static final int TYPE_GC = 1;
005    
006        public static final int TYPE_FULL_GC = 2;
007    
008        private int type = 0;
009    
010        private long startTime = -1;
011    
012        private GCTransition newGC = new GCTransition();;
013    
014        private GCTransition tenuredGC = new GCTransition();
015    
016        private GCTransition permGC = new GCTransition();
017    
018        public void setNewGC(GCTransition newGC) {
019            this.newGC = newGC;
020        }
021    
022        public GCTransition getNewGC() {
023            return newGC;
024        }
025    
026        public void setTenuredGC(GCTransition tenuredGC) {
027            this.tenuredGC = tenuredGC;
028            type = TYPE_FULL_GC;
029        }
030    
031        public GCTransition getTenuredGC() {
032            return tenuredGC;
033        }
034    
035        public void setPermGC(GCTransition permGC) {
036            this.permGC = permGC;
037        }
038    
039        public GCTransition getPermGC() {
040            return permGC;
041        }
042    
043        public long getStartTime() {
044            return startTime;
045        }
046    
047        public void setStartTime(long startTime) {
048            this.startTime = startTime;
049        }
050    
051        public int getType() {
052            return type;
053        }
054    
055        public void setType(int type) {
056            this.type = type;
057        }
058    
059        public void calculate() {
060            if (newGC.getBeforeSize() == -1) {
061                newGC.setBeforeSize(getBeforeSize() - tenuredGC.getBeforeSize());
062            }
063            if (type == GCSample.TYPE_FULL_GC) {
064                newGC.setAfterSize(0);
065            }
066            if (newGC.getMaxSize() == -1) {
067                newGC.setMaxSize(getMaxSize() - tenuredGC.getMaxSize());
068            }
069    
070            if (tenuredGC.getAfterSize() == -1) {
071                tenuredGC.setAfterSize(getAfterSize() - newGC.getAfterSize());
072            }
073            if (tenuredGC.getBeforeSize() == -1) {
074                tenuredGC.setBeforeSize(getBeforeSize() - newGC.getBeforeSize());
075            }
076            if (tenuredGC.getMaxSize() == -1) {
077                tenuredGC.setMaxSize(getMaxSize() - newGC.getMaxSize());
078            }
079        }
080    }