com.openexchange.mail.text
Class CSSMatcher

java.lang.Object
  extended by com.openexchange.mail.text.CSSMatcher

public final class CSSMatcher
extends java.lang.Object

CSSMatcher - Provides several utility methods to check CSS content.

Author:
Thorben Betten

Method Summary
static boolean checkCSS(java.lang.StringBuilder cssBuilder, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> styleMap, boolean findBlocks, boolean removeIfAbsent)
          Iterates over CSS blocks contained in specified string argument and checks each block against given style map
static boolean checkCSSElements(java.lang.StringBuilder cssBuilder, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> styleMap, boolean removeIfAbsent)
          Iterates over CSS elements contained in specified string argument and checks each element and its value against given style map
static boolean containsCSSElement(java.lang.String css)
          Checks if specified string argument contains at least one CSS element
static boolean matches(java.lang.String value, java.util.Set<java.lang.String> allowedValuesSet)
          Checks if specified CSS value is matched by given allowed values The allowed values may contain following patterns to cover certain CSS types: u: url(<URL>) n: number string without % N: number string c: color d: delete *: any value t: time
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matches

public static boolean matches(java.lang.String value,
                              java.util.Set<java.lang.String> allowedValuesSet)
Checks if specified CSS value is matched by given allowed values

The allowed values may contain following patterns to cover certain CSS types:

Parameters:
value - The value
allowedValuesSet - The allowed values
Returns:
true if value is matched by given allowed values; otherwise false

checkCSS

public static boolean checkCSS(java.lang.StringBuilder cssBuilder,
                               java.util.Map<java.lang.String,java.util.Set<java.lang.String>> styleMap,
                               boolean findBlocks,
                               boolean removeIfAbsent)
Iterates over CSS blocks contained in specified string argument and checks each block against given style map

Parameters:
cssBuilder - A StringBuilder containing CSS content
styleMap - The style map
findBlocks - true to iterate over CSS blocks; otherwise false to iterate over CSS elements
removeIfAbsent - true to completely remove CSS element if not contained in specified style map; otherwise false
Returns:
true if modified; otherwise false

checkCSSElements

public static boolean checkCSSElements(java.lang.StringBuilder cssBuilder,
                                       java.util.Map<java.lang.String,java.util.Set<java.lang.String>> styleMap,
                                       boolean removeIfAbsent)
Iterates over CSS elements contained in specified string argument and checks each element and its value against given style map

Parameters:
cssBuilder - A StringBuilder containing the CSS content
styleMap - The style map
removeIfAbsent - true to completely remove CSS element if not contained in specified style map; otherwise false
Returns:
true if modified; otherwise false

containsCSSElement

public static boolean containsCSSElement(java.lang.String css)
Checks if specified string argument contains at least one CSS element

Parameters:
css - The CSS string
Returns:
true if specified string argument contains at least one CSS element; otherwise false