org.oclc.da.gdfr.registryprototype.pvt
Class BasicStructuredObject

java.lang.Object
  extended by org.oclc.da.gdfr.registryprototype.pvt.BasicStructuredObject
All Implemented Interfaces:
java.lang.Cloneable, AdminData, CollectionItem, Content, DataObject, StructuredDataObject

public class BasicStructuredObject
extends java.lang.Object
implements CollectionItem, StructuredDataObject, AdminData, Content


Constructor Summary
BasicStructuredObject(java.lang.String bytes, java.util.Properties xPaths)
          Constructor
 
Method Summary
 java.lang.Object clone()
          Clones this object.
 AdminData getAdminData()
          Gets the admin data associated with this object
 java.lang.Object[] getAttr(java.lang.String attr)
          Gets the attribute associated with the given key
 java.lang.String getBytestream()
          Returns the bytestream associated with this object
 java.lang.String getContentType()
          Gets the content type of this data object
 Content getPayload()
          Return the content associated with this object
 Ref getRef()
          Get a Ref of this CollectionItem
 java.util.Properties modifyPathProperties(java.util.Properties oldProps, java.lang.String oldPath)
          Adjust the XPaths in a given Properties Object to reflect the element reached by the given XPath now being the root element.
 boolean setAdminData(AdminData data)
          Sets the admin data of this object
 boolean setAttr(java.lang.String attr, java.lang.String val)
          Sets the given attribute with the given text value
 boolean setAttr(java.lang.String attr, java.lang.String[] vals)
          Set the attribute defined by attr with the values specified in vals
 boolean setAttr(java.lang.String attr, StructuredDataObject obj)
          Sets a complex element into the object
 boolean setAttr(java.lang.String attr, StructuredDataObject[] objs)
          Sets a set of complex element into the object
 boolean setBytestream(java.lang.String s)
          Sets the bytestream of this object
 boolean setPayload(Content data)
          Sets the Payload (content) of this object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicStructuredObject

public BasicStructuredObject(java.lang.String bytes,
                             java.util.Properties xPaths)
Constructor

Parameters:
bytes - the bytestream of the item
xPaths - A Properties object containg key/value pairs of attr_name/path_to_attr These properties MUST include: 1) "guid"/path_to_guid 2) "content"/path_to_content 3) "admin"/path_to_admin 4) "content_type"/path_to_content_type 5) "indexes"/path_to_indexes 6) "index_name"/path_to_index_name 6) "index_path"/path_to_index_path 7) "content_root"/content_root_element_name 8) "index_type"/path_to_index_type
Method Detail

clone

public java.lang.Object clone()
Clones this object. Basically copies all fields

Overrides:
clone in class java.lang.Object

getAdminData

public AdminData getAdminData()
                       throws RegistrySystemException
Gets the admin data associated with this object

Specified by:
getAdminData in interface CollectionItem
Returns:
AdminData or null if not found
Throws:
RegistrySystemException - if attribute is missing

getAttr

public java.lang.Object[] getAttr(java.lang.String attr)
Gets the attribute associated with the given key

Specified by:
getAttr in interface StructuredDataObject
Parameters:
attr - The name of the attribute to get
Returns:
The result of executing the XPath vale associated with the given key against the xml content. Returns null if not found. If the element identified by the XPath is simple, a String Object is returned. Else, if the element is a complex one, DataObjects are returned. If there is more than one element for the given XPath, all are returned
Throws:
RegistrySystemException - if the specified attribute does not exist in the object's Properties

getBytestream

public java.lang.String getBytestream()
Returns the bytestream associated with this object

Specified by:
getBytestream in interface DataObject
Returns:
String representing the bytestream

getPayload

public Content getPayload()
                   throws RegistrySystemException
Return the content associated with this object

Specified by:
getPayload in interface CollectionItem
Returns:
An Xml String or null if any exceptions were caught
Throws:
RegistrySystemException - if attribute is missing

getContentType

public java.lang.String getContentType()
Gets the content type of this data object

Returns:
String representing the content type
Throws:
RegistrySystemException - if the attribute "content_type" is not part of this object's Properties

getRef

public Ref getRef()
Get a Ref of this CollectionItem

Specified by:
getRef in interface CollectionItem
Returns:
Ref containing key/value of PATH_TO_GUID/guid

setAdminData

public boolean setAdminData(AdminData data)
Sets the admin data of this object

Specified by:
setAdminData in interface CollectionItem
Parameters:
data - The AdminData to set
Returns:
true is successful, false otherwise
Throws:
RegistrySystemException - if the attribute "admin" is not in this object's Properties

setAttr

public boolean setAttr(java.lang.String attr,
                       java.lang.String val)
Sets the given attribute with the given text value

Specified by:
setAttr in interface StructuredDataObject
Parameters:
attr - The attribute to set
val - The text value to assign
Returns:
true if successful, false otherwise
Throws:
RegistrySystemException - if the provided attr is not in this object's Properties

setAttr

public boolean setAttr(java.lang.String attr,
                       java.lang.String[] vals)
Set the attribute defined by attr with the values specified in vals

Specified by:
setAttr in interface StructuredDataObject
Parameters:
attr - String name of the attribute to set
vals - Values to assign to the attribute
Returns:
true if successful, false otherwise

setAttr

public boolean setAttr(java.lang.String attr,
                       StructuredDataObject obj)
Sets a complex element into the object

Specified by:
setAttr in interface StructuredDataObject
Parameters:
attr - The attribute to set
obj - The StructuredDataObject to use as data
Returns:
true if successful, false otherwise
Throws:
RegistrySystemException - if the provided attr is not in this object's Properties

setAttr

public boolean setAttr(java.lang.String attr,
                       StructuredDataObject[] objs)
Sets a set of complex element into the object

Specified by:
setAttr in interface StructuredDataObject
Parameters:
attr - The elements to set
objs - The StructuredDataObjects to use as data
Returns:
true if successful, false otherwise
Throws:
RegistrySystemException - if the provided attr is not in this object's Properties

setBytestream

public boolean setBytestream(java.lang.String s)
Sets the bytestream of this object

Specified by:
setBytestream in interface DataObject
Parameters:
s - The bytestream to set
Returns:
true if successful, false otherwise

setPayload

public boolean setPayload(Content data)
Sets the Payload (content) of this object

Specified by:
setPayload in interface CollectionItem
Parameters:
data - The Content to set
Returns:
true if successful, false otherwise

modifyPathProperties

public java.util.Properties modifyPathProperties(java.util.Properties oldProps,
                                                 java.lang.String oldPath)
Adjust the XPaths in a given Properties Object to reflect the element reached by the given XPath now being the root element. The algorithm is as follows: 1) Obtain the new root element name from the path by using lastIndexOf("/") combined with substring(). 2) For each path in the oldProps file, do if(newPath contains oldPath) then Remove oldPath from newPath, prepend new root name done

Parameters:
oldProps - the original Properties Object containing XPaths
oldPath - The path to the element that is the new root element
Returns:
Properties modified to reflect a new root element


Copyright © 2008 OCLC Online Computer Library Center, Inc.. All Rights Reserved.