

from org.gvsig.fmap.dal.feature.impl import DefaultFeatureType as JFeatureType


def _getitem(self, name):
  return self.getAttributeDescriptor(name)

def _iter(self):
  return iter(self.getAttributeDescriptors())
  
def _len(self):
  return len(self.getAttributeDescriptors())
  

def _get(self, name, default=None):
  x = self.getAttributeDescriptor(name)
  if x == None:
    return default
  return x

def _getAttrNames(self):
  if not self.getAttributeDescriptors():
    return None
      
  return [attr.getName() for attr in self.getAttributeDescriptors()]
  
def _call(self):
  return self    
    

#
# Inject new methods in the class JFeatureType
#
JFeatureType.__call__ = _call
JFeatureType.__iter__ = _iter
JFeatureType.__len__ = _len
JFeatureType.get = _get
JFeatureType.getAttrNames = _getAttrNames


