fr.obeo.acceleo.gen.template.scripts.imports.services
Class StringServices


public class StringServices
extends java.lang.Object

System services for String elements.


Constructor Summary
StringServices()
           
 
Method Summary
 java.lang.String charAt(java.lang.String s, int index)
          Gets the char at a given position.
 boolean endsWith(java.lang.String s, java.lang.String arg)
          Indicates if a string ends with a given substring.
 boolean equals(java.lang.String s, java.lang.String arg)
          Indicates if two strings are equal (case sensitive).
 boolean equalsIgnoreCase(java.lang.String s, java.lang.String arg)
          Indicates if two strings are equal, ignoring case.
 int indexOf(java.lang.String buffer, java.lang.String arg)
          Returns the position of a substring in a string.
 int indexOf(java.lang.String buffer, java.lang.String arg, int index)
          Returns the position of a substring a the string, starting at a specified position.
 int lastIndexOf(java.lang.String buffer, java.lang.String arg)
          Returns the last position of a substring in a string.
 int lastIndexOf(java.lang.String buffer, java.lang.String arg, int index)
          Returns the last position of a substring in a string, starting at a specified position.
 int length(java.lang.String s)
          Returns the string's length
 boolean matches(java.lang.String s, java.lang.String regex)
          Indicates if a string matches a regex.
 java.lang.String replaceAll(java.lang.String buffer, java.lang.String s1, java.lang.String s2)
          Replaces all occurences of substring by another substring in a string.
 java.lang.String replaceFirst(java.lang.String buffer, java.lang.String s1, java.lang.String s2)
          Replaces the first occurence of a substring by another substring in a string.
 java.util.List split(java.lang.String buffer, java.lang.String arg)
          Splits a string with a substring.
 boolean startsWith(java.lang.String s, java.lang.String arg)
          Indicates if a string starts with a given substring.
 java.lang.String substring(java.lang.String s, int begin)
          Gets a substring of a string that begins at a specified index and ends at the end of the string.
 java.lang.String substring(java.lang.String s, int begin, int end)
          Returns a substring of a string that begins at a specified index and ends at end - 1.
 java.lang.String toLowerCase(java.lang.String s)
          Returns a lower case representation of a string.
 java.lang.String toUpperCase(java.lang.String s)
          Returns an upper case representation of a string.
 java.lang.String trim(java.lang.String s)
          Removes leading and trailing spaces of a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringServices

public StringServices()
Method Detail

charAt

public java.lang.String charAt(java.lang.String s,
                               int index)
Gets the char at a given position.

Parameters:
s - is the string
index - is the position
Returns:
the char at the given position

endsWith

public boolean endsWith(java.lang.String s,
                        java.lang.String arg)
Indicates if a string ends with a given substring.

Parameters:
s - is the string
arg - is the substring
Returns:
true if the string ends with the given substring

equals

public boolean equals(java.lang.String s,
                      java.lang.String arg)
Indicates if two strings are equal (case sensitive).

Parameters:
s - is the first string
arg - is the second string
Returns:
true if the two strings are equal

equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.String s,
                                java.lang.String arg)
Indicates if two strings are equal, ignoring case.

Parameters:
s - is the first string
arg - is the second string
Returns:
true if the two strings are equal

indexOf

public int indexOf(java.lang.String buffer,
                   java.lang.String arg)
Returns the position of a substring in a string.

Parameters:
buffer - is the string
arg - is the substring
Returns:
the position of the substring

indexOf

public int indexOf(java.lang.String buffer,
                   java.lang.String arg,
                   int index)
Returns the position of a substring a the string, starting at a specified position.

Parameters:
buffer - is the string
arg - is the substring
index - is the position where the research starts form
Returns:
the position of the substring

lastIndexOf

public int lastIndexOf(java.lang.String buffer,
                       java.lang.String arg)
Returns the last position of a substring in a string.

Parameters:
buffer - is the string
arg - is the substring
Returns:
the last position of the substring

lastIndexOf

public int lastIndexOf(java.lang.String buffer,
                       java.lang.String arg,
                       int index)
Returns the last position of a substring in a string, starting at a specified position.

Parameters:
buffer - is the string
arg - is the substring
index - is the position where the research starts form
Returns:
the last position of the substring

length

public int length(java.lang.String s)
Returns the string's length

Parameters:
s - is the string
Returns:
the string's length

matches

public boolean matches(java.lang.String s,
                       java.lang.String regex)
Indicates if a string matches a regex.

Parameters:
s - is the string
regex - is the regex
Returns:
true if the string matches with the given regex

replaceAll

public java.lang.String replaceAll(java.lang.String buffer,
                                   java.lang.String s1,
                                   java.lang.String s2)
Replaces all occurences of substring by another substring in a string.

Parameters:
buffer - is the buffer
s1 - is the substring to replace
s2 - is the new substring
Returns:
the new string

replaceFirst

public java.lang.String replaceFirst(java.lang.String buffer,
                                     java.lang.String s1,
                                     java.lang.String s2)
Replaces the first occurence of a substring by another substring in a string.

Parameters:
buffer - is the buffer
s1 - is the substring to replace
s2 - is the new substring
Returns:
the new string

split

public java.util.List split(java.lang.String buffer,
                            java.lang.String arg)
Splits a string with a substring.

Parameters:
buffer - is the string
arg - is the substring
Returns:
a list that contains the splitted string

startsWith

public boolean startsWith(java.lang.String s,
                          java.lang.String arg)
Indicates if a string starts with a given substring.

Parameters:
s - is the string
arg - is the substring
Returns:
true if the string starts with the given substring

substring

public java.lang.String substring(java.lang.String s,
                                  int begin)
Gets a substring of a string that begins at a specified index and ends at the end of the string.

Parameters:
s - is the string
begin - is the beginning index, inclusive
Returns:
the substring

substring

public java.lang.String substring(java.lang.String s,
                                  int begin,
                                  int end)
Returns a substring of a string that begins at a specified index and ends at end - 1.

Parameters:
s - is the string
begin - is the beginning index, inclusive
end - is the ending index, exclusive
Returns:
the substring

toLowerCase

public java.lang.String toLowerCase(java.lang.String s)
Returns a lower case representation of a string.

Parameters:
s - is the string
Returns:
the lower case representation

toUpperCase

public java.lang.String toUpperCase(java.lang.String s)
Returns an upper case representation of a string.

Parameters:
s - is the string
Returns:
the upper case representation

trim

public java.lang.String trim(java.lang.String s)
Removes leading and trailing spaces of a string.

Parameters:
s - is the string
Returns:
the string without leading and trailing spaces