@@ -45,23 +45,24 @@ protected Set<Mention> findByUserDescription(String description,Task task) {
4545
4646 protected String getFormattedTextForMentions (Set <Mention > mentions , String formattedText ) {
4747 for (Mention mention : mentions ) {
48-
49- if (mention .isProxy () && mention .hasUser () && (!mention .getScreenName ().isEmpty ())) {
50-
51- String USER_PROFILE_INPUT [] = {
52- "@(" + mention .getScreenName () + ")(" + stopChar + ")" ,
53- "@(" + mention .getScreenName () + ")$"
54- };
55-
56- String USER_PROFILE_OUTPUT [] = {
57- " <a class=\" tweet-action tweet-profile1\" href=\" https://twitter.com/$1\" target=\" _blank\" >@$1</a>$2" ,
58- " <a class=\" tweet-action tweet-profile2\" href=\" https://twitter.com/$1\" target=\" _blank\" >@$1</a> "
59- };
60-
61- for (int i =0 ;i <2 ;i ++){
62- Pattern userPattern = Pattern .compile (USER_PROFILE_INPUT [i ]);
63- Matcher m = userPattern .matcher (formattedText );
64- formattedText = m .replaceAll (USER_PROFILE_OUTPUT [i ]);
48+ if (mention != null ) {
49+ if (mention .isProxy () && mention .hasUser () && (!mention .getScreenName ().isEmpty ())) {
50+
51+ String USER_PROFILE_INPUT [] = {
52+ "@(" + mention .getScreenName () + ")(" + stopChar + ")" ,
53+ "@(" + mention .getScreenName () + ")$"
54+ };
55+
56+ String USER_PROFILE_OUTPUT [] = {
57+ " <a class=\" tweet-action tweet-profile1\" href=\" https://twitter.com/$1\" target=\" _blank\" >@$1</a>$2" ,
58+ " <a class=\" tweet-action tweet-profile2\" href=\" https://twitter.com/$1\" target=\" _blank\" >@$1</a> "
59+ };
60+
61+ for (int i = 0 ; i < 2 ; i ++) {
62+ Pattern userPattern = Pattern .compile (USER_PROFILE_INPUT [i ]);
63+ Matcher m = userPattern .matcher (formattedText );
64+ formattedText = m .replaceAll (USER_PROFILE_OUTPUT [i ]);
65+ }
6566 }
6667 }
6768 }
@@ -247,13 +248,14 @@ protected String getFormattedTextForMedia(Set<Media> media, String formattedText
247248
248249 public String getFormattedUrlForUrls (Set <Url > urls , String formattedText ) {
249250 for (Url url : urls ) {
251+ if (url !=null ) {
252+ String USER_PROFILE_INPUT = url .getUrl ();
253+ String USER_PROFILE_OUTPUT = "<a href=\" " + url .getExpanded () + "\" class=\" tw-url-db\" target=\" _blank\" >" + url .getDisplay () + "</a>" ;
250254
251- String USER_PROFILE_INPUT =url .getUrl ();
252- String USER_PROFILE_OUTPUT ="<a href=\" " + url .getExpanded () + "\" class=\" tw-url-db\" target=\" _blank\" >" + url .getDisplay () + "</a>" ;
253-
254- Pattern myUrl = Pattern .compile (USER_PROFILE_INPUT );
255- Matcher m = myUrl .matcher (formattedText );
256- formattedText = m .replaceAll (USER_PROFILE_OUTPUT );
255+ Pattern myUrl = Pattern .compile (USER_PROFILE_INPUT );
256+ Matcher m = myUrl .matcher (formattedText );
257+ formattedText = m .replaceAll (USER_PROFILE_OUTPUT );
258+ }
257259 }
258260 return formattedText ;
259261 }
@@ -323,29 +325,30 @@ protected String getFormattedTextForUrls( String formattedText) {
323325
324326 protected String getFormattedTextForUrls (Set <Url > urls , String formattedText ) {
325327 for (Url url : urls ) {
328+ if (url !=null ) {
329+ String USER_PROFILE_INPUT [] = {
330+ "(" + url .getDisplay () + ")(" + stopChar + ")" ,
331+ "(" + url .getDisplay () + ")$" ,
332+ "(" + url .getExpanded () + ")(" + stopChar + ")" ,
333+ "(" + url .getExpanded () + ")$" ,
334+ "(" + url .getUrl () + ")(" + stopChar + ")" ,
335+ "(" + url .getUrl () + ")$"
336+ };
326337
327- String USER_PROFILE_INPUT [] = {
328- "(" + url .getDisplay () + ")(" + stopChar + ")" ,
329- "(" + url .getDisplay () + ")$" ,
330- "(" + url .getExpanded () + ")(" + stopChar + ")" ,
331- "(" + url .getExpanded () + ")$" ,
332- "(" + url .getUrl () + ")(" + stopChar + ")" ,
333- "(" + url .getUrl () + ")$"
334- };
335-
336- String USER_PROFILE_OUTPUT [] = {
337- " <a href=\" " + url .getExpanded () + "\" class=\" tw-display1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
338- " <a href=\" " + url .getExpanded () + "\" class=\" tw-display2\" target=\" _blank\" >" + url .getDisplay () + "</a> " ,
339- " <a href=\" " + url .getExpanded () + "\" class=\" tw-expanded1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
340- " <a href=\" " + url .getExpanded () + "\" class=\" tw-expanded2\" target=\" _blank\" >" + url .getDisplay () + "</a> " ,
341- " <a href=\" " + url .getExpanded () + "\" class=\" tw-url1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
342- " <a href=\" " + url .getExpanded () + "\" class=\" tw-url2\" target=\" _blank\" >" + url .getDisplay () + "</a> "
343- };
338+ String USER_PROFILE_OUTPUT [] = {
339+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-display1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
340+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-display2\" target=\" _blank\" >" + url .getDisplay () + "</a> " ,
341+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-expanded1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
342+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-expanded2\" target=\" _blank\" >" + url .getDisplay () + "</a> " ,
343+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-url1\" target=\" _blank\" >" + url .getDisplay () + "</a>$2" ,
344+ " <a href=\" " + url .getExpanded () + "\" class=\" tw-url2\" target=\" _blank\" >" + url .getDisplay () + "</a> "
345+ };
344346
345- for (int i =0 ;i <6 ;i ++){
346- Pattern userPattern = Pattern .compile (USER_PROFILE_INPUT [i ]);
347- Matcher m = userPattern .matcher (formattedText );
348- formattedText = m .replaceAll (USER_PROFILE_OUTPUT [i ]);
347+ for (int i = 0 ; i < 6 ; i ++) {
348+ Pattern userPattern = Pattern .compile (USER_PROFILE_INPUT [i ]);
349+ Matcher m = userPattern .matcher (formattedText );
350+ formattedText = m .replaceAll (USER_PROFILE_OUTPUT [i ]);
351+ }
349352 }
350353 }
351354 return formattedText ;
0 commit comments