ItemMirror Class
ItemMirror represents an Item according to the XooML2 specification.
It can be instantiated using one of the following two cases based on the given arguments.
- XooMLFragment already exists. Given xooMLFragmentURI and xooMLDriver.
- The XooMLFragment is created from an existing groupingItemURI (e.g., a dropbox folder). Given a groupingItemURI, itemDriver, and a xooMLDriver a new itemMirror will be constructed for given groupingItemURI.
Throws NullArgumentException when options is null.
Throws MissingParameterException when options is not null and a required argument is missing.
Constructor
ItemMirror
-
options
-
callback
Parameters:
-
options
ObjectData to construct a new ItemMirror with
-
groupingItemURI
StringURI to the grouping item. Required for all cases.
-
itemDriver
StringData for the ItemDriver to construct ItemMirror with. Required for cases 2 & 3 Can contain any amount of optional key/value pairs for the various Driver implementations.
-
driverURI
StringURI of the driver.
-
-
xooMLDriver
StringData for the XooMLDriver to construct ItemMirror with. Required for all cases. Can contain any amount of optional key/value pairs for the various Driver implementations.
-
driverURI
StringURI of the driver.
-
-
syncDriver
StringData for the SyncDriver to construct ItemMirror with. Required Case 2 & 3. Can contain any amount of optional key/value pairs for the various Driver implementations.
-
driverURI
StringURI of the driver.
-
-
readIfExists
BooleanTrue if ItemMirror should create an ItemMirror if it does not exist, else false. Required for Case 2 & 3.
-
creator
ItemMirrorIf being created from another itemMirror, specifies that itemMirror which it comes from.
-
-
callback
FunctionFunction to execute once finished.
-
error
ObjectNull if no error has occurred in executing this function, else an contains an object with the error that occurred.
-
itemMirror
ItemMirrorNewly constructed ItemMirror
-
Item Index
Methods
- _isURL
- _unsafeWrite
- addAssociationNamespaceAttribute
- addFragmentNamespaceAttribute
- copyAssociation
- createAssociation
- createItemMirrorForAssociatedGroupingItem
- deleteAssociation
- getAssociationAssociatedItem
- getAssociationDisplayText
- getAssociationLocalItem
- getAssociationNamespaceAttribute
- getAssociationNamespaceData
- getCreator
- getDisplayName
- getFragmentNamespaceAttribute
- getFragmentNamespaceData
- getSchemaLocation
- getSchemaVersion
- getURIforItemDescribed
- hasAssociationNamespace
- hasFragmentNamespace
- isAssociationAssociatedItemGrouping
- isAssociationPhantom
- listAssociationNamespaceAttributes
- listAssociations
- listFragmentNamespaceAttributes
- moveAssociation
- refresh
- removeAssociationNamespaceAttribute
- removeFragmentNamespaceAttribute
- renameAssocaitionLocalItem
- save
- setAssociationDisplayText
- setAssociationNamespaceAttribute
- setAssociationNamespaceData
- setDisplayName
- setFragmentNamespaceAttribute
- setFragmentNamespaceData
- sync
- upgradeAssociation
Methods
_isURL
-
URL
Checks if the AssociatedItem String passed into it is a URL or not.
Parameters:
-
URL
String
Returns:
True if it is an HTTP URL, false otherwise (HTTPS will fail)
_unsafeWrite
-
callback
-
calback.error
A special method that is used for certain file operations where calling a sync won't work. Essentially it is the save function, sans syncing. This should never be called be an application.
addAssociationNamespaceAttribute
-
attributeName
-
attributeValue
-
GUID
-
uri
Adds the given attributeName to the association with the given GUID and namespaceURI.
Throws NullArgumentException if attributeName, GUID, or namespaceURI is
null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not
a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Throws an InvalidStateException when the given attributeName has already
been added.
addFragmentNamespaceAttribute
-
attributeName
-
uri
Adds the given attributeName to the fragment's current namespace
Throws an InvalidStateException when the attribute already exists
copyAssociation
-
GUID
-
ItemMirror
-
callback
Duplicates (copies) an association to another ItemMirror Object (representing a grouping item)
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID of the association you wish to copy/duplicate
-
ItemMirror
ItemMirrorItemMirror representing the grouping item you want to move the GUID object to
-
callback
FunctionFunction to execute once finished.
-
error
ObjectNull if no error Null if no error has occurred in executing this function, else it contains an object with the error that occurred.
-
createAssociation
-
options
-
callback
Creates an association based on the given options and the following cases.
Cases 1, 2, 7 implemented. All else are not implemented.
- Simple text association declared phantom.
- Link to existing non-grouping item, phantom. This can be a URL
- Link to existing non-grouping item, real.
- Link to existing grouping item, phantom.
- Link to existing grouping item, real.
- Create new local non-grouping item.
- Create new local grouping item.
Throws NullArgumentException when options, or callback is null.
Throws InvalidTypeException when options is not an object and callback
is not a function.
Throws MissingParameterException when an argument is missing for an expected
case.
Parameters:
-
options
ObjectData to create an new association for.
-
displayText
StringDisplay text for the association. Required in all cases.
-
itemURI
StringURI of the item. Required for case 2 & 3. Note: Please ensure "http://" prefix exists at the beginning of the string when referencing a Web URL and not an Item.
-
localItemRequested
BooleanTrue if the local item is requested, else false. Required for cases 2 & 3.
-
groupingItemURI
StringURI of the grouping item. Required for cases 4 & 5.
-
xooMLDriverURI
StringURI of the XooML driver for the association. Required for cases 4 & 5.
-
localItem
StringURI of the new local non-grouping/grouping item. Required for cases 6 & 7.
-
isGroupingItem
StringTrue if the item is a grouping item, else false. Required for cases 6 & 7.
-
-
callback
FunctionFunction to execute once finished.
createItemMirrorForAssociatedGroupingItem
-
GUID
Creates an ItemMirror from the associated grouping item represented by the given GUID.
Throws NullArgumentException if GUID or callback is null.
Throws InvalidTypeException if GUID is not a string, and callback is
not a function.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID of the association to create the ItemMirror from.
Returns:
Possibly return an itemMirror if the GUID is a grouping item
deleteAssociation
-
GUID
-
callback
Deletes the association represented by the given GUID.
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
getAssociationAssociatedItem
-
GUID
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID of the association to get.
Returns:
The associated item for the association with the given GUID.
getAssociationDisplayText
-
GUID
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID representing the desired association.
Returns:
The display text for the association with the given GUID.
getAssociationLocalItem
-
GUID
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID of the association to get.
Returns:
The local item for the association with the given GUID.
getAssociationNamespaceAttribute
-
attributeName
-
GUID
-
uri
Throws NullArgumentException if attributeName, GUID, or namespaceURI is
null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not
a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
Returns:
The association namespace attribute with the given attributeName and the given namespaceURI within the association with the given GUID.
getAssociationNamespaceData
-
GUID
-
uri
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
Returns:
The association namespace data for an association with the given GUID and the given namespaceURI.
getCreator
()
Object
Returns:
The itemMirror that created this current itemMirror, if it has one. Note that this isn't the same as asking for a 'parent,' since multiple itemMirrors can possibly link to the same one
getFragmentNamespaceAttribute
-
attributeName
-
uri
Returns:
Returns the value of the given attributeName for the fragmentNamespaceData with the given namespaceURI.
getFragmentNamespaceData
-
uri
Parameters:
-
uri
StringNamespace URI
Returns:
The fragment namespace data with the given namespace URI.
getURIforItemDescribed
()
String
Returns URI pointing to item described by the metadata of a fragment. A URI might point to just about anything that can be interpreted as a grouping item. For example: a conventional file system folder or a “tag as supported by any of several applications.
Returns:
A URI pointing to item described by the metadata of a fragment if it exists, else returns null.
hasAssociationNamespace
-
GUID
-
uri
Returns:
True if the association has the given namespaceURI, else false.
hasFragmentNamespace
-
uri
Checks if the fragment has the given namespaceURI.
Currently cannot find a way to list the namespaces (no DOM standard method for doing so). So this fuction will ALWAYS RETURN FALSE for now.
Parameters:
-
uri
StringURI of the namespace for the association.
Returns:
True if the fragment has the given namespaceURI, otherwise false.
isAssociationAssociatedItemGrouping
-
GUID
Checks if an association's associatedItem is a grouping item
Throws NullArgumentException if GUID, callback is null.
Throws InvalidTypeException if GUID is not a String, and if callback
is not an function.
Parameters:
-
GUID
StringGUID of the association to be to be checked.
Returns:
True if the association with the given GUID's associatedItem is a grouping item, otherwise false.
isAssociationPhantom
-
guid
Parameters:
-
guid
String
Returns:
True if the association of the given GUID is a phantom association. False otherwise.
listAssociationNamespaceAttributes
-
GUID
-
uri
Throws NullArgumentException if GUID, namespaceURI is null.
Throws InvalidTypeException if GUID, namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Returns:
An array of the association namespace attributes with the given attributeName and the given namespaceURI within the association with the given GUID.
listAssociations
()
String[]
Lists the GUIDs of each association.
Returns:
Array of the GUIDs of each association
listFragmentNamespaceAttributes
-
uri
Parameters:
-
uri
StringNamespace URI
Returns:
An array of the attributes within the fragmentNamespaceData with the given namespaceURI.
moveAssociation
-
GUID
-
ItemMirror
-
callback
Moves an association to another ItemMirror Object (representing a grouping item)
Throws NullArgumentException if GUID is null.
Throws InvalidTypeException if GUID is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Parameters:
-
GUID
StringGUID of the item you want to paste or move
-
ItemMirror
ItemMirrorItemMirror representing the grouping item you want to move the GUID object to
-
callback
FunctionFunction to execute once finished.
-
error
ObjectNull if no error Null if no error has occurred in executing this function, else it contains an object with the error that occurred.
-
refresh
-
callback
Reloads the XooML Fragment
removeAssociationNamespaceAttribute
-
attributeName
-
GUID
-
uri
Removes the given attributeName to the association with the given GUID and namespaceURI.
Throws NullArgumentException if attributeName, GUID, or namespaceURI is
null.
Throws InvalidTypeException if attributeName, GUID, or namespaceURI is not
a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
Throws an InvalidStateException when the given attributeName is not an
attribute.
removeFragmentNamespaceAttribute
-
attributeName
-
uri
Removes the fragment namespace attribute with the given namespaceURI.
Throws NullArgumentException if attributeName, or namespaceURI is
null.
Throws InvalidTypeException if attributeName, or namespaceURI is not
a String.
Throws an InvalidStateException when the given attributeName is not an
attribute.
renameAssocaitionLocalItem
-
GUID
-
String
-
callback
Renames the local item for the association with the given GUID.
Throws NullArgumentException if GUID, callback is null.
Throws InvalidTypeException if GUID is not a String, and if callback
is not a function.
save
-
callback
Saves the itemMirror object, writing it out to the fragment. Fails if the GUID generated on last write for the itemMirror and the XooML fragment don't match.
Parameters:
-
callback
Object-
error
Returns false if everything went ok, otherwise returns the error
-
setAssociationDisplayText
-
GUID
-
displayText
Sets the display text for the association with the given GUID.
Throws NullArgumentException if GUID or displayName is null.
Throws InvalidTypeException if GUID or displayName is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
setAssociationNamespaceAttribute
-
attributeName
-
attributeValue
-
GUID
-
uri
Sets the association namespace attribute with the given attributeName and the given namespaceURI within the association with the given GUID.
Throws NullArgumentException if attributeName, attributeValue, GUID, or
namespaceURI is null.
Throws InvalidTypeException if attributeName, attributeValue, GUID, or
namespaceURI is not a String.
Throws InvalidGUIDException if GUID is not a valid GUID.
setAssociationNamespaceData
-
data
-
GUID
Sets the association namespace data for an association with the given GUID and given namespaceURI using the given data.
Throws NullArgumentException if data, GUID, or namespaceURI is null.
Throws InvalidTypeException if data, GUID, or namespaceURI is not a
String.
Throws InvalidGUIDException if GUID is not a valid GUID.
setFragmentNamespaceAttribute
-
attributeName
-
attributeValue
-
uri
Sets the value of the given attributeName with the given attributeValue for the fragmentNamespaceData with the given namespaceURI.
Throws NullArgumentException if attributeName, attributeValue, or
namespaceURI is null.
Throws InvalidTypeException if attributeName, attributeValue, or
namespaceURI is not a String.
setFragmentNamespaceData
-
data
-
uri
Sets the fragment namespace data with the given namespaceURI.
sync
-
callback
Uses the specified ItemDriver and SyncDriver to synchronize the local ItemMirror object changes. This is an implmentation of Synchronization Driver which modifies the XooML Fragment according to the real structure under the item described.
upgradeAssociation
-
options
-
callback
Upgrades a given association without a local item. Local item is named by a truncated form of the display name of this ItemMirror if the localItemURI is not given, else uses given localItemURI. Always truncated to 50 characters.
ONLY SUPPORTS SIMPLE PHANTOM ASSOCIATION TO ASSOCIATION WITH GROUPING ITEM
Throws NullArgumentException when options is null.
Throws MissingParameterException when options is not null and a required
argument is missing.
Throws InvalidTypeException if GUID is not a string, and if callback
is not a function.
Throws InvalidState if the association with the given GUID cannot be
upgraded.