From kato-commits-return-64-apmail-incubator-kato-commits-archive=incubator.apache.org@incubator.apache.org Thu May 07 14:51:06 2009 Return-Path: Delivered-To: apmail-incubator-kato-commits-archive@minotaur.apache.org Received: (qmail 65265 invoked from network); 7 May 2009 14:51:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 May 2009 14:51:06 -0000 Received: (qmail 3906 invoked by uid 500); 7 May 2009 14:51:05 -0000 Delivered-To: apmail-incubator-kato-commits-archive@incubator.apache.org Received: (qmail 3891 invoked by uid 500); 7 May 2009 14:51:05 -0000 Mailing-List: contact kato-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: kato-dev@incubator.apache.org Delivered-To: mailing list kato-commits@incubator.apache.org Received: (qmail 3881 invoked by uid 99); 7 May 2009 14:51:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 14:51:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 14:50:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6AFC52388A23; Thu, 7 May 2009 14:50:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r772669 [4/7] - in /incubator/kato/trunk: HprofBinaryReaderPOC/ HprofBinaryReaderPOC/.settings/ HprofBinaryReaderPOC/META-INF/ HprofBinaryReaderPOC/bin/ HprofBinaryReaderPOC/bin/org/ HprofBinaryReaderPOC/bin/org/apache/ HprofBinaryReaderPOC... Date: Thu, 07 May 2009 14:50:35 -0000 To: kato-commits@incubator.apache.org From: monteith@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090507145039.6AFC52388A23@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/kato/trunk/HprofBinaryReaderPOC/src/org/apache/kato/hprof/datalayer/StaticFieldEntry.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOC/src/org/apache/kato/hprof/datalayer/StaticFieldEntry.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOC/src/org/apache/kato/hprof/datalayer/StaticFieldEntry.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOC/src/org/apache/kato/hprof/datalayer/StaticFieldEntry.java Thu May 7 14:50:21 2009 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.datalayer; + +/** + * Represents a static field in a class on the heap. + * Provides methods to retrieve its value. + */ +public class StaticFieldEntry extends FieldEntry { + public StaticFieldEntry(long fieldNameID, short type, long data) { + this.fieldNameID = fieldNameID; + this.type = type; + this.data = data; + } + + /** + * The data. Fields are either ID's of objects or numbers, + * all should fit within a long. + */ + private long data; + + public long getData() { + return data; + } + + public byte getByteField() { + return (byte) data; + } + + + public char getCharField() { + return (char) data; + } + + + public double getDoubleField() { + return Double.longBitsToDouble(data); + } + + + public float getFloatField() { + return Float.intBitsToFloat((int) data); + } + + + public long getIDField() { + return data; + } + + + public int getIntegerField() { + return (int)data; + } + + + public long getLongField() { + return data; + } + + + public short getShortField() { + return (short)data; + } + + public boolean getBooleanField() { + return !(data == 0L); + } +} \ No newline at end of file Added: incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/org/apache/kato/hprof/HProfViewTest.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/org/apache/kato/hprof/HProfViewTest.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/org/apache/kato/hprof/HProfViewTest.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/org/apache/kato/hprof/HProfViewTest.java Thu May 7 14:50:21 2009 @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof; + +import java.io.File; +import java.util.Collection; +import java.util.Vector; + +import junit.framework.TestCase; + +import org.apache.kato.hprof.datalayer.HProfFactory; +import org.apache.kato.hprof.datalayer.HProfFile; + +public class HProfViewTest extends TestCase { + HProfFile file; + HProfView view; + + public void setUp() throws Exception { + file = HProfFactory.createReader(new File("data/dumpall.hprof")); + view = new HProfView(file); + view.open(null); + } + + public void testClassLoaders() { + Collection loaders = view.getJavaClassLoaders(); + + for(IJavaClassLoader loader : loaders) { + + System.out.println("\nloader = 0x"+Long.toHexString(loader.getID())); + System.out.println("=============================="); + + Collection classes = loader.getClasses(); + + for ( Long clazz : classes ) { + IJavaClass classObj = view.getJavaClassByID(clazz); + + System.out.println("\t0x"+Long.toHexString(clazz)+ ": "+ + Long.toHexString(classObj.getClassObjectID())+ + " "+classObj.getClassName()); + } + } + } +} Added: incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/AllTests.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/AllTests.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/AllTests.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/AllTests.java Thu May 7 14:50:21 2009 @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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 test.apache.kato.common; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests { + + public static Test suite() { + TestSuite suite = new TestSuite("Test for test.apache.kato.common"); + //$JUnit-BEGIN$ + suite.addTestSuite(TestBitMaskMappingArray.class); + suite.addTestSuite(TestSubsetDataProvider.class); + suite.addTestSuite(TestDataReader.class); + suite.addTestSuite(TestArrayCompactor.class); + suite.addTestSuite(TestArrayBitMaskMappingStrategy.class); + //$JUnit-END$ + return suite; + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayBitMaskMappingStrategy.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayBitMaskMappingStrategy.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayBitMaskMappingStrategy.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayBitMaskMappingStrategy.java Thu May 7 14:50:21 2009 @@ -0,0 +1,279 @@ +package test.apache.kato.common; + +import junit.framework.TestCase; + +import org.apache.kato.common.ArrayBitMaskMappingStrategy; + +public class TestArrayBitMaskMappingStrategy extends TestCase { + + + + public void report(int arraySize,int elementNo1,int elementNo2) { + + + System.out.println("Array Size = "+arraySize); + System.out.println("Element Nos = "+elementNo1+","+elementNo2+" ("+Integer.toBinaryString(elementNo2)); + int maxBitShift= (int) (31 - (Math.log10(arraySize)/Math.log10(2)))+1; + System.out.println("Maximum bit shift = "+maxBitShift); + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(arraySize,2); + + int arrayIndex1 = c.getIndexArrayElement(elementNo1); + int seekCount1 = c.getSeekCount(elementNo1); + + System.out.println("Array Index1 = "+arrayIndex1+" : "+seekCount1); + + int arrayIndex2 = c.getIndexArrayElement(elementNo2); + int seekCount2 = c.getSeekCount(elementNo2); + + System.out.println("Array Index2 = "+arrayIndex2+" : "+seekCount2); + + int bitcount=(int) (Math.log10(elementNo2)/Math.log10(2))+1; + int max= ( 1 << bitcount ) -1; + System.out.println("Element2 bitcount = "+bitcount+" ( Max is "+max+")"); + int newBucketSize=max/arraySize; + int bitcountBS=(int) (Math.log10(newBucketSize)/Math.log10(2))+1; + int maxBS= ( 1 << bitcountBS ) -1; + System.out.println("new bitcount = "+bitcountBS+" ( Max is "+maxBS+")"); + System.out.println("new bucket size = "+maxBS+" ("+(maxBS*arraySize)+")("+Integer.toBinaryString(maxBS)); + + + } + + + + public void testArraySize1bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(8,c.getArraySize()); + + + } + + public void testBucketSize1bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(2,c.getBucketSize()); + + } + public void testArraySize5bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(8,c.getArraySize()); + + + } + + public void testBucketSize5bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(32,c.getBucketSize()); + + } + + public void testGet0ElementFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(0,c.getIndexArrayElement(0)); + assertEquals(0,c.getSeekCount(0)); + + } + public void testGet0ElementSeekCountFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(0,c.getSeekCount(0)); + + } + + public void testGet1ElementFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(0,c.getIndexArrayElement(1)); + + + } + public void testGet1ElementSeekFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(1,c.getSeekCount(1)); + + } + + public void testGet3ElementFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(1,c.getIndexArrayElement(3)); + + + } + public void testGet3ElementSeekFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(1,c.getSeekCount(3)); + + } + + public void testGet15ElementFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(7,c.getIndexArrayElement(15)); + + + } + public void testGet15ElementSeekFrom1Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + assertEquals(1,c.getSeekCount(15)); + + } + + + public void testGet0ElementFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(0,c.getIndexArrayElement(0)); + assertEquals(0,c.getSeekCount(0)); + + } + + public void testGet0ElementSeekCountFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(0,c.getSeekCount(0)); + + } + + public void testGet1ElementFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(0,c.getIndexArrayElement(1)); + + + } + + public void testGet1ElementSeekFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(1,c.getSeekCount(1)); + + } + + public void testGet3ElementFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(0,c.getIndexArrayElement(3)); + + + } + + public void testGet3ElementSeekFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(3,c.getSeekCount(3)); + + } + + public void testGet64ElementFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(2,c.getIndexArrayElement(64)); + + + } + + public void testGet64ElementSeekFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(0,c.getSeekCount(64)); + + } + + public void testGet500ElementFrom5Bit() { + + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + assertEquals(-1,c.getIndexArrayElement(500)); + + } + + public void testDoubleCapacityReturnsObject() { + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + ArrayBitMaskMappingStrategy newStrategy=c.doubleCapacity(); + assertNotNull(newStrategy); + } + public void testDoubleCapacityReturnsNull() { + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,(Integer.MAX_VALUE/2)+50); + ArrayBitMaskMappingStrategy newStrategy=c.doubleCapacity(); + assertNull(newStrategy); + } + public void testDoubleCapacityArraySize() { + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + ArrayBitMaskMappingStrategy newStrategy=c.doubleCapacity(); + assertEquals(8,newStrategy.getArraySize()); + + + } + public void testDoubleCapacityBucketSize() { + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,30); + ArrayBitMaskMappingStrategy newStrategy=c.doubleCapacity(); + assertEquals(64,newStrategy.getBucketSize()); + + } + public void testSmallArrayMapping1Bit() { + + int[] data=new int[8]; + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + for(int i=0;i<16;i++) { + int location=c.getIndexArrayElement(i); + int seek=c.getSeekCount(i); + if(seek==0) data[location]=i; + } + + assertEquals(0,data[0]); + assertEquals(2,data[1]); + assertEquals(4,data[2]); + assertEquals(6,data[3]); + assertEquals(8,data[4]); + assertEquals(10,data[5]); + assertEquals(12,data[6]); + assertEquals(14,data[7]); + + + + } + + + public void testSmallArrayDoubling1Bit() { + + int[] data=new int[8]; + ArrayBitMaskMappingStrategy c=new ArrayBitMaskMappingStrategy(8,2); + for(int i=0;i<16;i++) { + int location=c.getIndexArrayElement(i); + int seek=c.getSeekCount(i); + if(seek==0) data[location]=i; + } + + c=c.doubleCapacity(); + + for(int i=0;i<16;i++) { + int location=c.getIndexArrayElement(i); + int seek=c.getSeekCount(i); + if(seek==0) { + assertEquals(data[location]*2,i); + } + } + + + + } + + public void printWible() { + + for(int i=2;i<32;i++) { + int bitshift=(int) (Math.log10(i-1)/Math.log10(2)); + int shifted= 1 << bitshift; + int mask = (1 << (bitshift+1))-1; + int max = mask+1; + System.out.println(""+i+"("+max+")="+bitshift+" "+Integer.toBinaryString(i)+" "+Integer.toBinaryString(shifted)+ " "+Integer.toBinaryString(mask)); + } + } +} Added: incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayCompactor.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayCompactor.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayCompactor.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOC/testsrc/test/apache/kato/common/TestArrayCompactor.java Thu May 7 14:50:21 2009 @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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 test.apache.kato.common; + +import org.apache.kato.common.ArrayCompactor; + +import junit.framework.TestCase; + +public class TestArrayCompactor extends TestCase { + + + public void testCompactArray() { + + long[] array=new long[]{100,50,45,30,56,90,89,2,0,0,0 }; + int last=7; + long[] results=new long[]{100,45,56,89,56,90,89,2,0,0,0 }; + int expectedLast=3; + + int result=ArrayCompactor.compact(array, last); + assertEquals(expectedLast,result); + + for(int i=0;i + + + + + + + + + + + + + + + + + + + + + Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/Activator.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/Activator.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/Activator.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/Activator.java Thu May 7 14:50:21 2009 @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import java.io.File; +import java.io.IOException; + +import org.apache.kato.hprof.datalayer.HProfFile; +import org.apache.kato.hprof.datalayer.HProfFactory; +import org.eclipse.core.runtime.IAdapterManager; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.views.properties.IPropertySource; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.apache.kato.hprof.ui"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + final IAdapterManager manager = Platform.getAdapterManager(); + + manager.registerAdapters(new HPRofEntityPropertySourceAdapter(),IPropertySource.class); + + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public void load(IProgressMonitor pm, File file) { + + + } + + public void load(IProgressMonitor pm, HProfSource source) { + HProfFile converter=null; + try { + converter = HProfFactory.createReader(source.getFile()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + source.setDump(converter); + } +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/DumpEditorInput.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/DumpEditorInput.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/DumpEditorInput.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/DumpEditorInput.java Thu May 7 14:50:21 2009 @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPersistableElement; + +public class DumpEditorInput implements IEditorInput { + + private HProfSource source=null; + + public DumpEditorInput(HProfSource converter) { + this.source = converter; + } + + @Override + public boolean exists() { + + return false; + } + + @Override + public ImageDescriptor getImageDescriptor() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getName() { + + return source.getName(); + } + + @Override + public IPersistableElement getPersistable() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getToolTipText() { + + return "HProf Dump"; + } + + @Override + public Object getAdapter(Class adapter) { + // TODO Auto-generated method stub + return null; + } + + public HProfSource getSource() { + return source; + } + + + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/ExploreHProfFileAction.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/ExploreHProfFileAction.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/ExploreHProfFileAction.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/ExploreHProfFileAction.java Thu May 7 14:50:21 2009 @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + + +import java.io.File; +import java.io.IOException; + +import org.apache.kato.hprof.datalayer.HProfFile; +import org.apache.kato.hprof.datalayer.HProfFactory; +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +public class ExploreHProfFileAction implements IObjectActionDelegate{ + + private IFile file=null; + @Override + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // TODO Auto-generated method stub + + } + + @Override + public void run(IAction action) { + if(file==null) return; + File realFile=new File(file.getFullPath().toString()); + HProfFile hprof; + try { + hprof = HProfFactory.createReader(realFile); + } catch (IOException e) { + e.printStackTrace(); + hprof=null; + } + if(hprof==null) { + Shell shell = new Shell(); + MessageDialog.openInformation( + shell, + "HPRof Viewer Plug-in", + ""+realFile+" is not an hprof file"); + + } + + + + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + if(selection==null) file=null; + else { + if(selection instanceof IStructuredSelection) { + IStructuredSelection ss=(IStructuredSelection) selection; + Object top=ss.getFirstElement(); + if(top instanceof IFile) { + file=(IFile) top; + } + + } + } + + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HPRofEntityPropertySourceAdapter.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HPRofEntityPropertySourceAdapter.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HPRofEntityPropertySourceAdapter.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HPRofEntityPropertySourceAdapter.java Thu May 7 14:50:21 2009 @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import java.util.Properties; + +import org.apache.kato.hprof.datalayer.HProfFile; +import org.apache.kato.hprof.datalayer.IUTF8HProfRecord; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; +import org.eclipse.ui.progress.IElementCollector; +import org.eclipse.ui.views.properties.IPropertySource; + +public class HPRofEntityPropertySourceAdapter implements IAdapterFactory{ + + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + + System.out.println("called for "+adaptableObject.getClass()+" "+adapterType); + if(adaptableObject==null) return null; // belt and braces + + if(adaptableObject instanceof HProfFile) { + HProfFile hp=(HProfFile) adaptableObject; + return toProperty(hp); + } + if(adaptableObject instanceof IUTF8HProfRecord) { + return toProperty((IUTF8HProfRecord)adaptableObject); + } + return null; + } + + private Object toProperty(IUTF8HProfRecord adaptableObject) { + Properties p=new Properties(); + p.put("characters",adaptableObject.getCharacters()); + p.put("value",adaptableObject.getAsString()); + return p; + } + + private Object toProperty(HProfFile hp) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[]{IPropertySource.class}; + } + + + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfEntityPropertySourceAdapterFactory.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfEntityPropertySourceAdapterFactory.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfEntityPropertySourceAdapterFactory.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfEntityPropertySourceAdapterFactory.java Thu May 7 14:50:21 2009 @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.apache.kato.hprof.datalayer.HProfFile; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.views.properties.IPropertySource; + +public class HProfEntityPropertySourceAdapterFactory implements IAdapterFactory{ + + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + + System.out.println("handle.."+adaptableObject); + if(adaptableObject==null) return null; // belt and braces + + if(adaptableObject instanceof HProfFile) { + HProfFile hp=(HProfFile) adaptableObject; + return hp.getHeader(); + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[]{IWorkbenchAdapter.class}; + } + + + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordHandle.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordHandle.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordHandle.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordHandle.java Thu May 7 14:50:21 2009 @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.apache.kato.hprof.HProfView; +import org.apache.kato.hprof.datalayer.IHProfRecord; +import org.apache.kato.hprof.datalayer.HProfFile.GCClassHeapDumpRecord; +import org.apache.kato.hprof.ui.propertysource.GCClassHeapDumpRecordPropertySource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.views.properties.IPropertySource; + +public class HProfRecordHandle implements IAdaptable{ + + private HProfView view=null; + + public HProfRecordHandle(int index,HProfView view) { + this.recordNumber=index; + this.view=view; + } + + public int recordNumber=0; + + public IHProfRecord getRecord() { + return view.getFile().getRecord(recordNumber); + } + + public long getRecordLocation() { + return view.getFile().getRecordLocation(recordNumber); + } + + @Override + public Object getAdapter(Class adapter) { + + + return null; + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordPropertySource.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordPropertySource.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordPropertySource.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfRecordPropertySource.java Thu May 7 14:50:21 2009 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource; + +public class HProfRecordPropertySource implements IPropertySource { + + private HProfRecordHandle handle=null; + public HProfRecordPropertySource(HProfRecordHandle profRecordHandle) { + this.handle=profRecordHandle; + } + + @Override + public Object getEditableValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getPropertyValue(Object id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isPropertySet(Object id) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void resetPropertyValue(Object id) { + // TODO Auto-generated method stub + + } + + @Override + public void setPropertyValue(Object id, Object value) { + // TODO Auto-generated method stub + + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSource.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSource.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSource.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSource.java Thu May 7 14:50:21 2009 @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import java.io.File; + +import org.apache.kato.hprof.datalayer.HProfFile; + +public class HProfSource { + + public HProfSource(File file) { + this.file=file; + } + private File file=null; + private HProfFile dump=null; + public File getFile() { + + return file; + } + public HProfFile getDump() { + return dump; + } + public void setDump(HProfFile dump) { + this.dump = dump; + } + public String getName() { + + return file.getAbsolutePath(); + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSubRecordHandle.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSubRecordHandle.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSubRecordHandle.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfSubRecordHandle.java Thu May 7 14:50:21 2009 @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.apache.kato.hprof.datalayer.IHProfRecord; +import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord; +import org.apache.kato.hprof.ui.factory.HProfRecordPropertySourceFactory; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.views.properties.IPropertySource; + +public class HProfSubRecordHandle implements IAdaptable { + + private IHeapDumpHProfRecord dumprecord = null; + + public HProfSubRecordHandle(int index, IHeapDumpHProfRecord rec) { + this.recordNumber = index; + this.dumprecord = rec; + } + + public int recordNumber = 0; + + public IHProfRecord getRecord() { + return dumprecord.getSubRecord(recordNumber); + } + + public long getRecordLocation() { + return dumprecord.getSubRecordLocation(recordNumber); + } + + @Override + public Object getAdapter(Class adapter) { + + + + if (IPropertySource.class.isAssignableFrom(adapter)) { + + IHProfRecord record = getRecord(); + return HProfRecordPropertySourceFactory.createPropertySource( + dumprecord, recordNumber, getRecord()); + } + + if(adapter == Long.class) { + return (Long)getRecordLocation(); + } + return null; + } + +} Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfWorkbenchAdapter.java URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfWorkbenchAdapter.java?rev=772669&view=auto ============================================================================== --- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfWorkbenchAdapter.java (added) +++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/HProfWorkbenchAdapter.java Thu May 7 14:50:21 2009 @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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 org.apache.kato.hprof.ui; + +import org.apache.kato.hprof.datalayer.HProfFile; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; + +public class HProfWorkbenchAdapter implements IWorkbenchAdapter { + + private HProfFile base=null; + + public HProfWorkbenchAdapter(HProfFile obj) { + this.base=null; + } + @Override + public Object[] getChildren(Object o) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getLabel(Object o) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getParent(Object o) { + // TODO Auto-generated method stub + return null; + } + +}