18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

JAVA APPLICATION PROGRAMMING INTERFACE<br />

with an interface. Objects use type inheritance; the code associated with an<br />

interface comes from the class implementation.<br />

This model shares some features of the Java interface model. An interface in the<br />

Java language is a specification of methods that an object declares it implements.<br />

A Java interface does not include instance variables or implementation code.<br />

The <strong>ArcGIS</strong> API for Java has two objects for every ArcObjects interface: a<br />

corresponding interface and an interface proxy class. The interface is named in the<br />

ArcObjects style, prefixed with an I. The interface proxy class appends the term<br />

proxy to the name. An example of this mapping is provided below:<br />

ArcObjects Interface<br />

interface IArea : IUnknown<br />

Java Representation<br />

public interface IArea{}<br />

public class IAreaProxy implements IArea{}<br />

The proxy classes are used internally by the <strong>ArcGIS</strong> API for Java to provide<br />

implementation to respective interfaces. An application developer should never<br />

use the default constructor of these classes as it holds no implementation.<br />

ArcObjects requires developers to go through an interface to access objects. The<br />

Java language does not use this model; subsequently, the <strong>ArcGIS</strong> API for Java has<br />

two ways of accessing objects—by interface or by class.<br />

/* use the class implementing com.esri.arcgis.geometry.Point();<br />

IPoint iPoint = new Point();<br />

/* access object through class */<br />

Point cPoint = new Point();<br />

You cannot access objects through the default interface proxy class:<br />

IPointProxy proxyPoint = new IPointProxy(); // incorrect usage<br />

This will be discussed in more depth in subsequent sections.<br />

ArcObjects interfaces are immutable and subsequently never versioned. An<br />

interface is never changed once it is defined and published. When an interface<br />

requires additional methods, the API defines a new interface by the same name<br />

with a version number appended to it as described in the following table.<br />

ArcObjects Interface<br />

interface IGeometry : IUnknown<br />

interface IGeometry2 : IGeometry<br />

interface IGeometry3 : IGeometry2<br />

interface IGeometry4 : IGeometry3<br />

Java Representation<br />

public interface IGeometry{}<br />

public interface IGeometry2 extends IGeometry{}<br />

public interface IGeometry3 extends IGeometry2{}<br />

public interface IGeometry4 extends IGeometry3{}<br />

Classes<br />

In the ArcObjects model, classes provide the implementation of the defined<br />

interfaces. ArcObjects provides three types of classes: abstract classes, classes, and<br />

coclasses. These class types can be distinguished through the object model diagrams<br />

provided in <strong>ArcGIS</strong> <strong>Developer</strong> Help. It is important to be familiar with them<br />

before you begin to use the three class types.<br />

In ArcObjects, an abstract class cannot be used to create new objects and are<br />

absent in the <strong>ArcGIS</strong> API for Java. These classes are specifications in ArcObjects<br />

for instances of subclasses through type inheritance. An abstract class enumerates<br />

what interfaces are to be implemented by the implementing subclass but does not<br />

186 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!