geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [42/51] [partial] incubator-geode git commit: SGA #2
Date Fri, 03 Jul 2015 19:21:43 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectIntrospector.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectIntrospector.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectIntrospector.java
new file mode 100644
index 0000000..2a55869
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectIntrospector.java
@@ -0,0 +1,195 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionRepository;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+public class ObjectIntrospector {
+  // field exposing 'name' attribute of an enum
+  private static final String ENUM_NAME_FIELD = "name";
+  // method of enum to get the value of name attribute, ToString method return user friendly name
+  private static final String ENUM_NAME_METHOD = "toString";
+  //maintains list of classes already introspected
+  private static Set<Class<?>> introspectedClassList = new HashSet<Class<?>>();
+  
+  public static IntrospectionResult introspectClass(Class objClass) throws IntrospectionException {
+    LogUtil.info("Start introspecting class :"+objClass);
+
+    IntrospectionRepository repo = IntrospectionRepository.singleton();
+    ObjectTypeResultImpl result = new ObjectTypeResultImpl(objClass);
+    //Set<ObjectColumn> columns = new HashSet<ObjectColumn>();
+    Set<ObjectColumn> columns = new TreeSet<ObjectColumn>(new ObjectColumnComparator());
+    //In case of generic Object class, we do not have specific fields/properties to introspect.
+    //also in case of Class class, we do not have application specific
+    // fields/properties to introspect.
+    //Hence we will return immediately.
+    if (objClass.equals(java.lang.Object.class)
+        || objClass.equals(java.lang.Class.class)
+        ||objClass.isInterface()
+        ) {
+      return result;
+    }
+    
+    //Step 1 : Use the Java Beans specification to retrieve accessible properties.
+    BeanInfo info = null;
+    try {
+      if(objClass.isEnum())
+        info = Introspector.getBeanInfo(objClass, Enum.class);//Don't want to introspect unnecessary properties of enum  
+      else
+        info = Introspector.getBeanInfo(objClass, Object.class);  
+    }
+    catch (java.beans.IntrospectionException e) {
+      throw new IntrospectionException(e);     
+    }
+    
+    //adding class in introspected list for future reference
+    introspectedClassList.add(objClass);
+    
+    PropertyDescriptor[] desc = info.getPropertyDescriptors();
+    for (int i = 0; i < desc.length; i++) {
+      String name = desc[i].getName();
+      Method readMethod = desc[i].getReadMethod();
+      if(readMethod == null)
+        continue;
+      int modifiers = readMethod.getModifiers();
+      boolean accessible = readMethod.isAccessible();
+      
+      if(Modifier.isPublic(modifiers)){
+        if(!accessible) {
+          try {
+            readMethod.setAccessible(true);
+          }
+          catch (SecurityException e) {
+            LogUtil.warning("Exception while making property"+name+" accessible :"+e.getMessage());
+            continue;
+          }
+        }
+        
+        Method writeMethod = desc[i].getWriteMethod();
+        ObjectPropertyImpl column = new ObjectPropertyImpl(name, readMethod, writeMethod);
+        Class<?> fieldType = column.getFieldType();
+        if (!introspectedClassList.contains(fieldType)) {
+          repo.introspectType(fieldType);
+        }
+        columns.add(column);
+        LogUtil.fine("Added Property :" + name);
+      }
+    }  
+    
+    //Make a list of public fields available for this type. For this take care of field 'hiding'.
+    //For this, we start with the actual type being introspected, upto the base type (i.e. java.lang.Object.class)
+    //adding/replacing the fields as necessary.
+    Map<String, Field> _fields = new HashMap<String, Field>();
+    Class type = objClass;    
+    do {
+      //Check and add all the public fields.
+      Field[] fields = type.getFields();
+      for (int i = 0; i < fields.length; i++) {
+        Field field = fields[i];
+        String name = field.getName();
+        int modifier = field.getModifiers();      
+        if(!Modifier.isStatic(modifier) && !Modifier.isTransient(modifier)) {
+         if(_fields.containsKey(name)) {
+           Field temp = _fields.get(name);
+           //If the current entry in the Map is of Supertype then replace it with the subtype.
+           if((temp != field) && (temp.getDeclaringClass().isAssignableFrom(field.getDeclaringClass()))) {
+            _fields.put(name, field); 
+           }
+         } else {
+           _fields.put(name, field);
+         }
+        }
+      }
+      type = type.getSuperclass();
+    } while(!(type == null  || type.equals(java.lang.Object.class)));
+
+    
+    Field[] fields = _fields.values().toArray(new Field[0]);
+    for (int i = 0; i < fields.length; i++) {
+      Field field = fields[i];
+      LogUtil.fine("Field :"+field);
+      int modifier = field.getModifiers();      
+      boolean readOnly = Modifier.isFinal(modifier);        
+      ObjectFieldImpl column = new ObjectFieldImpl(field, readOnly);
+      Class<?> fieldType = column.getFieldType();
+      if (!introspectedClassList.contains(fieldType)) {
+        repo.introspectType(fieldType);
+      }
+        
+      if(!columns.contains(column)) {
+       columns.add(column);
+       LogUtil.fine("Added Field :"+column.getFieldName());
+      } 
+    }
+    
+    // in case of enum, we need to read "name" attribute
+    if(objClass.isEnum()){
+      Method readMethod;
+      try {
+        readMethod = objClass.getMethod(ENUM_NAME_METHOD, (Class<?> [])null);
+        boolean accessible = readMethod.isAccessible();
+        if(!accessible)
+          readMethod.setAccessible(true);
+        ObjectPropertyImpl column = new ObjectPropertyImpl(ENUM_NAME_FIELD, readMethod, null);
+        if(!columns.contains(column)) {
+          columns.add(column);
+          LogUtil.fine("Added property :"+column.getFieldName());
+         } 
+      }
+      catch (SecurityException e) {
+        LogUtil.fine("Exception while making property toString accessible :"+e.getMessage());
+      }
+      catch (NoSuchMethodException e) {
+        LogUtil.fine("Exception while getting method toString :"+e.getMessage());
+      }
+    }
+    
+    result.setObjectColumns(columns);  
+    LogUtil.fine("End introspecting class :"+objClass);
+    return result;
+  }
+  
+  static class ObjectColumnComparator implements Comparator, Serializable {
+    
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public int compare(Object o1, Object o2) {
+      ObjectColumn col1 = (ObjectColumn)o1;
+      ObjectColumn col2 = (ObjectColumn)o2;
+      
+      if(col1.getFieldName().equals(col2.getFieldName()))
+       return 0; 
+      
+      if(col1.getDeclaringClass().equals(col2.getDeclaringClass())) 
+       return col1.getFieldName().compareTo(col2.getFieldName()); 
+      
+      if(col1.getDeclaringClass().isAssignableFrom(col2.getDeclaringClass()))
+       return -1;
+      
+      return 1;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectPropertyImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectPropertyImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectPropertyImpl.java
new file mode 100644
index 0000000..e6914e9
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectPropertyImpl.java
@@ -0,0 +1,76 @@
+/*=========================================================================
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+
+public class ObjectPropertyImpl implements ObjectColumn {
+  protected final String name;
+  protected final Method readMethod;
+  protected final Method writeMethod;
+  protected boolean final_;
+
+  public ObjectPropertyImpl(String nm, Method mthdRead, Method mthdWrite ) {
+    name = nm;
+    readMethod = mthdRead;
+    writeMethod = mthdWrite;
+    int modifier = readMethod.getReturnType().getModifiers();
+    this.final_ = (readMethod.getReturnType().isPrimitive() || Modifier.isFinal(modifier));
+  }
+
+  public String getFieldName() {
+    return this.name;
+  }
+
+  public Class<?> getFieldType() {
+    return readMethod.getReturnType();
+  }
+
+  public boolean isReadOnly() {
+    return (writeMethod == null);
+  }
+
+  public boolean isFinal() {
+    return this.final_;
+  }
+
+  public Class getDeclaringClass() {
+    return this.readMethod.getDeclaringClass();
+  }
+
+  public Object getValue(Object object) throws ColumnValueNotAvailableException {
+    try {
+     return readMethod.invoke(object);
+    }
+    catch (Exception e) {
+      throw new ColumnValueNotAvailableException("Could not read the value of the property "+name + " for input type "+object, e);
+    }
+  }
+
+  @Override
+  public int hashCode() {
+    return this.name.hashCode();
+  }
+
+  @Override
+  public String toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("ObjectPropertyImpl [ declaringClass :"+this.getDeclaringClass()+" name :"+this.getFieldName()+" ]");
+    return buffer.toString();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(obj instanceof ObjectColumn) {
+      ObjectColumn other = (ObjectColumn)obj;
+      return (this.getFieldName().equals(other.getFieldName()));
+    }
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectTypeResultImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectTypeResultImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectTypeResultImpl.java
new file mode 100644
index 0000000..ad299e2
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ObjectTypeResultImpl.java
@@ -0,0 +1,264 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionRepository;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil;
+
+/**
+ * This class provides functionality to introspect a given class and perform
+ * necessary object-to-relational transformations to flatten the objects.
+ *
+ * @author Hrishi
+ **/
+public final class ObjectTypeResultImpl implements IntrospectionResult {
+
+  private Class<?>           type_ = null;
+  private List<ObjectColumn> fields_ = null;
+
+  public ObjectTypeResultImpl(Class<?> ty) {
+    type_ = ty;
+    fields_ = new ArrayList<ObjectColumn>();
+  }
+  
+  public int getResultType() {
+    return COMPOSITE_TYPE_RESULT;
+  }
+
+  void setObjectColumns(Collection<ObjectColumn> columns) {
+    fields_.clear();
+    fields_.addAll(columns);
+  }
+  
+  public ObjectColumn getObjectColumn(int index) {
+    if (fields_.size() > index) {
+      return fields_.get(index);
+    }
+    
+    return null;
+  }
+
+  public Class getColumnClass(int index) throws ColumnNotFoundException {
+    if (fields_.size() > index) {
+      ObjectColumn col = fields_.get(index);
+      return col.getFieldType();
+    }
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+  
+  public Class getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    int type = getColumnType(index);
+    ObjectColumn col = fields_.get(index);
+    
+    if(type == IntrospectionResult.UNKNOWN_TYPE_COLUMN && (tuple != null)) {
+      try {
+        Object val = col.getValue(tuple);
+        if(val != null) {
+          return val.getClass();
+        }
+      }
+      catch (ColumnValueNotAvailableException e) {
+        throw new ColumnNotFoundException(e);
+      }
+    }
+    
+    return col.getFieldType();
+  }
+
+  public Class<?> getJavaType() {
+    return type_;
+  }
+
+  public int getColumnCount() {
+    return fields_.size();
+  }
+
+  public String getColumnName(int index) throws ColumnNotFoundException {
+    if (fields_.size() > index) {
+      ObjectColumn col = fields_.get(index);
+      return col.getFieldName();
+    }
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    for (ObjectColumn column : fields_) {
+      if (column.getFieldName().equals(name)) {
+        return fields_.indexOf(column);
+      }
+    }
+
+    throw new ColumnNotFoundException("Column not available for name :" + name);
+  }
+
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    // TODO: Hrishi it is a zero based index right?
+    /*
+    if (index > fields_.size()) {
+      throw new ColumnNotFoundException("Column not available for index :"
+          + index);
+    }
+
+    ObjectColumn col = fields_.get(index);
+     
+    if (QueryUtil.isPrimitiveType(col.getFieldType()))
+      return IntrospectionResult.PRIMITIVE_TYPE_COLUMN;
+    else if (QueryUtil.isCompositeType(col.getFieldType())) {
+      if(col.isFinal())
+        return IntrospectionResult.COMPOSITE_TYPE_COLUMN;
+
+      return IntrospectionResult.UNKNOWN_TYPE_COLUMN;  
+    } else if (QueryUtil.isCollectionType(col.getFieldType()))
+      return IntrospectionResult.COLLECTION_TYPE_COLUMN;
+    else if (QueryUtil.isMapType(col.getFieldType()))
+      return IntrospectionResult.MAP_TYPE_COLUMN;
+
+    throw new ColumnNotFoundException(
+        "Unable to detect the column type for index :" + index);
+    
+    */
+    final ObjectColumn col;
+    int iRes = IntrospectionResult.UNDEFINED;
+    String sXptnMsg = null;
+    
+    try {
+      col = fields_.get(index);
+      if (QueryUtil.isPrimitiveType(col.getFieldType()))
+        iRes = IntrospectionResult.PRIMITIVE_TYPE_COLUMN;
+      else if (QueryUtil.isCompositeType(col.getFieldType())) {
+        if(col.isFinal())
+          iRes = IntrospectionResult.COMPOSITE_TYPE_COLUMN;
+        else
+          iRes = IntrospectionResult.UNKNOWN_TYPE_COLUMN;  
+      } else if (QueryUtil.isCollectionType(col.getFieldType()))
+        iRes = IntrospectionResult.COLLECTION_TYPE_COLUMN;
+      else if (QueryUtil.isMapType(col.getFieldType()))
+        iRes = IntrospectionResult.MAP_TYPE_COLUMN;
+      
+      if( IntrospectionResult.UNDEFINED == iRes ) {
+        sXptnMsg = "Unable to detect the column type for index :" + index;
+      }
+    }
+    catch( IndexOutOfBoundsException xptn ) {
+      sXptnMsg = "Column not available for index : " + index;
+    }
+    
+    if( null != sXptnMsg ) {
+      throw new ColumnNotFoundException( sXptnMsg );
+    }
+    
+    return iRes;
+  }
+  
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+   
+    int type = getColumnType(index);
+    ObjectColumn col = fields_.get(index);
+    
+    if(type == IntrospectionResult.UNKNOWN_TYPE_COLUMN && tuple != null) {
+
+        try {
+          Object value = col.getValue(tuple);
+          if(value != null) {
+            IntrospectionResult result = IntrospectionRepository.singleton().introspectTypeByObject(value);
+            switch(result.getResultType()) {
+              case PRIMITIVE_TYPE_RESULT : return PRIMITIVE_TYPE_COLUMN;
+              case COMPOSITE_TYPE_RESULT : return COMPOSITE_TYPE_COLUMN;
+              case COLLECTION_TYPE_RESULT : return COLLECTION_TYPE_COLUMN;
+              case MAP_TYPE_RESULT : return MAP_TYPE_COLUMN;
+              case PDX_TYPE_RESULT : return PDX_TYPE_COLUMN;
+            }
+          }
+        }
+        catch (ColumnValueNotAvailableException e) {
+          throw new ColumnNotFoundException(e);    
+        } catch (IntrospectionException e) {
+          throw new ColumnNotFoundException(e);              
+        } 
+    }
+    
+    return type;
+  }
+
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    if (fields_.size() > index) {
+      ObjectColumn col = fields_.get(index);
+      int type = getColumnType(tuple, index);
+
+      switch (type) {
+        case COMPOSITE_TYPE_COLUMN: {
+          //In this case we don't need to make sure that the type of the field is
+          //introspected, because that is already done in ObjectIntrospector class during init. 
+          return col.getValue(tuple);
+        }
+  
+        case COLLECTION_TYPE_COLUMN: {
+       
+          if(col.getFieldType().isArray()) {
+            try {
+              return QueryUtil.introspectArrayType(col.getFieldType(), col.getValue(tuple));
+            }
+            catch (IntrospectionException e) {
+              throw new ColumnValueNotAvailableException(e);
+            }
+          }
+          
+          Collection< Object > result = (Collection<Object>) col.getValue(tuple);
+          try {
+            return QueryUtil.introspectCollectionObject(result);
+          } catch (QueryExecutionException e) {
+            throw new ColumnValueNotAvailableException(e);
+          }
+        }
+        
+        case MAP_TYPE_COLUMN: {
+          Map result = (Map)col.getValue(tuple);
+          Collection temp = null;
+          if(result != null)          
+            temp = result.entrySet();   
+          
+          try {
+            return QueryUtil.introspectCollectionObject(temp);
+          }
+          catch (QueryExecutionException e) {
+            throw new ColumnValueNotAvailableException(e);
+          }
+        }
+        
+        default: return col.getValue(tuple);
+        }
+    }
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+  
+  public String getJavaTypeName() {
+    Class<?> javaType = getJavaType();
+    
+    return javaType != null ? javaType.getName() : null;
+  }
+  
+  public boolean isCompatible(Object data) {
+    //checks for equality by reference not assignable. Using == assuming single 
+    //instance of a class
+    return data != null && getJavaType() == data.getClass();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxEnumIntrospectionResult.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxEnumIntrospectionResult.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxEnumIntrospectionResult.java
new file mode 100644
index 0000000..144f29e
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxEnumIntrospectionResult.java
@@ -0,0 +1,154 @@
+/*
+ * =========================================================================
+ * Copyright (c) 2002-2012 VMware, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. VMware products are covered by
+ * more patents listed at http://www.vmware.com/go/patents.
+ * All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.pdx.PdxInstance;
+
+/**
+ * This class is used to gather & provide introspection meta-data about Objects
+ * which are enums & represented by GemFire type PdxInstance. The introspection
+ * is done only on the 'name' of an enum. 
+ * 
+ * Note: enum that implement PdxSerializable would still be accessible as 
+ * PdxInstanceImpl & Data Browser will handler them using 
+ * PdxIntrospectionResult.
+ * 
+ * @author abhishek
+ * @since 1.4 (GemFire 6.6.2)
+ */
+public class PdxEnumIntrospectionResult implements IntrospectionResult {
+  /* stores the PdxInfoType objects for the known PdxInstance objects */
+  private static final Map<PdxInstance, PdxInfoType> pdxInfos = new HashMap<PdxInstance, PdxInfoType>();
+
+  /* List of Field Names in the given PdxInstance */
+  private List<String> fieldNames;
+  /* Local (Data Browser side) representation of the GemFire PdxType */
+  private PdxInfoType  pdxInfoType;
+
+  //Note: used by PdxTypesIntrospectionResult
+  public PdxEnumIntrospectionResult(Object pdxInstanceArg) {
+    PdxInstance pdxInstance;
+    if (pdxInstanceArg instanceof PdxInstance) {
+      pdxInstance = (PdxInstance) pdxInstanceArg;
+    } else {
+      throw new IllegalArgumentException("Only PdxInstance enum class is expected.");
+    }
+
+    fieldNames  = pdxInstance.getFieldNames();
+    pdxInfoType = new PdxInfoType(pdxInstance.getClassName());
+    pdxInfos.put(pdxInstance, pdxInfoType);
+  }
+
+  public Class<?> getColumnClass(int index) throws ColumnNotFoundException {
+    // For enum, we are exposing only 'name' which will be a String
+    return String.class;
+  }
+
+  public Class<?> getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnClass(index);
+  }
+
+  public int getColumnCount() {
+    return fieldNames.size();
+  }
+
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    return fieldNames.indexOf(name);
+  }
+
+  public String getColumnName(int index) throws ColumnNotFoundException {
+    return fieldNames.get(index);
+  }
+
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    // For enum, we are exposing only 'name' which will be a String/Primitive
+    return IntrospectionResult.PRIMITIVE_TYPE_COLUMN;
+  }
+
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnType(index);
+  }
+
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    return ((PdxInstance)tuple).getField(getColumnName(index));
+  }
+
+  public Class<?> getJavaType() {
+    return PdxInstance.class;
+  }
+  
+  public String getJavaTypeName() {
+    return pdxInfoType.getDisplayName();
+  }
+
+  public int getResultType() {
+    return PDX_TYPE_RESULT;
+  }
+
+  /**
+   * Whether the given Object is compatible with this IntrospectionResult. Here,
+   * we check whether the type of the actual object is same as that of the given
+   * object. The PdxInstance have the meta info about the actual object.
+   * 
+   * @param data
+   *          Object to check for compatibility
+   * @return true if type of the given Object is same as the type for which this
+   *         IntrospectionResult is created, false otherwise
+   *         
+   * @see IntrospectionResult#isCompatible(Object)        
+   */
+  public boolean isCompatible(Object data) {
+    //checks for equality not assignable
+    return pdxInfoType.equals(getPdxInfoType(data));
+  }
+
+  /**
+   * Create or return existing PdxInfoType for the given object. If given object
+   * - 'pdxInstanceArg' - is not of the type PdxInstanceImpl, it returns null.
+   * 
+   * @param pdxInstanceArg
+   *          PdxInstance for which PdxInfoType is to be retrieved
+   * @return new or existing PdxInfoType for the given object.
+   */
+  //Note: used by PdxTypesIntrospectionResult
+  static PdxInfoType getPdxInfoType(Object pdxInstanceArg) {
+    PdxInfoType storedPdxInfoType = null;
+    
+    if (pdxInstanceArg instanceof PdxInstance) {
+      PdxInstance pdxInstance = (PdxInstance) pdxInstanceArg;
+
+      storedPdxInfoType = pdxInfos.get(pdxInstance);
+
+      if (storedPdxInfoType == null) {
+        storedPdxInfoType = new PdxInfoType(pdxInstance.getClassName());
+      } 
+    }
+    
+    return storedPdxInfoType; 
+  }
+  
+  /**
+   * Clears cached known Pdx Instance type Information.
+   */
+  //Note: used by PdxTypesIntrospectionResult
+  static void clearKnownPdxTypeInfo() {
+    pdxInfos.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxHelper.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxHelper.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxHelper.java
new file mode 100644
index 0000000..bf0121e
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxHelper.java
@@ -0,0 +1,261 @@
+/*
+ * =========================================================================
+ * Copyright (c) 2002-2012 VMware, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. VMware products are covered by
+ * more patents listed at http://www.vmware.com/go/patents.
+ * All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+/**
+ * Helper class through which everything needed for PDX support is available.
+ * <pre>
+ * 1. Whether PDX is available 
+ * 2. Whether given type is assignable to PdxInstance
+ * 3. Whether given object is instance of PdxInstance  
+ * <pre>
+ * Using reflection, isolates loading of GemFire 6.6 types/classes used for 
+ * PdxInstance from the rest of the code so that Data Browser can be used with 
+ * earlier GemFire versions.
+ * 
+ * @author abhishek
+ * @since 1.3 (GemFire 6.6)
+ */
+public class PdxHelper {
+
+  /* Initial GemFire version since when PDX support started */
+  private static final double PDX_SUPPORT_START_VERSION = 6.6;
+  private static final double PDX_FIELDTYPE_MADE_PUBLIC_MINOR_VERSION = 6.2; //read it in continuation with 6.6 i.e. 6.6 MAJOR.MINOR & 6.2 MINOR.SUBMINOR 
+  /* Class Name to use to load the PdxInstance type (java.lang.Class)  */
+  private static final String PDXINSTANCE_CLASS_NAME = "com.gemstone.gemfire.pdx.PdxInstance";
+  /* Class Name of the class used for IntrospectionResult for objects of type
+   * PdxInstance. This class has to use internal GemFire types introduced in
+   * GemFire 6.6, hence this is also accessed using reflection though it's a
+   * Data Browser class */
+  private static final String PDXINSTANCE_INTROSPECTION_RESULT_CLASS_NAME = "com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PdxTypesIntrospectionResult";
+  
+  private static final String PDXINSTANCE_FIELDTYPE66_CLASS_NAME  = "com.gemstone.gemfire.pdx.internal.FieldType";
+  private static final String PDXINSTANCE_FIELDTYPE662_CLASS_NAME = "com.gemstone.gemfire.pdx.FieldType";
+
+  /* PdxHelper instance class */
+  private static final PdxHelper instance = new PdxHelper();
+  
+  /* Class used for PdxInstance type */
+  private Class<?> pdxInstanceClass;
+  /* Class used for IntrospectionResult for PdxInstance type */
+  private Class<? extends IntrospectionResult> pdxIntrospectionResultClass;
+  /* Caching constructor of IntrospectionResult implementation used for
+   * PdxInstance type. Specifically: PdxTypesIntrospectionResult(Object, String) */
+  private Constructor<? extends IntrospectionResult> pdxIntrospectionResultConstructor;
+  /* Caching method of IntrospectionResult implementation used for retrieving 
+   * PdxInfoType for a PdxInstance type. Specifically: getPdxInfoType(Object) 
+   * & clearKnownPdxInfo()*/
+  private Method getPdxInfoTypeMethod;
+  private Method clearKnownPdxInfoMethod;
+  
+  /* boolean indicating whether PDX is supported or not */
+  private boolean pdxSupported = false;
+
+  private double gemfireMajorMinorVersion    = 6.0; //oldest supported by Data Browser
+  private double gemfireMinorSubMinorVersion = 0.0; //oldest supported by Data Browser
+  private String fieldTypeClassName;
+
+  /**
+   * Checks whether PDX support is available. If PDX support is available,
+   * initializes components required for introspecting PdxInstance
+   */
+  private PdxHelper() {
+    String version = GemFireVersion.getGemFireVersion();
+    if(version.indexOf("Beta") > 0){
+	    version = version.substring(0, version.indexOf("Beta"));
+    }
+    String[] split = version.split("\\.");
+    if (split.length >= 2) {
+      String majorMinor = split[0] + "." + split[1];
+      gemfireMajorMinorVersion = Double.valueOf(majorMinor);
+      this.pdxSupported = gemfireMajorMinorVersion >= PDX_SUPPORT_START_VERSION;
+    }
+    
+    if (this.pdxSupported) {
+      if (split.length > 2) {
+        String minorSubMinor = split[1] + "." + split[2];
+        gemfireMinorSubMinorVersion = Double.valueOf(minorSubMinor);
+      }
+      
+      fieldTypeClassName = PDXINSTANCE_FIELDTYPE662_CLASS_NAME;
+      //for versions prior to 6.6.2 
+      if (gemfireMajorMinorVersion == PDX_SUPPORT_START_VERSION && 
+          gemfireMinorSubMinorVersion < PDX_FIELDTYPE_MADE_PUBLIC_MINOR_VERSION) {
+        fieldTypeClassName = PDXINSTANCE_FIELDTYPE66_CLASS_NAME;
+      }
+       
+      initPdxIntrospectionSupport();
+    }
+  }
+
+  /**
+   * Initializes local (Data Browser side) support for introspecting PdxInstance
+   * types.
+   */
+  private void initPdxIntrospectionSupport() {
+    try {
+      pdxInstanceClass            = Class.forName(PDXINSTANCE_CLASS_NAME);
+      pdxIntrospectionResultClass = (Class<? extends IntrospectionResult>) Class.forName(PDXINSTANCE_INTROSPECTION_RESULT_CLASS_NAME);
+    } catch (ClassNotFoundException e) {
+      pdxInstanceClass            = null;
+      pdxIntrospectionResultClass = null;
+      LogUtil.error("This GemFire version supports Pdx but could not load/find required classes.", e);
+    }
+    
+    if (pdxIntrospectionResultClass != null) {
+      try {
+        pdxIntrospectionResultConstructor = pdxIntrospectionResultClass.getConstructor(new Class[] {Object.class, String.class});
+        getPdxInfoTypeMethod    = pdxIntrospectionResultClass.getDeclaredMethod("getPdxInfoType", new Class[] {Object.class});
+        clearKnownPdxInfoMethod = pdxIntrospectionResultClass.getDeclaredMethod("clearKnownPdxTypeInfo", new Class[0]);
+      } catch (SecurityException e) {
+        pdxIntrospectionResultConstructor = null;
+        getPdxInfoTypeMethod              = null;
+        clearKnownPdxInfoMethod           = null;
+        LogUtil.error("This GemFire version supports Pdx but could not access required class elements.", e);
+      } catch (NoSuchMethodException e) {
+        pdxIntrospectionResultConstructor = null;
+        getPdxInfoTypeMethod              = null;
+        clearKnownPdxInfoMethod           = null;
+        LogUtil.error("This GemFire version supports Pdx but could not find required class elements.", e);
+      }
+    }
+    LogUtil.fine("Versions Info: "+gemfireMajorMinorVersion + "," + gemfireMinorSubMinorVersion + ", field type class : "+ fieldTypeClassName);
+  }  
+  
+  /**
+   * @return singleton for PdxHelper
+   */
+  public static PdxHelper getInstance() {
+    return instance;
+  }
+  
+  /**
+   * @return whether the GemFire version supports PDX
+   */
+  public boolean isPdxSupported() {
+    return this.pdxSupported;
+  }
+
+  /**
+   * Checks whether PDX support is available & whether the given instance is of
+   * PdxInstance GemFire type
+   * 
+   * @param other
+   *          Object to be checked whether it's of PdxInstance GemFire type
+   * @return true if PDX support is available & given object is of type
+   *         PdxInstance, false otherwise
+   */
+  public boolean isPdxInstance(Object other) {
+    if (!isPdxSupported()) {
+      return false;
+    }
+    
+    return pdxInstanceClass.isInstance(other);
+  }
+
+  /**
+   * Checks whether PDX support is available & whether the given Class/type is
+   * same as or sub-type of PdxInstance GemFire type
+   * 
+   * @param klass
+   *          Class/type to be checked whether it is same as or sub-type of
+   *          PdxInstance GemFire type
+   * @return true if PDX support is available & given object is same as or
+   *         sub-type of PdxInstance GemFire type, false otherwise
+   */
+  public boolean isPdxInstanceType(Class<?> klass) {
+    if (!isPdxSupported()) {
+      return false;
+    }
+    
+    return pdxInstanceClass.isAssignableFrom(klass);
+  }
+
+  /**
+   * Wraps the method PdxTypesIntrospectionResult.getPdxInfoType(Object) which
+   * is used to Create or return existing PdxInfoType for the given object. If
+   * given object - 'pdxInstanceObj' - is not of the type PdxInstanceImpl OR if
+   * can call to PdxTypesIntrospectionResult.getPdxInfoType() using reflection
+   * fails, it returns null.
+   * 
+   * @param pdxInstanceObj
+   *          PdxInstance for which PdxInfoType is to be retrieved
+   * @return new or existing PdxInfoType for the given object.
+   * @throws PdxIntrospectionException
+   *           if fails to invoke method -
+   *           PdxTypesIntrospectionResult.getPdxInfoType
+   */
+  public PdxInfoType getPdxInfoType(Object pdxInstanceObj) throws PdxIntrospectionException {
+    PdxInfoType pdxInfoType = null;
+    try {
+      pdxInfoType = (PdxInfoType) getPdxInfoTypeMethod.invoke(pdxIntrospectionResultClass, new Object[] {pdxInstanceObj});
+    } catch (IllegalArgumentException e) {
+      throw new PdxIntrospectionException(e);
+    } catch (IllegalAccessException e) {
+      throw new PdxIntrospectionException(e);
+    } catch (InvocationTargetException e) {
+      throw new PdxIntrospectionException(e);
+    }
+    
+    return pdxInfoType;
+  }
+  
+  /**
+   * Wraps creation of new PdxTypesIntrospectionResult objects.
+   * 
+   * @param pdxInstanceObj
+   *          PdxInstance for which PdxTypesIntrospectionResult is needed
+   * @return new PdxTypesIntrospectionResult object for a given pdxInstanceObj
+   * @throws PdxIntrospectionException
+   *           if fails to create PdxTypesIntrospectionResult using reflection
+   * @throws IllegalArgumentException
+   *           if given object is not a PdxInstance
+   */
+  public IntrospectionResult getPdxMetaInfo(Object pdxInstanceObj) throws PdxIntrospectionException {
+    IntrospectionResult pdxIntrospectionResult = null;
+    try {
+      pdxIntrospectionResult = pdxIntrospectionResultConstructor.newInstance(new Object[] {pdxInstanceObj, fieldTypeClassName});
+    } catch (IllegalArgumentException e) {
+      throw new PdxIntrospectionException(e);
+    } catch (InstantiationException e) {
+      throw new PdxIntrospectionException(e);
+    } catch (IllegalAccessException e) {
+      throw new PdxIntrospectionException(e);
+    } catch (InvocationTargetException e) {
+      throw new PdxIntrospectionException(e);
+    }
+    
+    return pdxIntrospectionResult;
+  }
+  
+  /**
+   * Clears cached known Pdx Instance type Information.
+   * Wraps call to PdxTypesIntrospectionResult.clearKnownPdxTypeInfo()
+   */
+  public void clearKnownPdxTypeInfo() {
+    try {
+      clearKnownPdxInfoMethod.invoke(pdxIntrospectionResultClass, new Object[0]);
+    } catch (IllegalArgumentException e) {
+      LogUtil.warning("Could not clear cached known Pdx Type information.", e);
+    } catch (IllegalAccessException e) {
+      LogUtil.warning("Could not clear cached known Pdx Type information.", e);
+    } catch (InvocationTargetException e) {
+      LogUtil.warning("Could not clear cached known Pdx Type information.", e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxInfoType.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxInfoType.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxInfoType.java
new file mode 100644
index 0000000..412b63c
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxInfoType.java
@@ -0,0 +1,102 @@
+/*
+ * =========================================================================
+ * Copyright (c) 2002-2012 VMware, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. VMware products are covered by
+ * more patents listed at http://www.vmware.com/go/patents.
+ * All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+
+/** 
+ * Local (Data Browser side) representation of the GemFire class PdxType.
+ * 
+ * @author abhishek
+ * @since 1.3 (GemFire 6.6)
+ */
+public class PdxInfoType {
+  /* Actual class name of the PdxInstance */
+  private String className = "";
+  /* Internal Type Id of the PdxInstance */
+  private int    typeId    = -1;
+  /* Actual class name of the PdxInstance */
+  // Darrel mentioned that this doesn't mean that it is a NATIVE class/type
+  // Hence, currently it's not used in Data Browser except for equals() check.
+//  private boolean isNotJavaClass = false;
+  
+  private String displayName;
+  
+  /**
+   * Useful for PdxInstance for enum.
+   * 
+   * @param className
+   * @since 1.4 (GemFire 6.6.2)
+   */
+  public PdxInfoType(String className) {
+    this.className   = className;
+    this.displayName = this.className;//TODO: Is there no version for non PdxSerializable enums?
+  }
+  
+  /**
+   * Useful for PdxInstanceImpl.
+   * 
+   * @param className
+   * @param typeId
+   */
+  public PdxInfoType(String className, int typeId) {
+    this.className      = className;
+    this.typeId         = typeId;
+    this.displayName    = className + "(pdxId:" + typeId + ")";
+  }
+  
+  /**
+   * @return the className
+   */
+  public String getClassName() {
+    return className;
+  }
+  
+  /**
+   * @return the typeId
+   */
+  public int getTypeId() {
+    return typeId;
+  }
+
+  public String getDisplayName() {
+    return displayName;
+  }
+
+  /**
+   * Equality is checked on all className, typeId & isNotJavaClass.
+   * 
+   * @param obj
+   *          object to check for equality with this PdxInfoType object
+   * @return whether given object is same as this PdxInfoType object
+   */
+  public boolean equals(Object obj) {
+    if (!(obj instanceof PdxInfoType)) {
+      return false;
+    }
+    PdxInfoType other = (PdxInfoType) obj;   
+    
+    return this.className.equals(other.className) 
+            && this.typeId == other.typeId;
+  }
+  
+  /**
+   * @return hashcode based on the hash code of class name & type id
+   */
+  public int hashCode() {
+    return className.hashCode() + typeId;
+  }
+
+  /**
+   * @return String representation of this object
+   */
+  public String toString() {
+    return PdxInfoType.class.getSimpleName()+"["+className+","+typeId+"]";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionException.java
new file mode 100644
index 0000000..cd0db39
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionException.java
@@ -0,0 +1,34 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionException;
+
+/**
+ * Exception used while introspecting PdxInstance GemFire type.
+ * 
+ * @author abhishek
+ */
+public class PdxIntrospectionException extends IntrospectionException {
+
+  private static final long serialVersionUID = 85788300245998987L;
+
+  public PdxIntrospectionException() {
+    super();
+  }
+
+  public PdxIntrospectionException(String message, Throwable throwable) {
+    super(message, throwable);
+  }
+
+  public PdxIntrospectionException(String message) {
+    super(message);
+  }
+
+  public PdxIntrospectionException(Throwable throwable) {
+    super(throwable);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionResult.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionResult.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionResult.java
new file mode 100644
index 0000000..14e9258
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxIntrospectionResult.java
@@ -0,0 +1,272 @@
+/*
+ * =========================================================================
+ * Copyright (c) 2002-2012 VMware, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. VMware products are covered by
+ * more patents listed at http://www.vmware.com/go/patents.
+ * All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+import com.gemstone.gemfire.pdx.internal.PdxField;
+import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl;
+import com.gemstone.gemfire.pdx.internal.PdxType;
+
+/**
+ * This class is used to gather & provide introspection meta-data about Objects 
+ * which are of GemFire type PdxInstance - PdxInstanceImpl to be specific. The 
+ * introspection is done using other classes PdxType, FieldType & PdxField.
+ * 
+ * @author abhishek
+ * @since 1.3 (GemFire 6.6)
+ */
+public class PdxIntrospectionResult implements IntrospectionResult {
+  /* stores the PdxInfoType objects for the known PdxInstanceImpl objects */
+  private static final Map<PdxInstanceImpl, PdxInfoType> pdxInfos = new HashMap<PdxInstanceImpl, PdxInfoType>();
+  
+  /* PdxType for the given PdxInstanceImpl */
+  private PdxType      pdxType;
+  /* List of Field Names in the given PdxInstanceImpl */
+  private List<String> fieldNames;
+  /* Local (Data Browser side) representation of the GemFire PdxType */
+  private PdxInfoType  pdxInfoType;
+
+  /* Class that represents FieldType enum in GemFire. */
+  private FieldTypeAccessor fieldTypeAccessor;
+
+  //Note: used by PdxTypesIntrospectionResult
+  public PdxIntrospectionResult(Object pdxInstanceArg, String fieldTypeClass) {
+    PdxInstanceImpl pdxInstance;
+    if (pdxInstanceArg instanceof PdxInstanceImpl) {
+      pdxInstance = (PdxInstanceImpl) pdxInstanceArg;
+    } else {
+      throw new IllegalArgumentException("Only PdxInstance class is expected.");
+    }
+
+    try {
+      fieldTypeAccessor = new FieldTypeAccessor(Class.forName(fieldTypeClass));
+    } catch (ClassNotFoundException e) {
+      LogUtil.error("Could not load/find required classes.", e);
+    }
+    
+    pdxType     = pdxInstance.getPdxType();
+    fieldNames  = pdxType.getFieldNames();
+    pdxInfoType = new PdxInfoType(pdxType.getClassName(), pdxType.getTypeId());
+    pdxInfos.put(pdxInstance, pdxInfoType);
+  }
+
+  public Class<?> getColumnClass(int index) throws ColumnNotFoundException {
+    PdxField pdxField = pdxType.getPdxFieldByIndex(index);
+    Object fieldType = pdxField.getFieldType();
+    Class<?> columnClass = null;
+    
+    if (fieldType.equals(fieldTypeAccessor.getBoolean())) {
+      columnClass = boolean.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getByte())) {
+      columnClass = byte.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getChar())) {
+      columnClass = char.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getShort())) {
+      columnClass = short.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getInt())) {
+      columnClass = int.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getLong())) {
+      columnClass = long.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getFloat())) {
+      columnClass = float.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getDouble())) {
+      columnClass = double.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getDate())) {
+//      columnClass = String.class;//TODO: should this be a string
+      columnClass = java.util.Date.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getString())) {
+      columnClass = String.class;
+    } else if (fieldType.equals(fieldTypeAccessor.getBooleanArray())) {
+      columnClass = boolean[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getCharArray())) {
+      columnClass = char[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getByteArray())) {
+      columnClass = byte[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getShortArray())) {
+      columnClass = short[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getIntArray())) {
+      columnClass = int[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getLongArray())) {
+      columnClass = long[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getFloatArray())) {
+      columnClass = float[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getDoubleArray())) {
+      columnClass = double[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getStringArray())) {
+      columnClass = String[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getObjectArray())) {
+      columnClass = Object[].class;
+    } else if (fieldType.equals(fieldTypeAccessor.getArrayOfByteArrays())) {
+      columnClass = byte[][].class;
+    }else if (fieldType.equals(fieldTypeAccessor.getObject())) {
+      columnClass = Object.class;
+    } 
+    
+    if (columnClass == null) {
+      throw new ColumnNotFoundException("PDX Type Information for Column not available for index :" + index);
+    }
+
+    return columnClass;
+  }
+
+  public Class<?> getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnClass(index);
+  }
+
+  public int getColumnCount() {
+    return fieldNames.size();
+  }
+
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    return fieldNames.indexOf(name);
+  }
+
+  public String getColumnName(int index) throws ColumnNotFoundException {
+    return fieldNames.get(index);
+  }
+
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    int iRes = IntrospectionResult.UNDEFINED;
+    String sXptnMsg = null;
+    
+    try {
+      PdxField pdxField = pdxType.getPdxFieldByIndex(index);
+      Object fieldType = pdxField.getFieldType();
+//      System.out.println("PdxIntrospectionResult.getColumnType() : pdxField :: "+pdxField);
+//      System.out.println("PdxIntrospectionResult.getColumnType() : fieldType :: "+fieldType);
+      boolean isPrimitive = fieldType.equals(fieldTypeAccessor.getBoolean()) ||  
+                            fieldType.equals(fieldTypeAccessor.getByte()) || 
+                            fieldType.equals(fieldTypeAccessor.getChar()) || 
+                            fieldType.equals(fieldTypeAccessor.getShort()) ||
+                            fieldType.equals(fieldTypeAccessor.getInt()) || 
+                            fieldType.equals(fieldTypeAccessor.getLong()) ||
+                            fieldType.equals(fieldTypeAccessor.getFloat()) || 
+                            fieldType.equals(fieldTypeAccessor.getDouble()) ||
+                            fieldType.equals(fieldTypeAccessor.getString()) || 
+                            fieldType.equals(fieldTypeAccessor.getDate()); //TODO: should date be here as primitive?
+      
+      boolean isCollection = fieldType.equals(fieldTypeAccessor.getBooleanArray()) ||  
+                            fieldType.equals(fieldTypeAccessor.getCharArray()) || 
+                            fieldType.equals(fieldTypeAccessor.getByteArray()) || 
+                            fieldType.equals(fieldTypeAccessor.getShortArray()) ||
+                            fieldType.equals(fieldTypeAccessor.getIntArray()) || 
+                            fieldType.equals(fieldTypeAccessor.getLongArray()) ||
+                            fieldType.equals(fieldTypeAccessor.getFloatArray()) || 
+                            fieldType.equals(fieldTypeAccessor.getDoubleArray()) ||
+                            fieldType.equals(fieldTypeAccessor.getStringArray()) ||
+                            fieldType.equals(fieldTypeAccessor.getObjectArray()) ||
+                            fieldType.equals(fieldTypeAccessor.getArrayOfByteArrays());
+      
+      boolean isObject = fieldType.equals(fieldTypeAccessor.getObject());
+      
+      if (isPrimitive) {
+        iRes = IntrospectionResult.PRIMITIVE_TYPE_COLUMN;
+      } else if (isCollection) {
+        iRes = IntrospectionResult.COLLECTION_TYPE_COLUMN;
+      } else if (isObject) {
+        iRes = IntrospectionResult.PDX_OBJECT_TYPE_COLUMN;
+      }
+      
+      if( IntrospectionResult.UNDEFINED == iRes ) {
+        sXptnMsg = "Unable to detect the column type for index :" + index;
+      }
+    } catch( IndexOutOfBoundsException xptn ) {
+      sXptnMsg = "Column not available for index : " + index;
+    }
+    
+    if( null != sXptnMsg ) {
+      throw new ColumnNotFoundException( sXptnMsg );
+    }
+    
+    return iRes;
+  }
+
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnType(index);
+  }
+
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    return ((PdxInstanceImpl)tuple).getField(getColumnName(index));
+  }
+
+  public Class<?> getJavaType() {
+    return PdxInstanceImpl.class;//TODO: should there be a dummy PdxInstance class.
+  }
+  
+  public String getJavaTypeName() {
+    return pdxInfoType.getDisplayName();
+  }
+
+  public int getResultType() {
+    return PDX_TYPE_RESULT;
+  }
+
+  /**
+   * Whether the given Object is compatible with this IntrospectionResult. Here,
+   * we check whether the type of the actual object is same as that of the given
+   * object. The PdxInstance have the meta info about the actual object.
+   * 
+   * @param data
+   *          Object to check for compatibility
+   * @return true if type of the given Object is same as the type for which this
+   *         IntrospectionResult is created, false otherwise
+   *         
+   * @see IntrospectionResult#isCompatible(Object)        
+   */
+  public boolean isCompatible(Object data) {
+    //checks for equality not assignable
+    return pdxInfoType.equals(getPdxInfoType(data));
+  }
+
+  /**
+   * Create or return existing PdxInfoType for the given object. If given object
+   * - 'pdxInstanceArg' - is not of the type PdxInstanceImpl, it returns null.
+   * 
+   * @param pdxInstanceArg
+   *          PdxInstance for which PdxInfoType is to be retrieved
+   * @return new or existing PdxInfoType for the given object.
+   */
+  //Note: used by PdxTypesIntrospectionResult
+  static PdxInfoType getPdxInfoType(Object pdxInstanceArg) {
+    PdxInfoType storedPdxInfoType = null;
+    
+    if (pdxInstanceArg instanceof PdxInstanceImpl) {
+      PdxInstanceImpl pdxInstance = (PdxInstanceImpl) pdxInstanceArg;
+
+      storedPdxInfoType = pdxInfos.get(pdxInstance);
+
+      if (storedPdxInfoType == null) {
+        PdxType pdxTypeArg = pdxInstance.getPdxType();
+        storedPdxInfoType = new PdxInfoType(pdxTypeArg.getClassName(), 
+                                            pdxTypeArg.getTypeId());
+      } 
+    }
+    
+    return storedPdxInfoType; 
+  }
+  
+  /**
+   * Clears cached known Pdx Instance type Information.
+   */
+  //Note: used by PdxTypesIntrospectionResult
+  static void clearKnownPdxTypeInfo() {
+    pdxInfos.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxTypesIntrospectionResult.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxTypesIntrospectionResult.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxTypesIntrospectionResult.java
new file mode 100644
index 0000000..c5c13a5
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PdxTypesIntrospectionResult.java
@@ -0,0 +1,207 @@
+/*
+ * =========================================================================
+ * Copyright (c) 2002-2012 VMware, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. VMware products are covered by
+ * more patents listed at http://www.vmware.com/go/patents.
+ * All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.pdx.PdxInstance;
+
+/**
+ * Wraps the IntrospectionResult types for Pdx objects which are:
+ * <ol> All PdxSeriailzable objects which are available as PdxInstanceImpl
+ * <ol> or enum which are available as PdxInstance
+ * 
+ * Wrapped type is decided using the argument passed to the constructor 
+ * {@link #PdxTypesIntrospectionResult(Object, String)}.
+ * 
+ * @author abhishek
+ * @since 1.4 (GemFire 6.6.2)
+ */
+public class PdxTypesIntrospectionResult implements IntrospectionResult {
+
+  /* Methods handle to access the isEnum() methods of PdxInstance added in 6.6.2 */
+  private static final Method isEnumMethod;
+
+  /* Wrapped Pdx IntrospectionResult type */
+  private IntrospectionResult wrapped;
+  
+  static {
+    Method methodHandle = null;
+    try {
+      methodHandle = PdxInstance.class.getDeclaredMethod("isEnum", new Class[0]);
+    } catch (SecurityException e) {
+      methodHandle = null;
+    } catch (NoSuchMethodException e) {
+      methodHandle = null;
+    } finally {
+      isEnumMethod = methodHandle;
+    }
+  }
+
+  /**
+   * Creates a wrapper IntrospectionResult for Pdx Types.
+   * 
+   * @param pdxInstanceArg
+   *          PdxInstance object to be introspected.
+   * @param fieldTypeClass
+   *          FieldType fully qualified class name
+   * @throws PdxIntrospectionException
+   *           if isEnum() method exists & its invocation fails on the given
+   *           PdxInstance
+   */
+  //Note: used by PdxHelper over reflection
+  public PdxTypesIntrospectionResult(Object pdxInstanceArg, String fieldTypeClass) 
+    throws PdxIntrospectionException {
+    PdxInstance pdxInstance = null;
+    if (pdxInstanceArg instanceof PdxInstance) {
+      pdxInstance = (PdxInstance) pdxInstanceArg;
+
+      if (isEnum(pdxInstance)) {
+        wrapped = new PdxEnumIntrospectionResult(pdxInstance);
+//        System.out.println("PdxTypesIntrospectionResult.PdxTypesIntrospectionResult(): pdxInstance :: "+pdxInstance +", isEnum: true");
+      } else {
+        wrapped = new PdxIntrospectionResult(pdxInstance, fieldTypeClass);
+//        System.out.println("PdxTypesIntrospectionResult.PdxTypesIntrospectionResult(): pdxInstance :: "+pdxInstance +", isEnum: false");
+      }
+    } else {
+      throw new IllegalArgumentException("Only PdxInstance class is expected.");
+    }
+  }
+
+  /**
+   * Returns <code>true</code> if the given PdxInstance has isEnum() methods & 
+   * if it represents a non-PdxSerializable Java enum. Hence, for 
+   * GemFire >= 6.6 & < 6.6.2 this method should return <code>false</code>.
+   * 
+   * @param pdxInstance
+   *          Pdx Instance to be checked whether it's an enum
+   * @return true if the given PdxInstance has isEnum() methods & if it
+   *         represents a non-PdxSerializable Java enum.; false otherwise
+   * @throws PdxIntrospectionException
+   *           if isEnum method exists & its invocation fails on the given
+   *           PdxInstance
+   */
+  private boolean isEnum(PdxInstance pdxInstance) throws PdxIntrospectionException {
+    boolean isEnum = false;
+    
+    if (isEnumMethod != null) { // PdxInstance class has isEnum() i.e. it's 6.6.2 or later
+      try {
+        isEnum = (Boolean) isEnumMethod.invoke(pdxInstance, new Object[0]);
+      } catch (IllegalArgumentException e) {
+        isEnum = false;
+        throw new PdxIntrospectionException("Could not find PdxInstance.isEnum() in "+pdxInstance);
+      } catch (IllegalAccessException e) {
+        throw new PdxIntrospectionException("Could not find PdxInstance.isEnum() in "+pdxInstance);
+      } catch (InvocationTargetException e) {
+        throw new PdxIntrospectionException("Could not find PdxInstance.isEnum() in "+pdxInstance);
+      }
+    }
+    
+    return isEnum;
+  }
+
+  @Override
+  public Class<?> getColumnClass(int index) throws ColumnNotFoundException {
+    return wrapped.getColumnClass(index);
+  }
+
+  @Override
+  public Class<?> getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return wrapped.getColumnClass(tuple, index);
+  }
+
+  @Override
+  public int getColumnCount() {
+    return wrapped.getColumnCount();
+  }
+
+  @Override
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    return wrapped.getColumnIndex(name);
+  }
+
+  @Override
+  public String getColumnName(int index) throws ColumnNotFoundException {
+    return wrapped.getColumnName(index);
+  }
+
+  @Override
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    return wrapped.getColumnType(index);
+  }
+
+  @Override
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return wrapped.getColumnType(tuple, index);
+  }
+
+  @Override
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    return wrapped.getColumnValue(tuple, index);
+  }
+
+  @Override
+  public Class<?> getJavaType() {
+    return wrapped.getJavaType();
+  }
+
+  @Override
+  public String getJavaTypeName() {
+    return wrapped.getJavaTypeName();
+  }
+
+  @Override
+  public int getResultType() {
+    return wrapped.getResultType();
+  }
+
+  @Override
+  public boolean isCompatible(Object data) {
+    return wrapped.isCompatible(data);
+  }
+  
+  /**
+   * Create or return existing PdxInfoType for the given object. If given object
+   * - 'pdxInstanceArg' - is not of the type PdxInstance, it returns null.
+   * 
+   * @param pdxInstanceArg
+   *          PdxInstance for which PdxInfoType is to be retrieved
+   * @return new or existing PdxInfoType for the given object.
+   */
+  //Note: used by PdxHelper over reflection  
+  static PdxInfoType getPdxInfoType(Object pdxInstanceArg) {
+    //1. Check if it's a 'PdxInstanceImpl'. If yes, retrieve/return PdxInfoType for it 
+    PdxInfoType pdxInfoType = PdxIntrospectionResult.getPdxInfoType(pdxInstanceArg);
+    
+    //2. Check if it's a 'PdxInstance'. If yes, retrieve/return PdxInfoType for it.
+    if (pdxInfoType == null) {
+      pdxInfoType = PdxEnumIntrospectionResult.getPdxInfoType(pdxInstanceArg);
+    }
+    
+    return pdxInfoType;
+  }
+  
+  /**
+   * Clears cached known Pdx Instance type Information.
+   */
+  //Note: used by PdxHelper over reflection
+  static void clearKnownPdxTypeInfo() {
+    PdxIntrospectionResult.clearKnownPdxTypeInfo();
+    PdxEnumIntrospectionResult.clearKnownPdxTypeInfo();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PrimitiveTypeResultImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PrimitiveTypeResultImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PrimitiveTypeResultImpl.java
new file mode 100644
index 0000000..1ee0f7f
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/PrimitiveTypeResultImpl.java
@@ -0,0 +1,81 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+
+public class PrimitiveTypeResultImpl implements IntrospectionResult {
+  private static final int CONST_COLUMN_COUNT = 1;
+  public static final String CONST_COLUMN_NAME = "Result";
+  
+  private Class<?> type;
+  
+  public PrimitiveTypeResultImpl(Class<?> ty) {
+   this.type = ty; 
+  }
+  
+  public Class<?> getJavaType() {
+    return this.type;
+  }
+  
+  public int getResultType() {
+    return PRIMITIVE_TYPE_RESULT;
+  }
+  
+
+  public Class getColumnClass(int index) {
+    return this.type;
+  }
+  
+  public Class getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnClass(index);
+  }
+
+  public int getColumnCount() {
+    return CONST_COLUMN_COUNT;
+  }
+
+  public String getColumnName(int index) {
+    return CONST_COLUMN_NAME;
+  }
+  
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    if(CONST_COLUMN_NAME.equals(name))
+     return 0;
+    
+    throw new ColumnNotFoundException("Column not available for name :" + name);
+  }
+
+  public Object getColumnValue(Object tuple, int index) {
+    return tuple;
+  }
+
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    if(index < CONST_COLUMN_COUNT)
+      return PRIMITIVE_TYPE_COLUMN;
+    
+    throw new ColumnNotFoundException("Column not available for index :" + index);
+  }
+  
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+    return getColumnType(index);
+  }
+  
+  public String getJavaTypeName() {
+    Class<?> javaType = getJavaType();
+    
+    return javaType != null ? javaType.getName() : null;
+  }
+  
+  public boolean isCompatible(Object data) {
+    //checks for equality by reference not assignable. Using == assuming single 
+    //instance of a class
+    return data != null && getJavaType() == data.getClass();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ResultSetImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ResultSetImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ResultSetImpl.java
new file mode 100644
index 0000000..6e4efbc
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/ResultSetImpl.java
@@ -0,0 +1,114 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.gemstone.gemfire.cache.query.Struct;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ResultSet;
+
+public class ResultSetImpl implements ResultSet {
+
+  private Map<Object, IntrospectionResult> types;
+  private Collection<?>                    results;
+  
+  public ResultSetImpl(Map<Object, IntrospectionResult> typs, Collection<?> res) {
+    types = typs;
+    results = (res != null) ? res : new ArrayList();
+  }  
+  
+  public void close() {
+   if(this.results != null) {
+     this.results = null;
+   }
+   
+   if(this.types != null) {
+     this.types.clear();
+     this.types = null;    
+   }
+  }
+
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+
+    Object type = (tuple instanceof Struct) ? ((Struct) tuple).getStructType()
+        : tuple.getClass();
+
+    if (types.containsKey(type)) {
+      IntrospectionResult metaInfo = types.get(type);
+      return metaInfo.getColumnValue(tuple, index);
+    } 
+
+    throw new ColumnNotFoundException("Could not identify type :" + type);
+  }
+
+  
+  public IntrospectionResult[] getIntrospectionResult() {
+    return this.types.values().toArray(new IntrospectionResult[0]);
+  }
+
+
+  public Collection<?> getQueryResult() {
+    return this.results;
+  }
+
+
+  /**
+   * This method returns the subset of result of the executed query for a given
+   * introspection type.
+   * 
+   * @param metaInfo
+   *          IntrospectionResult type for which we require result
+   * @return subset of result of the query execution.
+   * @see ResultSet#getQueryResult(IntrospectionResult)
+   */
+  public Collection<?> getQueryResult(IntrospectionResult metaInfo) {
+    List result = new ArrayList();
+    result.addAll(getQueryResult());
+
+    if (metaInfo == null || metaInfo.getJavaType() == null) {
+      return result;
+    }
+
+    if(metaInfo.getResultType() == IntrospectionResult.STRUCT_TYPE_RESULT) {
+      //In case of Struct type of result, it is not possible to get different types of results.
+      //Hence we should return the complete results.  
+      return result;
+    } 
+
+    Iterator iter = result.iterator();
+
+    while (iter.hasNext()) {
+      Object obj = iter.next();
+      if ( (obj == null) || !metaInfo.isCompatible(obj)) {
+        iter.remove();
+      }
+    }
+
+    return result;
+  }
+
+
+  public boolean isEmpty() {
+    if(this.results != null)
+     return results.isEmpty();
+
+    return true; 
+  }
+  
+  @Override
+  public String toString() {
+    return String.valueOf(results);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/StructTypeResultImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/StructTypeResultImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/StructTypeResultImpl.java
new file mode 100644
index 0000000..d3bcff5
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/StructTypeResultImpl.java
@@ -0,0 +1,213 @@
+/*=========================================================================
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.internal;
+
+import java.util.Collection;
+import java.util.Map;
+
+import com.gemstone.gemfire.cache.query.Struct;
+import com.gemstone.gemfire.cache.query.types.StructType;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnValueNotAvailableException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionRepository;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil;
+
+
+/**
+ * This class provides functionality to introspect the GemFire Struct type of
+ * results and convert them into standard Introspection result.
+ *
+ * @author Hrishi
+ **/
+public class StructTypeResultImpl implements IntrospectionResult {
+
+  private StructType type_;
+
+  public StructTypeResultImpl(StructType ty) {
+    type_ = ty;
+  }
+
+  public Class<?> getJavaType() {
+    return StructType.class;
+  }
+  
+  public int getResultType() {
+    return STRUCT_TYPE_RESULT;
+  }
+  
+  public Class getColumnClass(int index) throws ColumnNotFoundException {
+    if (this.type_.getFieldTypes().length > index) {
+      //Right now GemFire does not return specific type at all. Hence the hard-coding.
+      //ObjectType objType = this.type_.getFieldTypes()[index];
+      //return objType.getSimpleClassName();
+      return Object.class;
+    }
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+  
+  public Class getColumnClass(Object tuple, int index)
+      throws ColumnNotFoundException {
+    
+    if (!(tuple instanceof Struct)) {
+      throw new ColumnNotFoundException("The parameter should be of type Struct.");
+    }
+    
+    Struct val = (Struct)tuple;
+    int count = this.type_.getFieldNames().length;
+        
+    if(count > index) {
+      Object result = val.getFieldValues()[index];
+      Class type = (result != null) ? result.getClass() : java.lang.Object.class;
+      
+      // In case of Struct type of results, the type of the field can change depending upon the
+      //actual tuple. This information is not available in the StructType object. Hence make sure
+      //we understand the all the types properly.
+      try {
+        IntrospectionRepository.singleton().introspectType(type);
+      }
+      catch (IntrospectionException e) {
+        throw new ColumnNotFoundException(e);              
+      }     
+      
+      return  type;    
+    }
+    
+    throw new ColumnNotFoundException("The column for this index could not be found"); 
+  }
+
+  public int getColumnCount() {
+    return this.type_.getFieldNames().length;
+  }
+
+  public String getColumnName(int index) throws ColumnNotFoundException {
+    if (this.type_.getFieldNames().length > index) {
+      return this.type_.getFieldNames()[index];
+    }
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+
+  public int getColumnIndex(String name) throws ColumnNotFoundException {
+    return this.type_.getFieldIndex(name);
+  }
+
+  public int getColumnType(int index) throws ColumnNotFoundException {
+    int count = this.type_.getFieldNames().length;
+
+    if (count > index) {
+      return UNKNOWN_TYPE_COLUMN;
+    }
+
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+  
+  public int getColumnType(Object tuple, int index)
+      throws ColumnNotFoundException {
+    
+    if (!(tuple instanceof Struct)) {
+      throw new ColumnNotFoundException("The parameter should be of type Struct.");
+    }
+    
+    Struct val = (Struct)tuple;
+    int count = this.type_.getFieldNames().length;
+    
+    if (count > index) {
+      Object result = val.getFieldValues()[index];
+      if(result != null) {
+        Class type = result.getClass();        
+        if (QueryUtil.isPrimitiveType(type))
+          return IntrospectionResult.PRIMITIVE_TYPE_COLUMN;
+        else if (QueryUtil.isCompositeType(type))
+          return IntrospectionResult.COMPOSITE_TYPE_COLUMN;
+        else if (QueryUtil.isCollectionType(type))
+          return IntrospectionResult.COLLECTION_TYPE_COLUMN;
+        else if (QueryUtil.isMapType(type))
+          return IntrospectionResult.MAP_TYPE_COLUMN;
+        else if (QueryUtil.isPdxInstanceType(type))
+          return IntrospectionResult.PDX_TYPE_COLUMN;  
+      }
+      
+      return IntrospectionResult.UNKNOWN_TYPE_COLUMN;
+      
+    }
+        
+    throw new ColumnNotFoundException("The column for this index could not be found");
+  }
+
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    if (!(tuple instanceof Struct)) {
+      throw new ColumnValueNotAvailableException(
+          "The parameter should be of type Struct.");
+    }
+
+    Struct struct = (Struct) tuple;
+    if (struct.getFieldValues().length > index) {
+      int type = getColumnType(tuple, index);
+      
+      switch(type) {
+        case COLLECTION_TYPE_COLUMN : {
+          Class javaType = getColumnClass(tuple, index);
+          
+          if(javaType.isArray()) {
+            try {
+              return QueryUtil.introspectArrayType(javaType, struct.getFieldValues()[index]);
+            }
+            catch (IntrospectionException e) {
+              throw new ColumnValueNotAvailableException(e);
+            }
+          }
+          
+          Collection result = (Collection)struct.getFieldValues()[index];
+
+          try {
+            return QueryUtil.introspectCollectionObject(result);
+          } catch (QueryExecutionException e) {
+            throw new ColumnValueNotAvailableException(e);
+          }          
+        }
+        
+        case MAP_TYPE_COLUMN : {
+          Map result = (Map)struct.getFieldValues()[index];
+          Collection temp = null;
+          if(result != null)
+            temp = result.entrySet();
+
+          try {
+            return QueryUtil.introspectCollectionObject(temp);
+          } catch (QueryExecutionException e) {
+            throw new ColumnValueNotAvailableException(e);
+          }  
+        }
+        
+        default : {
+          return struct.getFieldValues()[index];
+          
+        }
+      }
+    }
+
+    throw new ColumnNotFoundException("Column not available for index :"
+        + index);
+  }
+  
+  public String getJavaTypeName() {
+    Class<?> javaType = getJavaType();
+    
+    return javaType != null ? javaType.getName() : null;
+  }
+
+  public boolean isCompatible(Object data) {
+    //checks for equality by reference not assignable. Using == assuming single 
+    //instance of a class
+    return data != null && getJavaType() == data.getClass();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/databrowser.properties
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/databrowser.properties b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/databrowser.properties
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/databrowser.properties
@@ -0,0 +1 @@
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/CacheServer.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/CacheServer.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/CacheServer.ico
new file mode 100644
index 0000000..73c078a
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/CacheServer.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSDisabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSDisabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSDisabled.PNG
new file mode 100644
index 0000000..b8f6e69
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSDisabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSEnabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSEnabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSEnabled.PNG
new file mode 100644
index 0000000..d7a8f0d
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ConnectToDSEnabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember.ico
new file mode 100644
index 0000000..57b49e7
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember01.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember01.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember01.ico
new file mode 100644
index 0000000..6c36508
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember01.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember02.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember02.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember02.ico
new file mode 100644
index 0000000..57b49e7
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember02.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember03.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember03.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember03.ico
new file mode 100644
index 0000000..16ba975
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember03.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember2.png
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember2.png b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember2.png
new file mode 100644
index 0000000..642026e
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DSMember2.png differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSDisabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSDisabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSDisabled.PNG
new file mode 100644
index 0000000..0462189
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSDisabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSEnabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSEnabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSEnabled.PNG
new file mode 100644
index 0000000..cae7083
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/DisconnectFromDSEnabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryDisabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryDisabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryDisabled.PNG
new file mode 100644
index 0000000..c45f1cc
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryDisabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryEnabled.PNG
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryEnabled.PNG b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryEnabled.PNG
new file mode 100644
index 0000000..ac6dd75
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecuteQueryEnabled.PNG differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTab.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTab.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTab.ico
new file mode 100644
index 0000000..ff07a26
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTab.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTabIcon.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTabIcon.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTabIcon.ico
new file mode 100644
index 0000000..ff07a26
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/ExecutionPlanTabIcon.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1709e627/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Messages.ico
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Messages.ico b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Messages.ico
new file mode 100644
index 0000000..c2393ed
Binary files /dev/null and b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/resources/icons/Messages.ico differ



Mime
View raw message