/** * Checks if this media specification matches a given media query. * @param q The media query * @return {@code true} when this media specification matches the given media query. */ public boolean matches(MediaQuery q) { //match the media type if (q.getType() != null) { if (q.getType().equals("all")) { if (q.isNegative()) return false; //"NOT all" doesn't match to anything } else if (q.getType().equals(this.getType()) == q.isNegative()) //other than all return false; } //match the eventual expressions for (MediaExpression e : q) { if (!this.matches(e)) return false; } //everything matched return true; }
/** * Checks if this media specification matches a given media query. * @param q The media query * @return {@code true} when this media specification matches the given media query. */ public boolean matches(MediaQuery q) { //match the media type if (q.getType() != null) { if (q.getType().equals("all")) { if (q.isNegative()) return false; //"NOT all" doesn't match to anything } else if (q.getType().equals(this.getType()) == q.isNegative()) //other than all return false; } //match the eventual expressions for (MediaExpression e : q) { if (!this.matches(e)) return false; } //everything matched return true; }
/** * Checks if this media specification matches a given media query. * @param q The media query * @return {@code true} when this media specification matches the given media query. */ public boolean matches(MediaQuery q) { //match the media type if (q.getType() != null) { if (q.getType().equals("all")) { if (q.isNegative()) return false; //"NOT all" doesn't match to anything } else if (q.getType().equals(this.getType()) == q.isNegative()) //other than all return false; } //match the eventual expressions for (MediaExpression e : q) { if (!this.matches(e)) return false; } //everything matched return true; }