com.android.ide.common.res2
Class FileResourceNameValidator

java.lang.Object
  extended by com.android.ide.common.res2.FileResourceNameValidator

public final class FileResourceNameValidator
extends java.lang.Object


Method Summary
static java.lang.String getErrorTextForFileResource(java.lang.String fileNameWithExt, com.android.resources.ResourceType resourceType)
          Validate a single-file resource name.
static java.lang.String getErrorTextForNameWithoutExtension(java.lang.String fileNameWithoutExt)
          Validate a single-file resource name.
static java.lang.String getErrorTextForPartialName(java.lang.String partialFileNameWithExt, com.android.resources.ResourceType resourceType)
          Validate a file-based resource name as it is being typed in a text field.
static void validate(java.io.File file, com.android.resources.ResourceType resourceType)
          Validate a single-file resource name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validate

public static void validate(@NonNull
                            java.io.File file,
                            @NonNull
                            com.android.resources.ResourceType resourceType)
                     throws MergingException
Validate a single-file resource name.

Parameters:
file - the file resource to validate.
resourceType - the resource type.
Throws:
MergingException - is the resource name is not valid.

getErrorTextForFileResource

@Nullable
public static java.lang.String getErrorTextForFileResource(@NonNull
                                                                    java.lang.String fileNameWithExt,
                                                                    @NonNull
                                                                    com.android.resources.ResourceType resourceType)
Validate a single-file resource name.

Parameters:
fileNameWithExt - the resource file name to validate.
resourceType - the resource type.
Returns:
null if no error, otherwise a string describing the error.

getErrorTextForPartialName

@Nullable
public static java.lang.String getErrorTextForPartialName(@NonNull
                                                                   java.lang.String partialFileNameWithExt,
                                                                   @NonNull
                                                                   com.android.resources.ResourceType resourceType)
Validate a file-based resource name as it is being typed in a text field. Partial or no extensions are allowed, so the user does not see errors while typing.

Parameters:
partialFileNameWithExt - the resource file name or prefix of file name to validate.
resourceType - the resource type.
Returns:
null if no error, otherwise a string describing the error.

getErrorTextForNameWithoutExtension

@Nullable
public static java.lang.String getErrorTextForNameWithoutExtension(@NonNull
                                                                            java.lang.String fileNameWithoutExt)
Validate a single-file resource name.

Parameters:
fileNameWithoutExt - The resource file name to validate, without an extension.
Returns:
null if no error, otherwise a string describing the error.