[Forwarding to the list as this might be of general interest] On 07/06/11 04:24, Yaron Koren wrote: > Hi Markus, > > I'm modifying Semantic Internal Objects to work with SMW 1.6. SIO > currently has some code that creates an object of type SMWDataValue, and > calls getDBkeys() on it. That is now deprecated - instead one is > supposed to call SMWCompatibilityHelpers::getDBkeysFromDataItem(). That > function, though, takes in an object of type SMWDataItem, not > SMWDataValue. I don't know how to generate an object of type SMWDataItem > - I couldn't find a constructor function for it. I have a property name > and a value - how do I create one using those?
There are basically two cases: (1) You have user input data and want a data item. (2) You have exact, normalized, internal data and want a data item. In case (1), you should create an SMWDataValue as before. The data value classes are the place where all the parsing and cleaning of user data happens. You can call getDataItem() to get the dataitem (as usual, you may want to check isvalid() to see if the input could be parsed at all). In case (2), you simply call the constructor of the SMWDataItem that you want to create, using the right parameters. This should always be done if a fixed data item is required in the code (e.g. to represent a fixed special property that is created from its key). Dataitems should be viewed as simple data structures: they don't do anything intelligent other than possibly some basic sanity checks in the constructor. In most cases, you should no longer need to access the elements of the array that was returned by getDBkeys(): the same information is represented in a more direct way by the data item. The DBkeys-based methods are only useful if your code generally uses such arrays internally. Otherwise, the arrays should be replaced by data item objects, and it might not be necessary to ever convert these to arrays at all. Markus ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel