Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2007-2015 Mozilla Foundation
   *
   * Permission is hereby granted, free of charge, to any person obtaining a 
   * copy of this software and associated documentation files (the "Software"), 
   * to deal in the Software without restriction, including without limitation 
   * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
   * and/or sell copies of the Software, and to permit persons to whom the 
   * Software is furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in 
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
  */
 
 package nu.validator.datatype;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 public class MediaQuery extends AbstractDatatype {

    
The singleton instance.
 
     public static final MediaQuery THE_INSTANCE = new MediaQuery();
 
     private static final boolean WARN = System.getProperty(
             "nu.validator.datatype.warn""").equals("true") ? true : false;
 
     private enum State {
         INITIAL_WS, OPEN_PAREN_SEEN, IN_ONLY_OR_NOT, IN_MEDIA_TYPE, IN_MEDIA_FEATURE, WS_BEFORE_MEDIA_TYPE, WS_BEFORE_MEDIA_FEATURE, WS_BEFORE_AND, IN_AND, WS_BEFORE_EXPRESSION, WS_BEFORE_COLON, WS_BEFORE_VALUE, IN_VALUE_DIGITS, BEFORE_CALC_OPEN_PAREN, IN_CALC, IN_VALUE_SCAN, IN_VALUE_ORIENTATION, WS_BEFORE_CLOSE_PAREN, IN_VALUE_UNIT, IN_VALUE_DIGITS_AFTER_DOT, RATIO_SECOND_INTEGER_START, IN_VALUE_BEFORE_DIGITS, IN_VALUE_DIGITS_AFTER_DOT_TRAIL, AFTER_CLOSE_PAREN, IN_VALUE_ONEORZERO
     }
 
     private enum ValueType {
         LENGTH, RATIO, INTEGER, RESOLUTION, SCAN, ORIENTATION, NONZEROINTEGER, ONEORZERO
     }
 
     private static final Set<StringLENGTH_UNITS = new HashSet<String>();
 
     static {
         .add("em");
         .add("ex");
         .add("px");
         .add("gd");
         .add("rem");
         .add("vw");
         .add("vh");
         .add("vm");
         .add("ch");
         .add("in");
         .add("cm");
         .add("mm");
         .add("pt");
         .add("pc");
     }
 
     private static final Set<StringMEDIA_TYPES = new HashSet<String>();
 
     static {
         .add("all");
         .add("print");
         .add("screen");
         .add("speech");
     }
 
     private enum MediaType {
         ALL, PRINT, SCREEN, SPEECH, INVALID;
         private static MediaType toCaps(String str) {
             try {
                 return valueOf(toAsciiUpperCase(str));
             } catch (Exception ex) {
                 return ;
             }
         }
     }
 
     private static final Map<StringValueTypeFEATURES_TO_VALUE_TYPES = new HashMap<StringValueType>();
 
     static {
         .put("width".);
         .put("min-width".);
         .put("max-width".);
         .put("height".);
         .put("min-height".);
         .put("max-height".);
        .put("aspect-ratio".);
        .put("min-aspect-ratio".);
        .put("max-aspect-ratio".);
        .put("color".);
        .put("min-color".);
        .put("max-color".);
        .put("color-index".);
        .put("min-color-index".);
        .put("max-color-index".);
        .put("monochrome".);
        .put("min-monochrome".);
        .put("max-monochrome".);
        .put("resolution".);
        .put("min-resolution".);
        .put("max-resolution".);
        .put("scan".);
        .put("orientation".);
    }
    private static final Map<StringValueTypeNONSTANDARD_FEATURES_TO_VALUE_TYPES = new HashMap<StringValueType>();
    static {
                "-webkit-min-device-pixel-ratio".);
    }
    protected MediaQuery() {
        super();
    }
    @Override public void checkValid(CharSequence literal)
            throws DatatypeException {
        List<Stringwarnings = new ArrayList<String>();
        List<CharSequenceWithOffsetqueries = split(literal',');
        for (CharSequenceWithOffset query : queries) {
            warnings = checkQuery(query.getSequence(), query.getOffset(),
                    warnings);
        }
        if (!warnings.isEmpty() && ) {
            StringBuilder sb = new StringBuilder();
            for (String s : warnings) {
                sb.append(s + " ");
            }
            throw newDatatypeException(sb.toString().trim(), );
        }
    }
    private List<StringcheckQuery(CharSequence queryint offset,
            List<Stringwarningsthrows DatatypeException {
        int unmatchedParen = -1;
        int unmatchedCalcParen = -1;
        boolean zero = true;
        String type = null;
        String feature = null;
        ValueType valueExpectation = null;
        query = toAsciiLowerCase(query);
        StringBuilder sb = new StringBuilder();
        State state = .;
        for (int i = 0; i < query.length(); i++) {
            char c = query.charAt(i);
            switch (state) {
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('(' == c) {
                        state = .;
                        continue;
                    } else if ('o' == c || 'n' == c) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(
                                offset + i,
                                "Expected \u201C(\u201D or letter at start of a media query part but saw ",
                                c" instead.");
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c)) {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if ("only".equals(kw)) {
                            if (isMediaCondition()) {
                                throw newDatatypeException(offset + i,
                                        "Expected a CSS media condition (not a"
                                                + " CSS media type) but saw"
                                                + " \u201Conly\u201D instead.");
                            }
                            state = .;
                            continue;
                        } else if ("not".equals(kw)) {
                            if (isMediaCondition()) {
                                state = .;
                            } else {
                                state = .;
                            }
                            continue;
                        } else {
                            throw newDatatypeException(offset + i,
                                    "Expected \u201Conly\u201D or \u201Cnot\u201D but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('(' == c) {
                        state = .;
                        continue;
                    } else if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected \u201C(\u201D or"
                                        + " whitespace but saw \u201C" + c
                                        + "\u201D instead.");
                    }
                case :
                    if (('a' <= c && 'z' >= c) || c == '-') {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c)) {
                        /*
                         * store media type for later media-feature
                         * applicability check
                         */
                        type = sb.toString();
                        sb.setLength(0);
                        if (isMediaCondition()) {
                            errNotMediaCondition(type);
                        }
                        if (isMediaType(type)) {
                            state = .;
                            continue;
                        } else {
                            throw newDatatypeException(offset + i,
                                    "Expected a CSS media type but saw \u201C"
                                            + type + "\u201D instead.");
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter, hyphen or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('a' == c) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected whitespace or \u201Cand\u201D but saw"
                                        + " \u201C" + c + "\u201D instead.");
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c)) {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if ("and".equals(kw)) {
                            state = .;
                            continue;
                        } else {
                            throw newDatatypeException(offset + i,
                                    "Expected \u201Cand\u201D but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('(' == c) {
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected \u201C(\u201D or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('(' == c) {
                        unmatchedParen++;
                        continue;
                    } else if ('-' == c || ('a' <= c && 'z' >= c)) {
                        sb.append(c);
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter at start of a media feature part but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (('a' <= c && 'z' >= c) || c == '-') {
                        sb.append(c);
                        continue;
                    } else if (c == ')') {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if (!isMediaCondition()) {
                            checkApplicability(offset + ikwtypewarnings);
                        }
                        checkIfValueRequired(offset + ikw);
                        state = .;
                        continue;
                    } else if (isWhitespace(c) || c == ':') {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if (!isMediaCondition()) {
                            checkApplicability(offset + ikwtypewarnings);
                        }
                        feature = kw;
                        valueExpectation = valueExpectationFor(kw) != null ? valueExpectationFor(kw)
                                : nonstandardValueExpectationFor(kw);
                        if (valueExpectation != null) {
                            if (c == ':') {
                                state = .;
                                continue;
                            } else {
                                state = .;
                                continue;
                            }
                        } else {
                            throw newDatatypeException(offset + i,
                                    "Expected a CSS media feature but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter, hyphen, colon or whitespace but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if (':' == c) {
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected whitespace or colon but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else {
                        zero = true;
                        switch (valueExpectation) {
                            case :
                                if ('a' <= c && 'z' >= c) {
                                    sb.append(c);
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a letter but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                                if ('a' <= c && 'z' >= c) {
                                    sb.append(c);
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a letter but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                                if (c == '0' || c == '1') {
                                    sb.append(c);
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(
                                            offset + i,
                                            "Expected \u201C0\u201D or \u201C1\u201D as \u201c"
                                                    + feature
                                                    + "\u201d value but found \u201C"
                                                    + c + "\u201D instead.");
                                }
                            default:
                                if ('1' <= c && '9' >= c) {
                                    zero = false;
                                    state = .;
                                    continue;
                                } else if ('0' == c) {
                                    state = .;
                                    continue;
                                } else if ('+' == c) {
                                    state = .;
                                    continue;
                                } else if ('.' == c
                                        && valueExpectation == .) {
                                    state = .;
                                    continue;
                                } else if ('c' == c) {
                                    state = .;
                                    continue;
                                } else if (valueExpectation == .) {
                                    throw newDatatypeException(offset + i,
                                            "Expected a digit, a dot or a plus sign but saw \u201C"
                                                    + c + "\u201D instead.");
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a digit or a plus sign but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                        }
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c) || c == ')') {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if (!("progressive".equals(kw) || "interlace".equals(kw))) {
                            throw newDatatypeException(
                                    offset + i,
                                    "Expected \u201Cprogressive\u201D or \u201Cinterlace\u201D as the scan mode value but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                        if (c == ')') {
                            state = .;
                            continue;
                        } else {
                            state = .;
                            continue;
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter, whitespace or \u201C)\u201D but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c) || c == ')') {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if (!("portrait".equals(kw) || "landscape".equals(kw))) {
                            throw newDatatypeException(
                                    offset + i,
                                    "Expected \u201Cportrait\u201D or \u201Clandscape\u201D as the \u201corientation\u201d value but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                        if (c == ')') {
                            state = .;
                            continue;
                        } else {
                            state = .;
                            continue;
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter, whitespace or \u201C)\u201D but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c) || c == ')') {
                        sb.setLength(0);
                        if (c == ')') {
                            state = .;
                            continue;
                        } else {
                            state = .;
                            continue;
                        }
                    } else {
                        sb.append(c);
                        String kw = sb.toString();
                        throw newDatatypeException(offset + i,
                                "Expected \u201C0\u201D or \u201C1\u201D as \u201c"
                                        + feature
                                        + "\u201d value but saw \u201C" + kw
                                        + "\u201D instead.");
                    }
                case :
                    if ('0' == c) {
                        state = .;
                        continue;
                    } else if ('1' <= c && '9' >= c) {
                        zero = false;
                        state = .;
                        continue;
                    } else {
                        switch (valueExpectation) {
                            case :
                            case :
                                if ('.' == c) {
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a dot or a digit but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                            case :
                                throw newDatatypeException(offset + i,
                                        "Expected a digit but saw \u201C" + c
                                                + "\u201D instead.");
                            default:
                                throw new RuntimeException("Impossible state.");
                        }
                    }
                case :
                    if ('0' == c) {
                        continue;
                    } else if ('1' <= c && '9' >= c) {
                        zero = false;
                        continue;
                    } else {
                        switch (valueExpectation) {
                            case :
                            case :
                                if ('.' == c) {
                                    state = .;
                                    continue;
                                } else if ('a' <= c && 'z' >= c) {
                                    sb.append(c);
                                    state = .;
                                    continue;
                                } else if (isWhitespace(c) || c == ')') {
                                    if (!zero) {
                                        if (valueExpectation == .) {
                                            throw newDatatypeException(offset
                                                    + i,
                                                    "Non-zero lengths require a unit.");
                                        } else {
                                            throw newDatatypeException(offset
                                                    + i,
                                                    "Non-zero resolutions require a unit.");
                                        }
                                    }
                                    if (c == ')') {
                                        state = .;
                                        continue;
                                    } else {
                                        state = .;
                                        continue;
                                    }
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a letter, a dot or a digit but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                                if (c == ')') {
                                    state = .;
                                    continue;
                                } else if (isWhitespace(c)) {
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a digit, whitespace or \u201C)\u201D but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                                if (c == ')') {
                                    if (zero) {
                                        throw newDatatypeException(offset + i,
                                                "Expected a non-zero positive integer.");
                                    }
                                    state = .;
                                    continue;
                                } else if (isWhitespace(c)) {
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a digit, whitespace or \u201C)\u201D but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            case :
                                if (isWhitespace(c)) {
                                    continue;
                                } else if (c == '/') {
                                    if (zero) {
                                        throw newDatatypeException(offset + i,
                                                "Expected non-zero positive integer in ratio value.");
                                    }
                                    valueExpectation = .;
                                    state = .;
                                    continue;
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a digit, whitespace or"
                                                    + " \u201C/\u201D for "
                                                    + feature
                                                    + " value but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            default:
                                throw new RuntimeException("Impossible state.");
                        }
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if ('(' == c) {
                        unmatchedCalcParen = 1;
                        String kw = sb.toString();
                        sb.setLength(0);
                        if ("alc".equals(kw)) {
                            state = .;
                            continue;
                        } else {
                            throw newDatatypeException(offset + i,
                                    "Expected \u201ccalc\u201d but saw \u201C"
                                            + kw + "\u201D instead.");
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected \u201ccalc\u201d but saw \u201C" + c
                                        + "\u201D instead.");
                    }
                case :
                    if (')' == c) {
                        if (unmatchedCalcParen == 1) {
                            unmatchedCalcParen = -1;
                            state = .;
                            continue;
                        } else {
                            unmatchedCalcParen--;
                            continue;
                        }
                    } else if ('(' == c) {
                        unmatchedCalcParen++;
                        continue;
                    } else {
                        continue;
                    }
                case :
                    if ('0' == c) {
                        state = .;
                        continue;
                    } else if ('1' <= c && '9' >= c) {
                        state = .;
                        zero = false;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a digit but saw \u201C" + c
                                        + "\u201D instead.");
                    }
                case :
                    if ('0' == c) {
                        continue;
                    } else if ('1' <= c && '9' >= c) {
                        zero = false;
                        continue;
                    } else {
                        switch (valueExpectation) {
                            case :
                            case :
                                if ('a' <= c && 'z' >= c) {
                                    sb.append(c);
                                    state = .;
                                    continue;
                                } else if (isWhitespace(c) || c == ')') {
                                    if (!zero) {
                                        if (valueExpectation == .) {
                                            throw newDatatypeException(offset
                                                    + i,
                                                    "Non-zero lengths require a unit.");
                                        } else {
                                            throw newDatatypeException(offset
                                                    + i,
                                                    "Non-zero resolutions require a unit.");
                                        }
                                    }
                                    if (c == ')') {
                                        state = .;
                                        continue;
                                    } else {
                                        state = .;
                                        continue;
                                    }
                                } else {
                                    throw newDatatypeException(offset + i,
                                            "Expected a letter, a digit, whitespace or \u201C)\u201D but saw \u201C"
                                                    + c + "\u201D instead.");
                                }
                            default:
                                throw new RuntimeException("Impossible state.");
                        }
                    }
                case :
                    if ('a' <= c && 'z' >= c) {
                        sb.append(c);
                        continue;
                    } else if (isWhitespace(c) || c == ')') {
                        String kw = sb.toString();
                        sb.setLength(0);
                        if (valueExpectation == .) {
                            if (!isLengthUnit(kw)) {
                                throw newDatatypeException(offset + i,
                                        "Expected a length unit but saw \u201C"
                                                + c + "\u201D instead.");
                            }
                        } else {
                            if (!("dpi".equals(kw) || "dpcm".equals(kw))) {
                                throw newDatatypeException(offset + i,
                                        "Expected a resolution unit but saw \u201C"
                                                + c + "\u201D instead.");
                            }
                        }
                        if (c == ')') {
                            state = .;
                            continue;
                        } else {
                            state = .;
                            continue;
                        }
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a letter, a dot or a digit but saw \u201C"
                                        + c + "\u201D instead.");
                    }
                case :
                    valueExpectation = .;
                    if (isWhitespace(c)) {
                        continue;
                    } else if ('1' <= c && '9' >= c) {
                        zero = false;
                        state = .;
                        continue;
                    } else if ('0' == c) {
                        zero = true;
                        state = .;
                        continue;
                    } else if ('+' == c) {
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected a digit, whitespace or a plus sign"
                                        + " for " + feature
                                        + " value but saw \u201C" + c
                                        + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        state = .;
                        continue;
                    } else if (')' == c) {
                        if (unmatchedParen == 1) {
                            unmatchedParen = -1;
                        } else {
                            unmatchedParen--;
                        }
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected whitespace but saw \u201C" + c
                                        + "\u201D instead.");
                    }
                case :
                    if (isWhitespace(c)) {
                        continue;
                    } else if (c == ')') {
                        state = .;
                        continue;
                    } else {
                        throw newDatatypeException(offset + i,
                                "Expected whitespace or \u201C)\u201D but saw \u201C"
                                        + c + "\u201D instead.");
                    }
            }
        }
        switch (state) {
            case :
            case :
                return warnings;
            case :
                String kw = sb.toString();
                sb.setLength(0);
                if (isMediaCondition()) {
                    errNotMediaCondition(kw);
                }
                if (isMediaType(kw)) {
                    return warnings;
                } else {
                    throw newDatatypeException("Expected a CSS media type but the query ended.");
                }
            default:
                throw newDatatypeException("Media query ended prematurely.");
        }
    }
    private boolean isMediaFeature(String feature) {
        return .containsKey(feature);
    }
    private ValueType valueExpectationFor(String feature) {
        return .get(feature);
    }
    private ValueType nonstandardValueExpectationFor(String feature) {
        return .get(feature);
    }
    private boolean isMediaType(String type) {
        return .contains(type);
    }
    private boolean isLengthUnit(String unit) {
        return .contains(unit);
    }
    private List<StringcheckApplicability(int indexString feature,
            String typeList<Stringwarningsthrows DatatypeException {
        if (!isMediaType(type)) {
            return warnings;
        }
        if (!isMediaFeature(feature)) {
            throw newDatatypeException(index,
                    "Expected a CSS media feature but saw \u201C" + feature
                            + "\u201D instead.");
        }
        switch (MediaType.toCaps(type)) {
            case :
                warnings.add("The media feature \u201c"
                        + feature
                        + "\u201d is not applicable to the media type \u201cspeech\u201d. ");
                return warnings;
            default:
                return warnings;
        }
    }
    private void errNotMediaCondition(String typethrows DatatypeException {
        if (isMediaType(type)) {
            throw newDatatypeException("Expected a CSS media condition but saw"
                    + " CSS media type "type" instead.");
        } else {
            throw newDatatypeException("Expected a CSS media condition but saw"
                    + " "type" instead.");
        }
    }
    private void checkIfValueRequired(int indexString feature)
            throws DatatypeException {
        if (feature.startsWith("min-") || feature.startsWith("max-")) {
            throw newDatatypeException(index,
                    "Expected a value for the media feature \u201C" + feature
                            + "\u201D.");
        }
    }
    protected boolean isMediaCondition() {
        return false;
    }
    @Override public String getName() {
        return "media query";
    }