Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.twitterapime.util
Class StringUtil

    java.lang.Object
      com.twitterapime.util.StringUtil

    public final class StringUtil

extends java.lang.Object

This class provides some useful methods to work with strings.

Since:
  1.1
Version:
  1.2
Author:
  Ernandes Mourao Junior (ernandes@gmail.com)

Method Summary
`static long` | `convertTweetDateToLong(java.lang.String date)` Convert a given date according to a format used by Twitter to long.
`static java.lang.String` | `encode(java.lang.String s, java.lang.String enc)` Encode a given string.
`static java.lang.String` | `formatTweetID(java.lang.String id)` Format the Tweet ID returned by Twitter Search API.
`static boolean` | `isEmpty(java.lang.String str)` Verify whether the given string is null or empty.
`static java.lang.String` | `removeTags(java.lang.String str)` Remove any tag occurrence from the given string.
`static java.lang.String[]` | `split(java.lang.String str, char delimiter)` Split a string based on a given delimiter.
`static java.lang.String[]` | `splitTweetAuthorNames(java.lang.String name)` Split the author's username and name from the given string, according to the format: " ()".
`static java.lang.String` | `zeroPad(int n, int len)` Return a padded string with leading zeros.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### convertTweetDateToLong

    public static long convertTweetDateToLong(java.lang.String date)

  Convert a given date according to a format used by Twitter to long.

  Formats:

  - 2009-11-28 21:43:12
  - 2009-12-01T01:25:00+00:00
  - Sat Nov 07 21:30:03 +0000 2009

  Parameters:
    `date` - Tweet date value.
  Returns:
    Long date.
  Throws:
    `java.lang.IllegalArgumentException` - If date is null/empty.

### split

    public static final java.lang.String[] split(java.lang.String str,
                                                 char delimiter)

  Split a string based on a given delimiter.

  Parameters:
    `str` - String.
    `delimiter` - Delimiter.
  Returns:
    String tokens.
  Throws:
    `java.lang.IllegalArgumentException` - If str is null.

### formatTweetID

    public static java.lang.String formatTweetID(java.lang.String id)

  Format the Tweet ID returned by Twitter Search API.

  Parameters:
    `id` - Tweet ID.
  Returns:
    ID (e.g. 18738430989).
  Throws:
    `java.lang.IllegalArgumentException` - If ID is null.

### removeTags

    public static java.lang.String removeTags(java.lang.String str)

  Remove any tag occurrence from the given string.

  Parameters:
    `str` - String to be parsed.
  Returns:
    String with no tags.
  Throws:
    `java.lang.IllegalArgumentException` - If str is null.

### splitTweetAuthorNames

    public static java.lang.String[] splitTweetAuthorNames(java.lang.String name)

  Split the author's username and name from the given string, according to the format: " ()".

  Parameters:
    `name` - The name.
  Returns:
    The username [0] and full name [1].
  Throws:
    `java.lang.IllegalArgumentException` - If str is null.

### zeroPad

    public static java.lang.String zeroPad(int n,
                                           int len)

  Return a padded string with leading zeros.

  Parameters:
    `n` - Number.
    `len` - String length.
  Returns:
    Padded string.

### encode

    public static java.lang.String encode(java.lang.String s,
                                          java.lang.String enc)

  Encode a given string. If encode type is not informed, UTF-8 is considered.

  Parameters:
    `s` - String to encode.
    `enc` - Encode.
  Returns:
    Encoded string.
  Throws:
    `java.lang.IllegalArgumentException` - If string is empty or null.

### isEmpty

    public static final boolean isEmpty(java.lang.String str)

  Verify whether the given string is null or empty.

  Parameters:
    `str` - The string.
  Returns:
    true null/empty.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Twitter API ME Team. All Rights Reserved.