25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

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.

Methods<br />

6.4 Method Language<br />

You have the choice of implementation language when creating a method within <strong>Caché</strong>.<br />

Currently, there are three options: “Cache” (<strong>Caché</strong> ObjectScript), “Basic” , and “Java” .<br />

By default, a method uses the language specified by its class' Language keyword. You can<br />

override this on a method-by-method basis using the method's Language keyword:<br />

Class MyApp.Test {<br />

/// A Basic method<br />

Method TestB() As %Integer [ Language = basic]<br />

{<br />

'This is Basic<br />

Print "This is a test"<br />

Return 1<br />

}<br />

/// A Cache ObjectScript method<br />

Method TestC() As %Integer [ Language = cache]<br />

{<br />

// This is Cache ObjectScript<br />

Write "This is a test"<br />

Quit 1<br />

}<br />

}<br />

Within a class, it is possible to have methods implemented in different languages. All methods<br />

interoperate regardless of implementation language.<br />

<strong>Caché</strong> ObjectScript and Basic methods are compiled into executable <strong>Caché</strong> code; Java<br />

methods are treated differently. When you create a Java representation of a class (using the<br />

<strong>Caché</strong> Java Binding), all of its Java methods are generated directly within the Java source.<br />

This means that all Java methods run within a native JVM and have access to the complete<br />

Java environment.<br />

6.5 Method Keywords<br />

You can modify a method definition through the use of one or more method keywords. Each<br />

keyword is optional and has a default value if not explicitly specified.<br />

The major method keywords are:<br />

40 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>

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

Saved successfully!

Ooh no, something went wrong!