Java Doc for Binding.java in  » GIS » GeoTools-2.4.1 » org » geotools » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.xml 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.geotools.xml.Binding

Binding
public interface Binding (Code)
A specialized handler for a specific type in an xml schema.

Bindings have the following responsibilities.

  • Parsing components from an instance document (elements and attributes) into model objects
  • Encoding model objects as xml components
  • Sorting themselves in case multiple bindings target the same type

Type Binding

Binding objects correspond to xml schema types. A binding declares it target type by advertising the qualified name of the type it binds to. For instance, the following strategy binds itself to type xsd:string.

 
 class XSDStringStrategy {
 QName getTarget() {
 return new QName("http://www.w3.org/2001/XMLSchema","string");
 }
 ...
 
 

The upshot is that whenever an element or attribute is encountered in an instance document that is of type xsd:string, this binding will be used to turn the string into an object representation.

And on the other side of coin, when an instanceof String is encountered when serializing an object model, the binding will be used to encode the string as xml.

Inheritance

XML Schema supports Inheritance. As a concrete example, consider the simple xml schema simple types decimal and integer.

 
 <xs:simpleType name="decimal" id="decimal">
 <xs:annotation>
 <xs:appinfo>
 <hfp:hasFacet name="totalDigits"/>
 <hfp:hasFacet name="fractionDigits"/>
 <hfp:hasFacet name="pattern"/>
 <hfp:hasFacet name="whiteSpace"/>
 <hfp:hasFacet name="enumeration"/>
 <hfp:hasFacet name="maxInclusive"/>
 <hfp:hasFacet name="maxExclusive"/>
 <hfp:hasFacet name="minInclusive"/>
 <hfp:hasFacet name="minExclusive"/>
 <hfp:hasProperty name="ordered" value="total"/>
 <hfp:hasProperty name="bounded" value="false"/>
 <hfp:hasProperty name="cardinality" value="countably infinite"/>
 <hfp:hasProperty name="numeric" value="true"/>
 </xs:appinfo>
 <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#decimal"/>
 </xs:annotation>
 <xs:restriction base="xs:anySimpleType">
 <xs:whiteSpace fixed="true" value="collapse" id="decimal.whiteSpace"/>
 </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="integer" id="integer">
 <xs:annotation>
 <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#integer"/>
 </xs:annotation>
 <xs:restriction base="xs:decimal">
 <xs:fractionDigits fixed="true" value="0" id="integer.fractionDigits"/>
 <xs:pattern value="[\-+]?[0-9]+"/>
 </xs:restriction>
 </xs:simpleType>
 
 

The above types define an inheiretance hierarcy. To model this relationship among the corresponding binding objects, an execution mode must be declared by each binding. The execution mode specifies wether a binding should be executed before, after, or totally override the binding for a direct parent.

 
 class DecimalBinding implements Binding {
 ...
 int getExecutionMode() {
 return OVERRIDE;
 }
 ...
 }
 class IntegerBinding implemnts Binding {
 ...
 int getExecutionMode() {
 return AFTER;
 }
 ...
 }
 
 

In the above example, the decimal bidning declares its execution mode to be override. This means that no bindings for any of the base types of decimal will be executed. The integer binding declares its execution mode as AFTER. This means that the integer binding will be executed after the decimal strategy.

Context

Bindings are executed within a particular context or container. A binding can use its context to obtain objects that it depends on to perform a parse or encoding. A binding can declare a dependency by simply adding it to its constructor. This is known as Constructor Injection. When the binding is created it is injected with all dependencies. The context is responsible for satisfying the dependencies of the binding. As an example consider the following complex type defintion.
 
 <xsd:complexType name="collection">
 <xsd:sequence>
 <xsd:element name="item" type="xsd:any" minOccurs="0" maxOccurs="unbounded"/>
 </xsd:sequence>
 </xsd:complexType>
 
 
The associated binding must turn instances of this type into objects of type java.util.Collection . However, the question remains what concrete subclass of Collection to use. And perhaps we need this type to vary in different situations. The solution is to take the decision out of the hands of this binding, and into the hands of someone else. To acheive this the collection binding adds a dependency of type Collection.
 
 class CollectionStrategy implements ComplexBinding {
 Collection collection;
 
 CollectionStrategy(Collection collection) {
 this.collection = collection;
 }
 
 QName getTarget() {
 return new QName("http://org/geotools/","collection");
 }
 int getExecutionMode() {
 return OVERRIDE;
 }
 
 Object parse(Element instance, Node[] children, Node[] atts, Object value)
 throws Exception {
 for (int i = 0; i < children.length; i++) {
 collection.add(children[i].getValue());
 }
 return collection;
 }
 
 }
 
 

Conflict resolution

In some cases multiple bindings are targetting the same java class. This happens, for example, in GML3 where MultiPolygon is associated to two different elements, gml:MultiPolygon and gml:MultiSurface (the former being deprecated and kept for backwards compatibility).

In such occasions, binding implementations must implement the Comparable interface, in case of doubt the bindings associated to a specific class will be sorted and the first element in the resulting List will be used.
author:
   Justin Deoliveira,Refractions Research Inc.,jdeolive@refractions.net



Field Summary
final static  intAFTER
    
final static  intBEFORE
    
final static  intOVERRIDE
     Specifies that a binding should totally override the execution of its direct parent.


Method Summary
 intgetExecutionMode()
    
 QNamegetTarget()
    
 ClassgetType()
    

Field Detail
AFTER
final static int AFTER(Code)
Specifies that a binding should be executed after its direct parent



BEFORE
final static int BEFORE(Code)
Specifes that a binding should be executed before its direct parent.d



OVERRIDE
final static int OVERRIDE(Code)
Specifies that a binding should totally override the execution of its direct parent.





Method Detail
getExecutionMode
int getExecutionMode()(Code)
The execution mode of the binding, one of the constants AFTER,BEFORE, or OVERRIDE.
See Also:   Binding.AFTER
See Also:   Binding.BEFORE
See Also:   Binding.OVERRIDE



getTarget
QName getTarget()(Code)
The qualified name of the target for the binding.



getType
Class getType()(Code)
The java type this binding maps to.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.