IT. Expert System.


Reflecting on Service Data Objects

Reflecting on Service Data Objects

SDOs have a knowledge of the structure they have been created to represent (the model). For example, a Company SDO created using the Company XML schema above would only be permitted to contain DepartmentType data objects which in turn could only contain EmployeeType data objects.

Sometimes it is useful to be able to access this model information at runtime. For example, this could be used to automatically generate a user interface for populating a data object. The model information is accessed using reflection.

Example #1 Reflecting on a Data Object

The following example shows how we can reflect on an empty Employee data object.

// Create the employee data object (e.g. from an XML Data Access Service)
$employee = ...;
$reflection = new SDO_Model_ReflectionDataObject($employee);

The above example will output:

 object(SDO_Model_ReflectionDataObject)#4 { - ROOT OBJECT - Type { companyNS:EmployeeType[3] { commonj.sdo:String $name; commonj.sdo:String $SN; commonj.sdo:Boolean $manager; } } 

Using print on the SDO_Model_ReflectionDataObject writes out the data object's model. We can see from the output how the type companyNS:EmployeeType has three properties and we can see the names of the properties along with their types. Note, the primitive types are listed as SDO types (e.g. commonj.sdo namespace, String type). It is worth noting that this is the SDO model and when these are surfaced to an application they can be treated as the PHP equivalent types (e.g. string and boolean).

Example #2 Accessing the type information

We can query the type information of a data object using reflection. The following example checks the type corresponds to a data object rather than a primitive and then iterates through the properties of the type, writing out the name of each property ($type and $property are SDO_Model_Type and SDO_Model_Property objects, respectively).

// Create the employee data object (e.g. from an XML Data Access Service)
$employee = ...;
$reflection = new SDO_Model_ReflectionDataObject($employee);
$type $reflection->getType();
    if (! 
$type->isDataType()) {
        foreach (
$type->getProperties() as $property) {
$property->getName() . "\n";

The above example will output:

 name SN manager 


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 417 / 158670645. Delta: 0.04421 с