Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Examples/SDO/BasicAPI"
m (→Load) |
(→XMLHelper - Handle XML Data as DataObjects) |
||
Line 53: | Line 53: | ||
</source> | </source> | ||
− | === | + | ===Save=== |
+ | Save methods are used to convert DataObjects to XML. | ||
<source lang="java"> | <source lang="java"> | ||
− | + | xmlHelper.save(customerDO, "http://www.example.org/customer-example", "customer", System.out); | |
− | + | ||
</source> | </source> | ||
− | + | The XML root information can also be encapsulated in an XMLDocument object. | |
− | + | ||
<source lang="java"> | <source lang="java"> | ||
+ | XMLDocument xmlDocument = xmlHelper.createDocument(customerDO, "http://www.example.org/customer-example", "customer"); | ||
xmlHelper.save(xmlDocument, System.out, null); | xmlHelper.save(xmlDocument, System.out, null); | ||
− | |||
− | |||
− | |||
</source> | </source> | ||
Revision as of 16:35, 25 February 2009
Contents
HelperContext
TypeHelper - Access Metadata
TypeHelper provides a convenient means of handling SDO metadata.
TypeHelper typeHelper = helperContext.getTypeHelper();
Define Types
Get Types
Define Open Content Properties
Get Open Content Properties
XSDHelper - Access XML Schema Metadata
XSDHelper provides a convenient means of handling XML Schema metadata.
XSDHelper xsdHelper = helperContext.getXSDHelper();
Define
Generate
DataFactory - Create DataObjects
DataFactory provides a convenient means of creating SDO DataObjects.
DataFactory dataFactory = helperContext.getDataFactory();
Create
DataHelper - Convert Simple Values
DataHelper provides a convenient means of converting SDO data type values.
DataHelper dataHelper = helperContext.getDataHelper();
XMLHelper - Handle XML Data as DataObjects
XMLHelper provides a convenient means of handling XML data as DataObjects.
XMLHelper xmlHelper = helperContext.getXMLHelper();
Load
Load methods are used to unmarshal XML into DataObjects.
FileInputStream xmlInputStream = new FileInputStream("customer.xml"); XMLDocument xmlDocument = xmlHelper.load(xmlInputStream); DataObject customerDO = xmlDocument.getRootObject;
Save
Save methods are used to convert DataObjects to XML.
xmlHelper.save(customerDO, "http://www.example.org/customer-example", "customer", System.out);
The XML root information can also be encapsulated in an XMLDocument object.
XMLDocument xmlDocument = xmlHelper.createDocument(customerDO, "http://www.example.org/customer-example", "customer"); xmlHelper.save(xmlDocument, System.out, null);
CopyHelper - Create Copies of DataObjects
CopyHelper provides a convenient means of copying DataObjects.
CopyHelper copyHelper = helperContext.getCopyHelper();
Shallow Copy
Create a new DataObject containing the values of all dataType=true properties (excluding the ChangeSummary property).
DataObject shallowCopy = copyHelper.copyShallow(dataObject);
Deep Copy
Create a copy of the entire tree.
DataObject deepCopy = copyHelper.copy(dataObject);
EqualityHelper - Compare DataObjects
EqualityHelper provides a convenient means of comparing DataObjects.
EqualityHelper equalityHelper = helperContext.getEqualityHelper();
Shallow Equal
Two DataObjects are considered shallow equal if the data objects are of the same type and all the values of all dataType=true properties (excluding the ChangeSummary property) are equal.
boolean isShallowEqual = equalityHelper.equalShallow(dataObject1, dataObject2);
Deep Equal
Two DataObjects are considered deep equal if the data objects and the trees that they belong to are both equal.
boolean isDeepEqual = equalityHelper.equal(dataObject1, dataObject2);