com.google.caja.lang.css
Class CssSchema

java.lang.Object
  extended by com.google.caja.lang.css.CssSchema

public final class CssSchema
extends java.lang.Object

Definitions of CSS properties and symbols.

Author:
mikesamuel@gmail.com

Nested Class Summary
static class CssSchema.CssPropertyInfo
          Encapsulates a css property and its signatures.
private static class CssSchema.RegexpCriterion
           
static class CssSchema.SymbolInfo
          Encapsulates a css symbol.
 
Field Summary
private static Criterion<java.lang.String> ALL_ELEMENTS
           
private static Criterion<java.lang.String> ALL_MEDIA
           
private static java.util.regex.Pattern CSS_IDENTIFIER
           
private static Pair<CssSchema,java.util.List<Message>> defaultSchema
           
private  java.util.Set<Name> functionsAllowed
           
private static java.util.regex.Pattern HTML_IDENTIFIER
           
private static java.util.regex.Pattern JS_IDENTIFIER
           
private  java.util.Set<Name> keywords
           
private  java.util.Map<Name,CssSchema.CssPropertyInfo> properties
           
private  java.util.Set<Name> propertiesAllowed
           
private  java.util.Map<Name,CssSchema.SymbolInfo> symbols
           
 
Constructor Summary
CssSchema(WhiteList symbolsAndProperties, WhiteList functions)
           
 
Method Summary
private static Criterion<java.lang.String> criterionFromConfig(java.lang.Object type, Criterion<java.lang.String> permissiveCriterion)
           
private  void defineProperty(Name name, java.lang.String sig, java.lang.String defaultValue, Criterion<java.lang.String> appliesTo, boolean inherited, Criterion<java.lang.String> mediaGroups, java.util.List<java.lang.String> dom2properties)
           
private  void defineSymbol(Name name, java.lang.String sig)
           
 java.util.Collection<CssSchema.CssPropertyInfo> getCssProperties()
          All defined properties including disallowed ones.
 CssSchema.CssPropertyInfo getCssProperty(Name propertyName)
          Returns the signature and other information for a css property.
static CssSchema getDefaultCss21Schema(MessageQueue mq)
           
 CssSchema.SymbolInfo getSymbol(Name symbolName)
          Returns the signature for a css symbol.
private static Criterion<java.lang.String> in(java.lang.String... elementGroups)
           
 boolean isFunctionAllowed(Name name)
          Is the given word the name of a CSS function?
 boolean isKeyword(Name name)
          Is the given word a css keyword?
static boolean isMediaType(java.lang.String mediaType)
           
 boolean isPropertyAllowed(Name name)
          Is the given word the name of an allowed CSS property?
private static WhiteList.TypeDefinition merge(WhiteList.TypeDefinition wl1, WhiteList.TypeDefinition wl2)
           
private static CssPropertySignature parseSignature(Name name, java.lang.String sig)
          Parses a CssSignature according to the grammar described in http://www.w3.org/TR/CSS21/about.html#property-defs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

private final java.util.Map<Name,CssSchema.CssPropertyInfo> properties

symbols

private final java.util.Map<Name,CssSchema.SymbolInfo> symbols

keywords

private final java.util.Set<Name> keywords

functionsAllowed

private final java.util.Set<Name> functionsAllowed

propertiesAllowed

private final java.util.Set<Name> propertiesAllowed

defaultSchema

private static Pair<CssSchema,java.util.List<Message>> defaultSchema

HTML_IDENTIFIER

private static final java.util.regex.Pattern HTML_IDENTIFIER

CSS_IDENTIFIER

private static final java.util.regex.Pattern CSS_IDENTIFIER

JS_IDENTIFIER

private static final java.util.regex.Pattern JS_IDENTIFIER

ALL_ELEMENTS

private static final Criterion<java.lang.String> ALL_ELEMENTS

ALL_MEDIA

private static final Criterion<java.lang.String> ALL_MEDIA
Constructor Detail

CssSchema

public CssSchema(WhiteList symbolsAndProperties,
                 WhiteList functions)
Method Detail

getDefaultCss21Schema

public static CssSchema getDefaultCss21Schema(MessageQueue mq)

getCssProperty

public CssSchema.CssPropertyInfo getCssProperty(Name propertyName)
Returns the signature and other information for a css property.

Parameters:
propertyName - non null.
Returns:
null if no such property.

getCssProperties

public java.util.Collection<CssSchema.CssPropertyInfo> getCssProperties()
All defined properties including disallowed ones.


getSymbol

public CssSchema.SymbolInfo getSymbol(Name symbolName)
Returns the signature for a css symbol. Not all symbols can be defined in terms of a signature.

Parameters:
symbolName - non null.
Returns:
null if no such symbol or the symbol is not defined in terms of a signature.

isKeyword

public boolean isKeyword(Name name)
Is the given word a css keyword?


isFunctionAllowed

public boolean isFunctionAllowed(Name name)
Is the given word the name of a CSS function?


isPropertyAllowed

public boolean isPropertyAllowed(Name name)
Is the given word the name of an allowed CSS property?


isMediaType

public static boolean isMediaType(java.lang.String mediaType)

in

private static Criterion<java.lang.String> in(java.lang.String... elementGroups)

criterionFromConfig

private static Criterion<java.lang.String> criterionFromConfig(java.lang.Object type,
                                                               Criterion<java.lang.String> permissiveCriterion)

defineProperty

private void defineProperty(Name name,
                            java.lang.String sig,
                            java.lang.String defaultValue,
                            Criterion<java.lang.String> appliesTo,
                            boolean inherited,
                            Criterion<java.lang.String> mediaGroups,
                            java.util.List<java.lang.String> dom2properties)

defineSymbol

private void defineSymbol(Name name,
                          java.lang.String sig)

parseSignature

private static CssPropertySignature parseSignature(Name name,
                                                   java.lang.String sig)
Parses a CssSignature according to the grammar described in http://www.w3.org/TR/CSS21/about.html#property-defs


merge

private static WhiteList.TypeDefinition merge(WhiteList.TypeDefinition wl1,
                                              WhiteList.TypeDefinition wl2)


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0