FileDocCategorySizeDatePackage
NetworkCodeQualifier.javaAPI DocAndroid 1.5 API4662Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.resources.configurations

NetworkCodeQualifier

public final class NetworkCodeQualifier extends ResourceQualifier
Resource Qualifier for Mobile Network Code Pixel Density.

Fields Summary
private static final int
DEFAULT_CODE
Default pixel density value. This means the property is not set.
private static final Pattern
sNetworkCodePattern
private int
mCode
public static final String
NAME
Constructors Summary
Methods Summary
public booleancheckAndSet(java.lang.String value, FolderConfiguration config)

        Matcher m = sNetworkCodePattern.matcher(value);
        if (m.matches()) {
            String v = m.group(1);

            int code = -1;
            try {
                code = Integer.parseInt(v);
            } catch (NumberFormatException e) {
                // looks like the string we extracted wasn't a valid number.
                return false;
            }
            
            NetworkCodeQualifier qualifier = new NetworkCodeQualifier();
            qualifier.mCode = code;
            config.setNetworkCodeQualifier(qualifier);
            return true;
        }
        
        return false;
    
public booleanequals(java.lang.Object qualifier)

        if (qualifier instanceof NetworkCodeQualifier) {
            return mCode == ((NetworkCodeQualifier)qualifier).mCode;
        }
        
        return false;
    
public intgetCode()

        return mCode;
    
public static java.lang.StringgetFolderSegment(int code)
Returns the folder name segment for the given value. This is equivalent to calling {@link #toString()} on a {@link NetworkCodeQualifier} object.

param
code the value of the qualifier, as returned by {@link #getCode()}.

        if (code != DEFAULT_CODE && code >= 1 && code <= 999) { // code is 1-3 digit.
            return String.format("mnc%1$d", code); //$NON-NLS-1$
        }
        
        return ""; //$NON-NLS-1$
    
public org.eclipse.swt.graphics.ImagegetIcon()

        return IconFactory.getInstance().getIcon("mnc"); //$NON-NLS-1$
    
public java.lang.StringgetName()

        return NAME;
    
public static com.android.ide.eclipse.editors.resources.configurations.NetworkCodeQualifiergetQualifier(java.lang.String segment)
Creates and returns a qualifier from the given folder segment. If the segment is incorrect, null is returned.

param
segment the folder segment from which to create a qualifier.
return
a new {@link CountryCodeQualifier} object or null

    
                                              
         
        Matcher m = sNetworkCodePattern.matcher(segment);
        if (m.matches()) {
            String v = m.group(1);

            int code = -1;
            try {
                code = Integer.parseInt(v);
            } catch (NumberFormatException e) {
                // looks like the string we extracted wasn't a valid number.
                return null;
            }
            
            NetworkCodeQualifier qualifier = new NetworkCodeQualifier();
            qualifier.mCode = code;
            return qualifier;
        }

        return null;
    
public java.lang.StringgetShortName()

        return "Network Code";
    
public java.lang.StringgetStringValue()

        if (mCode != DEFAULT_CODE) {
            return String.format("MNC %1$d", mCode);
        }
        
        return ""; //$NON-NLS-1$
    
public inthashCode()

        return mCode;
    
public booleanisValid()

        return mCode != DEFAULT_CODE;
    
public java.lang.StringtoString()
Returns the string used to represent this qualifier in the folder name.

        return getFolderSegment(mCode);