Example usage for twitter4j HashtagEntity getEnd

List of usage examples for twitter4j HashtagEntity getEnd

Introduction

In this page you can find the example usage for twitter4j HashtagEntity getEnd.

Prototype

@Override
int getEnd();

Source Link

Document

Returns the index of the end character of the hashtag.

Usage

From source file:com.github.daytron.twaattin.ui.tabledecorator.TweetColumnDecorator.java

License:Open Source License

void createFragmentsWithTag(HashtagEntity[] tags) {

    if (tags != null) {

        for (HashtagEntity tag : tags) {

            int start = tag.getStart();
            int end = tag.getEnd();

            try {

                String encodedUrl = TWITTER_SEARCH_URL + URLEncoder.encode('#' + tag.getText(), "UTF-8");

                String href = "<a href='" + encodedUrl + "' target='search'>";

                TweetFragment fragment = new TweetFragment(start, end, href + '#' + tag.getText() + "</a>");

                fragments.add(fragment);

            } catch (UnsupportedEncodingException e) {

                e.printStackTrace();//from  w w  w  .  j  av a2  s .co  m
            }
        }
    }
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

static Struct convertHashtagEntity(HashtagEntity hashtagEntity) {
    return new Struct(SCHEMA_HASHTAG_ENTITY).put("Text", hashtagEntity.getText())
            .put("Start", hashtagEntity.getStart()).put("End", hashtagEntity.getEnd());
}

From source file:com.mothsoft.alexis.engine.retrieval.TwitterRetrievalTaskImpl.java

License:Apache License

private List<TweetHashtag> readHashtags(Status status) {
    final List<TweetHashtag> hashtags = new ArrayList<TweetHashtag>();

    if (status.getHashtagEntities() != null) {
        for (final HashtagEntity entity : status.getHashtagEntities()) {

            final TweetHashtag hashtag = new TweetHashtag((short) entity.getStart(), (short) entity.getEnd(),
                    entity.getText());//from   ww  w .  j a va 2  s.c  om
            hashtags.add(hashtag);
        }
    }

    return hashtags;
}

From source file:org.xmlsh.twitter.util.TwitterWriter.java

License:BSD License

private void write(String localName, HashtagEntity e) throws XMLStreamException {
    startElement(localName);// www .  j a v  a  2 s . c  om
    attribute("start", e.getStart());
    attribute("end", e.getEnd());
    characters(e.getText());
    endElement();

}