svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / operation / GeometryOperationContext.java @ 40435
History | View | Annotate | Download (1.01 KB)
1 | 40435 | jjdelcerro | package org.gvsig.fmap.geom.operation; |
---|---|---|---|
2 | |||
3 | import java.util.HashMap; |
||
4 | import java.util.Map; |
||
5 | |||
6 | /**
|
||
7 | * This class is a default parameter container for geometry operation.<br>
|
||
8 | *
|
||
9 | * Normally every GeometryOperation will extend this class and identify
|
||
10 | * its parameters publicly with getters/setters
|
||
11 | *
|
||
12 | * For those operations that need high performance, parameters should be declared as class
|
||
13 | * members instead of using the setAttribute/getAttribute mechanism. This way you avoid a hash
|
||
14 | * and a cast operation.
|
||
15 | *
|
||
16 | * @author jyarza
|
||
17 | *
|
||
18 | */
|
||
19 | public class GeometryOperationContext { |
||
20 | |||
21 | private Map ctx = new HashMap(); |
||
22 | |||
23 | /**
|
||
24 | * Returns an attribute given its name.
|
||
25 | * If it does not exist returns <code>null</code>
|
||
26 | * @param name
|
||
27 | * @return attribute
|
||
28 | */
|
||
29 | public Object getAttribute(String name) { |
||
30 | return ctx.get(name.toLowerCase());
|
||
31 | } |
||
32 | |||
33 | /**
|
||
34 | * Sets an attribute
|
||
35 | * @param name
|
||
36 | * @param value
|
||
37 | */
|
||
38 | public GeometryOperationContext setAttribute(String name, Object value) { |
||
39 | ctx.put(name.toLowerCase(), value); |
||
40 | return this; |
||
41 | } |
||
42 | |||
43 | } |