|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.utils.SdkUtils
public class SdkUtils
Miscellaneous utilities used by the Android SDK tools
Field Summary | |
---|---|
static java.lang.String |
FILENAME_PREFIX
Prefix in comments which mark the source locations for merge results |
Constructor Summary | |
---|---|
SdkUtils()
|
Method Summary | |
---|---|
static void |
copyXmlWithSourceReference(java.io.File from,
java.io.File to)
Copies the given XML file to the given new path. |
static java.lang.String |
createPathComment(java.io.File file,
boolean includePadding)
Creates the path comment XML string. |
static boolean |
endsWith(java.lang.CharSequence sequence,
java.lang.CharSequence suffix)
Returns true if the given sequence ends with the given suffix (case sensitive). |
static boolean |
endsWith(java.lang.CharSequence sequence,
int endOffset,
java.lang.CharSequence suffix)
Returns true if the given sequence ends at the given offset with the given suffix (case sensitive) |
static boolean |
endsWithIgnoreCase(java.lang.String string,
java.lang.String suffix)
Returns true if the given string ends with the given suffix, using a case-insensitive comparison. |
static java.net.URL |
fileToUrl(java.io.File file)
Returns the corresponding URL for the given File |
static java.lang.String |
fileToUrlString(java.io.File file)
Returns the corresponding URL string for the given File |
static java.lang.String |
getLineSeparator()
Returns the default line separator to use. |
static boolean |
hasUpperCaseCharacter(java.lang.String s)
Returns true if the given string has an upper case character. |
static double |
parseLocalizedDouble(java.lang.String string)
Returns the given localized string as a double. |
static double |
parseLocalizedDouble(java.lang.String string,
double defaultValue)
Returns the given localized string as a double. |
static int |
parseLocalizedInt(java.lang.String string)
Returns the given localized string as an int. |
static int |
parseLocalizedInt(java.lang.String string,
int defaultValue)
Returns the given localized string as an int. |
static boolean |
startsWith(java.lang.String string,
int offset,
java.lang.String prefix)
Returns true if the given string starts at the given offset with the given prefix, case insensitively. |
static boolean |
startsWithIgnoreCase(java.lang.String string,
java.lang.String prefix)
Returns true if the given string starts with the given prefix, using a case-insensitive comparison. |
static java.lang.String |
stripWhitespace(java.lang.String string)
Strips the whitespace from the given string |
static java.io.File |
urlToFile(java.lang.String url)
Returns the corresponding File for the given file:// url |
static java.io.File |
urlToFile(java.net.URL url)
|
static java.lang.String |
wrap(java.lang.String text,
int lineWidth,
java.lang.String hangingIndent)
Wraps the given text at the given line width, with an optional hanging indent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FILENAME_PREFIX
Constructor Detail |
---|
public SdkUtils()
Method Detail |
---|
public static boolean endsWithIgnoreCase(@NonNull java.lang.String string, @NonNull java.lang.String suffix)
string
- the full string to be checkedsuffix
- the suffix to be checked for
public static boolean endsWith(@NonNull java.lang.CharSequence sequence, @NonNull java.lang.CharSequence suffix)
sequence
- the character sequence to be checkedsuffix
- the suffix to look for
public static boolean endsWith(@NonNull java.lang.CharSequence sequence, int endOffset, @NonNull java.lang.CharSequence suffix)
sequence
- the character sequence to be checkedendOffset
- the offset at which the sequence is considered to endsuffix
- the suffix to look for
public static boolean startsWithIgnoreCase(@NonNull java.lang.String string, @NonNull java.lang.String prefix)
string
- the full string to be checkedprefix
- the prefix to be checked for
public static boolean startsWith(@NonNull java.lang.String string, int offset, @NonNull java.lang.String prefix)
string
- the full string to be checkedoffset
- the offset in the string to start lookingprefix
- the prefix to be checked for
public static java.lang.String stripWhitespace(@NonNull java.lang.String string)
string
- the string to be cleaned up
public static boolean hasUpperCaseCharacter(@NonNull java.lang.String s)
s
- the string to check
@NonNull public static java.lang.String getLineSeparator()
NOTE: If you have an associated IDocument (Eclipse), it is better to call TextUtilities#getDefaultLineDelimiter(IDocument) since that will allow (for example) editing a \r\n-delimited document on a \n-delimited platform and keep a consistent usage of delimiters in the file.
@NonNull public static java.lang.String wrap(@NonNull java.lang.String text, int lineWidth, @Nullable java.lang.String hangingIndent)
text
- the text to be wrappedlineWidth
- the number of characters to wrap the text tohangingIndent
- the hanging indent (to be used for the second and
subsequent lines in each paragraph, or null if not known
public static int parseLocalizedInt(@NonNull java.lang.String string) throws java.text.ParseException
To parse a string without catching parser exceptions, call
parseLocalizedInt(String, int)
instead, passing the
default value to be returned if the format is invalid.
string
- the string to be parsed
java.text.ParseException
- if the format is not correctpublic static int parseLocalizedInt(@NonNull java.lang.String string, int defaultValue)
string
- the string to be parseddefaultValue
- the value to be returned if there is a parsing error
public static double parseLocalizedDouble(@NonNull java.lang.String string) throws java.text.ParseException
To parse a string without catching parser exceptions, call
parseLocalizedDouble(String, double)
instead, passing the
default value to be returned if the format is invalid.
string
- the string to be parsed
java.text.ParseException
- if the format is not correctpublic static double parseLocalizedDouble(@NonNull java.lang.String string, double defaultValue)
string
- the string to be parseddefaultValue
- the value to be returned if there is a parsing error
@NonNull public static java.io.File urlToFile(@NonNull java.lang.String url) throws java.net.MalformedURLException
File
for the given file:// url
url
- the URL string, e.g. file://foo/bar
File
(which may or may not exist)
java.net.MalformedURLException
- if the URL string is malformed or is not a file: URL@NonNull public static java.io.File urlToFile(@NonNull java.net.URL url) throws java.net.MalformedURLException
java.net.MalformedURLException
public static java.lang.String fileToUrlString(@NonNull java.io.File file) throws java.net.MalformedURLException
File
file
- the file to look up the URL for
java.net.MalformedURLException
- in very unexpected casespublic static java.net.URL fileToUrl(@NonNull java.io.File file) throws java.net.MalformedURLException
File
file
- the file to look up the URL for
java.net.MalformedURLException
- in very unexpected casespublic static java.lang.String createPathComment(@NonNull java.io.File file, boolean includePadding) throws java.net.MalformedURLException
Document.createComment(String)
)
file
- the file to create a path comment forincludePadding
- whether to include padding. The final comment recognized by
error recognizers expect padding between the <!--
and
the start marker (From:); you can disable padding if the caller
already is in a context where the padding has been added.
java.net.MalformedURLException
public static void copyXmlWithSourceReference(@NonNull java.io.File from, @NonNull java.io.File to) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |