Revision 561 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/scripting/lib/gvsig_2_3_0/feature.py
feature.py | ||
---|---|---|
1 | 1 |
|
2 | 2 |
|
3 | 3 |
from org.gvsig.fmap.dal.feature.impl import DefaultFeature as JFeature |
4 |
from java.lang import RuntimeException |
|
4 |
from java.lang import RuntimeException, Throwable
|
|
5 | 5 |
|
6 | 6 |
def _geometry(self): |
7 | 7 |
return self.getDefaultGeometry() |
8 |
|
|
8 |
|
|
9 | 9 |
def _getValues(self): |
10 | 10 |
items = dict() |
11 | 11 |
for name,value in self.iteritems(): |
12 | 12 |
items[name] = value |
13 |
return items
|
|
13 |
return items |
|
14 | 14 |
|
15 | 15 |
def _edit(self): |
16 | 16 |
raise Exception("Deprecated method, use import gvSIG_2_0_0 for compatibilitty with gvSIG 2.0.0 or use getEditable method") |
... | ... | |
20 | 20 |
|
21 | 21 |
def _getattr(self,attributeName): |
22 | 22 |
# FIX console error when try to introspect feature object |
23 |
if name in ('__methods__'):
|
|
23 |
if attributeName in ('__methods__'):
|
|
24 | 24 |
return dict() |
25 |
elif name in ('__members__'):
|
|
25 |
elif attributeName in ('__members__'):
|
|
26 | 26 |
return self.getValues().keys() |
27 |
elif name == '__dict__':
|
|
28 |
return self.getValues()
|
|
29 |
|
|
27 |
elif attributeName == '__dict__':
|
|
28 |
return self.getValues() |
|
29 |
|
|
30 | 30 |
try: |
31 |
v = getattr(self, attributeName, None) |
|
32 |
if v == None: |
|
33 |
v = self.get(attributeName) |
|
31 |
v = self.get(attributeName) |
|
34 | 32 |
return v |
35 | 33 |
except Throwable, ex: |
36 |
raise RuntimeException("Can't access to attribute %s of feature (%s)" % (attributeName, str(ex)))
|
|
34 |
raise RuntimeException("Can't access to attribute %s of feature (%s)" % (attributeName, str(ex))) |
|
37 | 35 |
|
38 | 36 |
def _call(self): |
39 | 37 |
return self |
... | ... | |
47 | 45 |
name = attr.getName() |
48 | 46 |
value = self.get(attr.getName()) |
49 | 47 |
yield name,value |
50 |
|
|
48 |
|
|
51 | 49 |
def _itervalues(self): |
52 | 50 |
descriptor = self.getType() |
53 | 51 |
for attr in descriptor.getAttributeDescriptors(): |
54 | 52 |
name = attr.getName() |
55 | 53 |
value = self.get(attr.getName()) |
56 | 54 |
yield value |
57 |
|
|
55 |
|
|
58 | 56 |
def _iterkeys(self): |
59 | 57 |
descriptor = self.getType() |
60 | 58 |
for attr in descriptor.getAttributeDescriptors(): |
61 | 59 |
name = attr.getName() |
62 | 60 |
yield name |
63 |
|
|
64 | 61 |
|
62 |
|
|
65 | 63 |
# |
66 | 64 |
# Inject new methods in the class JFeature |
67 | 65 |
# |
Also available in: Unified diff