Fixing find hastag

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@176825 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2019-01-25 14:28:07 +00:00
parent 42e1e85992
commit 203a6c76a2
3 changed files with 11 additions and 11 deletions

View File

@ -3,15 +3,15 @@ package org.gcube.socialnetworking.socialtoken;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.socialnetworking.tokenization.Token;
public class TagToken extends ReplaceableToken {
public class HashTagToken extends ReplaceableToken {
protected SanitizedTag sanitizedTag;
protected SanitizedHashTag sanitizedTag;
public TagToken(String token, String delimiter, int start, int end) {
public HashTagToken(String token, String delimiter, int start, int end) {
super(token, delimiter, start, end);
}
public TagToken(Token token) {
public HashTagToken(Token token) {
super(token);
}
@ -32,7 +32,7 @@ public class TagToken extends ReplaceableToken {
public String getTag() throws Exception {
if(sanitizedTag==null) {
sanitizedTag = new SanitizedTag(token);
sanitizedTag = new SanitizedHashTag(token);
}
return sanitizedTag.getTag();
}

View File

@ -3,7 +3,7 @@ package org.gcube.socialnetworking.socialtoken;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SanitizedTag {
public class SanitizedHashTag {
private static final String TAG_REGEX = "^#[\\w-_]*";
@ -16,13 +16,13 @@ public class SanitizedTag {
protected String tag;
protected String postfix;
public SanitizedTag(String string) throws Exception {
public SanitizedHashTag(String string) throws Exception {
if(string==null || string.compareTo("")==0 || !string.startsWith("#")) {
throw new Exception(string + "is not a valid TAG");
}
Matcher matcher = SanitizedTag.pattern.matcher(string);
Matcher matcher = SanitizedHashTag.pattern.matcher(string);
if(matcher.find()) {
tag = string.substring(matcher.start(), matcher.end());

View File

@ -25,7 +25,7 @@ public class SocialMessageParser {
private StringWriter stringWriter;
private List<ReplaceableToken> tokens;
private List<TagToken> tagTokens;
private List<HashTagToken> tagTokens;
private List<URLToken> urlTokens;
private List<String> hashtags;
@ -45,7 +45,7 @@ public class SocialMessageParser {
for(Token token : socialStringTokenizer.getTokens()) {
String tokenString = token.getToken();
if(tokenString.startsWith("#")) {
TagToken tagToken = new TagToken(token);
HashTagToken tagToken = new HashTagToken(token);
try {
hashtags.add(tagToken.getTag());
tokens.add(tagToken);
@ -124,7 +124,7 @@ public class SocialMessageParser {
return hashtags;
}
public List<TagToken> getTagTokens() {
public List<HashTagToken> getTagTokens() {
if(tokens==null){
getTokens();
}