public class SdkUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FILENAME_PREFIX
Prefix in comments which mark the source locations for merge results
|
static java.util.List<java.lang.String> |
IMAGE_EXTENSIONS |
| Constructor and Description |
|---|
SdkUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
camelCaseToConstantName(java.lang.String camelCaseName)
Translates a camel case name (e.g.
|
static java.lang.String |
constantNameToCamelCase(java.lang.String constantName)
Translates a Java / C++ constant name (e.g.
|
static java.lang.String |
constantNameToXmlName(java.lang.String constantName)
Translates a Java / C++ constant name (e.g.
|
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.lang.String |
escapePropertyValue(java.lang.String value)
Escapes the given property file value (right hand side of property assignment)
as required by the property file format (e.g.
|
static java.lang.String |
fileNameToResourceName(java.lang.String fileName)
Returns the basename of the given filename, unless it's a dot-file such as ".svn".
|
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 |
getResourceFieldName(java.lang.String resourceName)
Get the R field name from a resource name, since
AAPT will flatten the namespace, turning dots, dashes and colons into _
|
static java.lang.String |
globToRegexp(java.lang.String glob) |
static boolean |
hasImageExtension(java.lang.String path)
Returns true if the given file path points to an image file recognized by
Android.
|
static boolean |
isBitmapFile(java.io.File file)
Returns true if the given file represents a bitmap drawable file
|
static boolean |
isServiceKey(java.lang.String name) |
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.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 firstLineWidth,
int nextLineWidth,
java.lang.String hangingIndent)
Wraps the given text at the given line width, with an optional hanging
indent.
|
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.
|
static java.lang.String |
xmlNameToConstantName(java.lang.String xmlName)
Translates an XML name (e.g.
|
public static final java.lang.String FILENAME_PREFIX
public static final java.util.List<java.lang.String> IMAGE_EXTENSIONS
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 forpublic static boolean endsWith(@NonNull
java.lang.CharSequence sequence,
@NonNull
java.lang.CharSequence suffix)
sequence - the character sequence to be checkedsuffix - the suffix to look forpublic 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 forpublic 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@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@NonNull
public static java.lang.String wrap(@NonNull
java.lang.String text,
int firstLineWidth,
int nextLineWidth,
@Nullable
java.lang.String hangingIndent)
text - the text to be wrappedfirstLineWidth - the line width to wrap the text to (on the first line)nextLineWidth - the line width to wrap the text to (on subsequent lines).
This does not include the hanging indent, if any.hangingIndent - the hanging indent (to be used for the second and
subsequent lines in each paragraph, or null if not known@NonNull
public static java.io.File urlToFile(@NonNull
java.lang.String url)
throws java.net.MalformedURLException
File for the given file:// urlurl - the URL string, e.g. file://foo/barFile (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.MalformedURLExceptionpublic static java.lang.String fileToUrlString(@NonNull
java.io.File file)
throws java.net.MalformedURLException
Filefile - the file to look up the URL forjava.net.MalformedURLException - in very unexpected casespublic static java.net.URL fileToUrl(@NonNull
java.io.File file)
throws java.net.MalformedURLException
Filefile - the file to look up the URL forjava.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.MalformedURLExceptionpublic static java.lang.String xmlNameToConstantName(java.lang.String xmlName)
xmlName - the hyphen separated lower case xml name.public static java.lang.String camelCaseToConstantName(java.lang.String camelCaseName)
camelCaseName - the camel case name.public static java.lang.String constantNameToCamelCase(java.lang.String constantName)
constantName - the constant name.public static java.lang.String constantNameToXmlName(java.lang.String constantName)
constantName - the constant name.@NonNull
public static java.lang.String getResourceFieldName(@NonNull
java.lang.String resourceName)
resourceName - the name to convertpublic static java.lang.String fileNameToResourceName(@NonNull
java.lang.String fileName)
fileName - the file name to extract the basename frompublic static boolean hasImageExtension(java.lang.String path)
path - the filename to be testedpublic static boolean isBitmapFile(@NonNull
java.io.File file)
file - the file to be checked@NonNull
public static java.lang.String escapePropertyValue(@NonNull
java.lang.String value)
value - the value to be escaped@NonNull
public static java.lang.String globToRegexp(@NonNull
java.lang.String glob)
public static boolean isServiceKey(@NonNull
java.lang.String name)