So we implement it to reach so far one is bookmarking while the other is marking an item as kid friendly 2
. 3
Now we will implement the feature for sharing kid friendly bookmark with partner websites. 4
However the constraint is that only a kid friendly bookmark that is either a book or of eyeblink can 5
be shared. 6
So a movie cannot be shared. 7
You may recall the slide from one officer up chapter which introduced this new requirement. 8
Here we have this strength to get friendly books so you can see that there is this link called shared 9
with snips where courtships is a fictitious part on the website. 10
This link will be shown only for books and ramblings but not for movies. 11
You can assume that this link shows up as soon as a staff member mocks either a book or a blink as kid 12
friendly. 13
Clicking on this link will invoke shared method in the back in which we know will be a method in the 14
controller in the Bakken. 15
Did we have a logic that will generate the data to be shared in SML format with the partner site like 16
in the case of marking. 17
Get friendly bookmarks. 18
We already discussed implementation because for this feature we did that well and are using interfaces 19
as an interface is needed for this new requirement. 20
So we're already familiar with this class diagram to enforce the constraint that only book on wabbling 21
can be shared. 22
We define an interface called sharable which is implemented by only book and Roblin classes he called 23
a sharable cannot be an abstract class because our classes are already extending that abstract bookmark 24
class. 25
Moreover sharing is an optional capability and so we know that it would have to be represented using 26
an interface. 27
So let's get started now and let's first create the interface shippable. 28
Let's create it in a new package called partner as shootable has something to do better. 29
Third party partner websites 30
so let's create a new package 31
partner 32
. 33
Let's create an interface here shootable 34
and that's how you define the method get item data. 35
Next let's have rebeling on book. 36
Implement this sharable interface. 37
Let's just open the book Class control shift are just and this book is implemented in open 38
court. 39
So just sit ired unimplemented methods which is to get item data. 40
So if you scroll down so be how the Templer generated automatically. 41
OK so we know that this method returns information about this particular item which is a book in XML 42
format which isn't shared with a partner website. 43
Typically data exchange between Web sites is done either in examen or Jason farmer Gissen is another 44
format but it is much more compact and XML in case you don't know what ex-head malice. 45
It is short for Extensible Markup Language And it basically encapsulates doodah using meaningful examinee 46
tax so the docs describe what the data is about the exim unstring that is generated is human readable 47
. 48
Art can also be processed by machines suitable ex-MIL string we will use a string builder as there are 49
several fields in book class and we need to combine them into a single string. 50
Recall that it's not recommended to use plus operator for string concatenation especially when performance 51
is critical. 52
That surplus should be used only sparingly. 53
OK so let's just get started and belive this particular method. 54
You can just delete this 55
Arnaud's builder 56
so a builder has happened matter. 57
So let's have the first semantic tag as item and its cluelessness. 58
So I accidently tax how the starting tag and name tags are it's have an ending tag a name tag would 59
have a forward slash followed by the tag name item. 60
Now since this is of Bible book so let's have an element just for book saying that it's a book so it's 61
Connard as Bible 62
so book is the real data type is another I. 63
Let's have a burn at night here. 64
But it has real value. 65
So let's just remove this 66
and rebuild that Shane. 67
Yes. 68
I mean that's good one more happened here for the name tag. 69
Now the title is present in the supercross which is bookmark. 70
And to get that we just need to do when we need to invoke the get Bitly method in the superclass. 71
So next 72
so we have all these feelings and we need to combine We need to include all these fields in our Exham 73
of string. 74
So next let's say publisher 75
schoolbags public publisher publication here. 76
OK it's good been publisher. 77
So let's call the element as publisher 78
since publisher is available in this class itself so we can directly access it 79
. 80
Next let's have publication here 81
. 82
Next let's have John Ray 83
. 84
Next is Amazon rating 85
. 86
One more we have is authors let's just keep it here because it's like an important field. 87
However alter says a string array rather than a string or an. 88
It is a string array. 89
So what we can do is we can make use of a third party library here we can use Apache Commons slang because 90
it has it has a class called String Udall's which can be used to join to combine to concatenate all 91
of the authors using a single function. 92
OK. 93
So with a single function in the string utils class we can combine all the authors all the alternates 94
into a single string and we can do that. 95
So let's use the string utos grads from Apache Commons line. 96
But we don't have it here. 97
So what we need to do is we need to download Apache a common Lange's and use the Jarve file for doc 98
. 99
So I have already done that. 100
So I have it here but you can just go ahead and can just type in about the Commons monster lying. 101
Here it is. 102
And you can download Apache Commons line. 103
That's the latest version is 3.4 and it requires that I was 6 and just you can download the binary here 104
and just unzip it and extract the folder and within that with no room for Ladu you will have a jar file 105
so you can just extract that jar file and store it on your desk. 106
And then we need to import it into our into our eclipse. 107
So the way we do it is just right click on three are here is going to properties going to be part and 108
I had external jars and this is an older one so to me 109
your 110
think Howard here. 111
Yes. 112
So this is the one and lie. 113
OK. 114
So here is the reference library. 115
So it's already there. 116
So Apache Commons Lang has this class called String Udalls. 117
So let me do it and let's just search for it. 118
We just show that 119
string your DOS. 120
Here is the class String utos class. 121
So it has a lot of utility functions and I'm sure you will be making use of this class quite a bit. 122
So here there is one function called Join in and this is the one. 123
So this can take a string array. 124
It's an object array but you can pass a string array and you will pass on any operator like a hybrid 125
of can be Ostrower or anything like that. 126
And we will pass on common so that we get a comma separated string. 127
So it will combine all the auteurs into it and into a single string which is operated by comma. 128
And so let's just make use of this function 129
. 130
So you join others. 131
Now the second argument is a comma. 132
OK so that's it. 133
So that's the string Udalls it's already imported. 134
She's next. 135
And let's just see written Berliner got to string. 136
OK. 137
So this would work on a string. 138
So that's the good item there Dummett there. 139
Let me just go ahead and do the same. 140
Godard under Dummett that let me implement the Guitard underdone method in the grappling class because 141
wabbling also implements this interface. 142
And then I'll do this offline and I'll come back and show it to you. 143
OK. 144
Here it is. 145
So we are implementing shareable. 146
And of course we are extending bookmark. 147
So here is the get item re-admitted. 148
And as you can see we are once again using string builder. 149
And so we have this item tags here. 150
Opening tag on the closing tag. 151
And we have pipe which is wabbling. 152
Let's actually make this gap to be consistent and then the next element is title and the next is you 153
aren't on the next as host. 154
So those are the only fields that we have for for the ruling class. 155
So that's about it for now. 156
So just go ahead and implement what we covered so far here. 157
Next we will complete the remaining part of this feature in the next lesson and we will code the logic 158
in view controller and the manager process. 159
OK so please just go ahead and call whatever has been shown in this class and this lesson