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

ScreenDimensionQualifier

public final class ScreenDimensionQualifier extends ResourceQualifier
Resource Qualifier for Screen Dimension.

Fields Summary
static final int
DEFAULT_SIZE
Default screen size value. This means the property is not set
private static final Pattern
sDimensionPattern
public static final String
NAME
private int
mValue1
Screen size 1 value. This is not size X or Y because the folder name always contains the biggest size first. So if the qualifier is 400x200, size 1 will always be 400 but that'll be X in landscape and Y in portrait. Default value is DEFAULT_SIZE
private int
mValue2
Screen size 2 value. This is not size X or Y because the folder name always contains the biggest size first. So if the qualifier is 400x200, size 2 will always be 200 but that'll be Y in landscape and X in portrait. Default value is DEFAULT_SIZE
Constructors Summary
Methods Summary
public booleancheckAndSet(java.lang.String value, FolderConfiguration config)

        Matcher m = sDimensionPattern.matcher(value);
        if (m.matches()) {
            String d1 = m.group(1);
            String d2 = m.group(2);
            
            ScreenDimensionQualifier qualifier = getQualifier(d1, d2);
            if (qualifier != null) {
                config.setScreenDimensionQualifier(qualifier);
                return true;
            }
        }
        return false;
    
public booleanequals(java.lang.Object qualifier)

        if (qualifier instanceof ScreenDimensionQualifier) {
            ScreenDimensionQualifier q = (ScreenDimensionQualifier)qualifier;
            return (mValue1 == q.mValue1 && mValue2 == q.mValue2);
        }
        
        return false;
    
public org.eclipse.swt.graphics.ImagegetIcon()

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

        return NAME;
    
public static com.android.ide.eclipse.editors.resources.configurations.ScreenDimensionQualifiergetQualifier(java.lang.String size1, java.lang.String size2)

        try {
            int s1 = Integer.parseInt(size1);
            int s2 = Integer.parseInt(size2);
            
            ScreenDimensionQualifier qualifier = new ScreenDimensionQualifier();

            if (s1 > s2) {
                qualifier.mValue1 = s1;
                qualifier.mValue2 = s2;
            } else {
                qualifier.mValue1 = s2;
                qualifier.mValue2 = s1;
            }

            return qualifier;
        } catch (NumberFormatException e) {
            // looks like the string we extracted wasn't a valid number.
        }
        
        return null;
    
public java.lang.StringgetShortName()

        return "Dimension";
    
public java.lang.StringgetStringValue()

        if (mValue1 != -1 && mValue2 != -1) {
            return String.format("%1$dx%2$d", mValue1, mValue2);
        }
        
        return ""; //$NON-NLS-1$
    
public intgetValue1()

    
       
        return mValue1;
    
public intgetValue2()

        return mValue2;
    
public inthashCode()

        return toString().hashCode();
    
public booleanisValid()

        return mValue1 != DEFAULT_SIZE && mValue2 != DEFAULT_SIZE;
    
public java.lang.StringtoString()
Returns the string used to represent this qualifier in the folder name.

        return String.format("%1$dx%2$d", mValue1, mValue2); //$NON-NLS-1$