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

PixelDensityQualifier

public final class PixelDensityQualifier extends ResourceQualifier
Resource Qualifier for Screen Pixel Density.

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

        PixelDensityQualifier qualifier = getQualifier(value);
        if (qualifier != null) {
            config.setPixelDensityQualifier(qualifier);
            return true;
        }
        
        return false;
    
public booleanequals(java.lang.Object qualifier)

        if (qualifier instanceof PixelDensityQualifier) {
            return mValue == ((PixelDensityQualifier)qualifier).mValue;
        }
        
        return false;
    
public static java.lang.StringgetFolderSegment(int value)
Returns the folder name segment for the given value. This is equivalent to calling {@link #toString()} on a {@link NetworkCodeQualifier} object.

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

        if (value != DEFAULT_DENSITY) {
            return String.format("%1$ddpi", value); //$NON-NLS-1$
        }
        
        return ""; //$NON-NLS-1$
    
public org.eclipse.swt.graphics.ImagegetIcon()

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

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

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

    
                                              
         
        Matcher m = sPixelDensityPattern.matcher(folderSegment);
        if (m.matches()) {
            String v = m.group(1);

            int density = -1;
            try {
                density = Integer.parseInt(v);
            } catch (NumberFormatException e) {
                // looks like the string we extracted wasn't a valid number.
                return null;
            }
            
            PixelDensityQualifier qualifier = new PixelDensityQualifier();
            qualifier.mValue = density;
            
            return qualifier;
        }
        return null;
    
public java.lang.StringgetShortName()

        return NAME;
    
public java.lang.StringgetStringValue()

        if (mValue != DEFAULT_DENSITY) {
            return String.format("%1$d dpi", mValue);
        }
        
        return ""; //$NON-NLS-1$
    
public intgetValue()

        return mValue;
    
public inthashCode()

        return mValue;
    
public booleanisValid()

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

        return getFolderSegment(mValue);