1. Home
  2. Programming
  3. EIDR Java/.NET SDKs
  4. Supporting Classes in the SDK

Supporting Classes in the SDK

Connection Classes

The EIDRConnection class manages information needed to construct HTTP calls from the SDK, including the identification and authentication information necessary for a successful Registry request.

Response Classes

The SDK response classes are defined in org.eidr.sdk.model, which contains the Response parent class. The following classes are derived from org.eidr.sdk.model.Response:

  • Responses to Resolution requests
    • AllSelfDefinedInfoResponse
    • FullObjectInfoResponse
    • KernelMetadataResponse
    • ProvenanceInfoResponse
    • SimpleInfoResponse
  • Responses to Party requests
    • PartyQueryResponse
    • PartyResolutionResponseType
  • Responses to Video Service Requests
    • ServiceQueryResponse
    • ServiceResolutionResponseType

SDK Utility Classes

Schema Classes

Java

For the Java SDK, the schema classes are:

  • Classes and constants generated from the DOI schemas:
    • org.doi._2010.doischema
    • org.doi._2010.iso3166a2
  • Classes and constants from the MovieLabs Common Metadata schema:
    • com.movielabs.schema.md.v2_1.md
  • Classes and constants derived from the EIDR schemas:
    • org.eidr.schema

For example, the XML complex type requestType is defined as RequestType in org.eidr.schema.RequestType.java.[1]

.NET

In general, object names and methods in .NET mirror their corresponding Java SDK entities, except for the use of Properties in the place of java’s getter and setter methods, and the use of object arrays to store some child objects.

All the schema classes are in the org.eidr.schema namespace defined in EidrSchema.cs. For example, the XML complex type requestType mentioned above is defined as the class responseType in the class org.eidr.schema.requestType in EidrSchema.cs.

.NET model objects derived from the XML schema may have slight capitalization variations or appended qualifiers that Java does not.  For example, the schema’s eidr:statusType enumeration is named StatusTypes in Java, but statusTypeType in .NET.

Field Access

Java

Use the JAXB bindings to access the fields. In general, each XML type is represented as a class, with one or two methods representing each element and attribute:

  • For fields with cardinality 0 or 1, use the getter to read the field and the setter to write the field.
  • For fields that can have multiple instances, the single function returns a live List<> object containing the values.  Use the List<>’s get() method to read values which can then be modified.  It is also possible to use the add(), clear(), remove(), etc. methods on the List<> for more complex modifications.

NOTE: It is important to check for null values and List<> objects whose size() method returns 0.  See the source code for FlattenTool included with the SDK. It reads every possible field in the registry.

.NET

In the .NET model implementation, an object’s children are represented as an object array wherever the schema defines an xs:choice of one or more xs:sequence. In these instances, the model-equivalent parent object has an Items member (array) that contains a sequence of child objects, and a corresponding ItemsElementName member. ItemsElementName is an array that contains a list of enumerated type elements declaring the type of object that is in the Items array at the same index.

For example, an XML <Response> tag may contain <RequestStatus> and <RequestStatusResults> elements.  The .NET model instance of responseType.Items will be an object array containing [requestStatusType, requestStatusResultsType] instances and a responseType.ItemElementName ResponseChoiceType array containing [ResponseChoiceType.RequestStatus, ResponseChoiceType.RequestStatusResults] enumerations.

To assist in extracting children from models objects following this implementation pattern, there are two utility classes: org.eidr.sdk.utils.ObjResponseUtils and org.eidr.sdk.utils.ObjMetadataUtils.

For example, to extract the RequestStatus element from ResponseType, simply use: ObjResponseUtils.GetFirstRequestStatus(responseObj);

The “First” in the method name above refers to the fact that only the first requestStatusType object in the object array will be returned.  Though the schema only allows one RequestStatus child element of ResponseType, the model implementation allows several.  The “First” distinction is made because there are some objects where multiple instances are indeed permitted by the schema.

For example, ObjResponseUtils.GetFirstRequestStatusResultsAllOperationStatus(responseObj) returns an array of operationStatusType children of the RequestStatusResults member of a <Response> object.

If fields are added to or removed from these collections, the Items and ItemsElementName arrays themselves should be reconstructed to have the correct values and count.

Serialization Classes

EidrXMLObjUtils class (java)

The Java SDK contains an org.eidr.sdk.utils.EidrXMLObjUtils class that provides methods for serializing objects into XML. This class is primarily a helper function for the SDK, but can be a used to convert various SDK classes to XML and back again. This is not meant to be a generic object for XML conversion.

To convert XML to an object, use:

public static Object XMLAndTypeToObj( String xml, Class<?> expectedType, int classtype );

To convert an object to XML use:

public static String objAndTagToXML(java.lang.Object obj, String tag, String nsUri, String nsPrefix, int classtype)

tag is the name of the root XML Element for the object. Namespace strings are defined in org.eidr.sdk.conf.Namespaces. The namespace prefix is generally “” (the empty string), since the EIDR namespace is unqualified. For example, if the object is SimpleInfoType (the return type for queries):

String xml = EidrXMLObjUtils.objAndTagToXML(simple, "SimpleMetadata", Namespaces.EIDR_URI, "", EidrXMLObjUtils.EIDR_Obj_SimpleInfoType);

SerializeUtils class (.net)

The .NET SDK contains an org.eidr.sdk.utils.EidrXMLObjUtils class that provides methods for serializing objects into XML similar to the java implementation.

Converters

BaseInfoConverter class

The org.eidr.sdk.utils.BaseInfoConverter class contains methods that convert between CreationFullInfo and CreationSelfDefined objects, in addition to utility methods for cloning an AlternateIDType and PersonNameType.

Formatters

XmlFormatter class

The org.eidr.sdk.utils.xml.XmlFormatter class contains methods that convert raw XML into a human-readable format.

Type Utilities

The org.eidr.sdk.utils.TypeUtils class contains methods that determine if instances of FullObjectInfoType or SimpleInfoType are root objects, or if an Object has a particular relationship. See the source code for FlattenTool included with the SDK for examples.


[1] Technically, path names are represented using subdirectory notation (org/eidr/schema/ResponseType.java), while class names are represented using dot notation (org.eidr.schema.ResponseType.java). For visual consistency, we use dot notation and leave it to the reader to switch to subdirectory notation when necessary.

Updated on April 11, 2021

Was this article helpful?

Related Articles