com.google.caja.config
Class JSONWhiteListLoader

java.lang.Object
  extended by com.google.caja.config.JSONWhiteListLoader

 class JSONWhiteListLoader
extends java.lang.Object


Field Summary
private static java.util.Map<java.net.URI,Pair<WhiteListSkeleton,java.util.List<Message>>> cache
           
(package private)  MessageQueue mq
           
(package private)  ImportResolver resolver
           
(package private)  FilePosition src
           
 
Constructor Summary
JSONWhiteListLoader(FilePosition src, ImportResolver resolver, MessageQueue mq)
           
 
Method Summary
(package private)  void checkValidity(WhiteListSkeleton s)
          Appends one or more MessageLevel.FATAL_ERROR to the given message queue if the skeleton is invalid.
(package private)
<T> T
expect(java.lang.Object obj, java.lang.Class<T> clazz, java.lang.String part)
          Abort with a ParseException if obj is not of type clazz, returning obj otherwise.
(package private)  org.json.simple.JSONObject expectJSONObject(java.lang.Object obj, java.lang.String part)
           
(package private)  java.lang.String expectString(java.lang.Object obj, java.lang.String part)
           
(package private)  WhiteList fromSkeleton(WhiteListSkeleton s)
           
(package private) static java.util.List<java.lang.Object> immutable(org.json.simple.JSONArray json)
          Converts a JSONArray to a List<Object> where values are JSONObjects, JSONArrays, or JSON primitives.
(package private) static java.util.Map<java.lang.String,java.lang.Object> immutable(org.json.simple.JSONObject json)
          Converts a JSONObject to a Map<String, Object> where values are JSONObjects, JSONArrays, or JSON primitives.
(package private) static java.lang.Object immutable(java.lang.Object obj)
          Converts a JSON value to an equivalent immutable java representation.
(package private)  WhiteList loadFrom(org.json.simple.JSONObject value)
           
(package private)  WhiteList loadFrom(java.io.Reader in)
           
private  WhiteListSkeleton loadSkeleton(org.json.simple.JSONObject whitelistJson)
          Split a JSON object into bits that can be turned into a skeleton, and issue warnings for bits we don't understand.
private  WhiteListSkeleton loadSkeleton(java.io.Reader in)
           
(package private)  WhiteListSkeleton makeSkeleton(java.util.List<WhiteListSkeleton> loaded, java.util.Set<java.lang.String> allowed, java.util.Set<java.lang.String> denied, java.util.List<org.json.simple.JSONObject> definitions)
          Gather information into a skeleton, so we can deal recursively with inherited whitelists.
(package private)  WhiteList.TypeDefinition makeTypeDefinition(org.json.simple.JSONObject def)
           
(package private) static
<K,V> void
multimapAdd(java.util.Map<K,java.util.List<V>> m, K key, java.util.List<V> newValues)
          Adds values for key to the multimap m maintaining the invariant: m.containsKey(key) is true iff at least one value has been added for the key key.
(package private)
<T> T
optional(java.lang.Object obj, java.lang.Class<T> clazz, java.lang.String part)
          Abort with a ParseException if obj is not either null or of type clazz, returning obj otherwise.
(package private)  org.json.simple.JSONArray optionalJSONArray(java.lang.Object obj, java.lang.String part)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

src

final FilePosition src

resolver

final ImportResolver resolver

mq

MessageQueue mq

cache

private static final java.util.Map<java.net.URI,Pair<WhiteListSkeleton,java.util.List<Message>>> cache
Constructor Detail

JSONWhiteListLoader

JSONWhiteListLoader(FilePosition src,
                    ImportResolver resolver,
                    MessageQueue mq)
Method Detail

loadFrom

WhiteList loadFrom(java.io.Reader in)
             throws java.io.IOException,
                    ParseException
Throws:
java.io.IOException
ParseException

loadFrom

WhiteList loadFrom(org.json.simple.JSONObject value)
             throws java.io.IOException,
                    ParseException
Throws:
java.io.IOException
ParseException

loadSkeleton

private WhiteListSkeleton loadSkeleton(java.io.Reader in)
                                throws java.io.IOException,
                                       ParseException
Throws:
java.io.IOException
ParseException

loadSkeleton

private WhiteListSkeleton loadSkeleton(org.json.simple.JSONObject whitelistJson)
                                throws java.io.IOException,
                                       ParseException
Split a JSON object into bits that can be turned into a skeleton, and issue warnings for bits we don't understand. We produce a skeleton before building a full whitelist since the skeleton makes it easier to deal recursively with inherited whitelists.

Throws:
java.io.IOException - if we can't load an inherited whitelist.
ParseException - if we can't produce a whitelist.

makeSkeleton

WhiteListSkeleton makeSkeleton(java.util.List<WhiteListSkeleton> loaded,
                               java.util.Set<java.lang.String> allowed,
                               java.util.Set<java.lang.String> denied,
                               java.util.List<org.json.simple.JSONObject> definitions)
Gather information into a skeleton, so we can deal recursively with inherited whitelists.


checkValidity

void checkValidity(WhiteListSkeleton s)
Appends one or more MessageLevel.FATAL_ERROR to the given message queue if the skeleton is invalid.


fromSkeleton

WhiteList fromSkeleton(WhiteListSkeleton s)

makeTypeDefinition

WhiteList.TypeDefinition makeTypeDefinition(org.json.simple.JSONObject def)

expectJSONObject

org.json.simple.JSONObject expectJSONObject(java.lang.Object obj,
                                            java.lang.String part)
                                      throws ParseException
Throws:
ParseException

expectString

java.lang.String expectString(java.lang.Object obj,
                              java.lang.String part)
                        throws ParseException
Throws:
ParseException

optionalJSONArray

org.json.simple.JSONArray optionalJSONArray(java.lang.Object obj,
                                            java.lang.String part)
                                      throws ParseException
Throws:
ParseException

immutable

static java.util.Map<java.lang.String,java.lang.Object> immutable(org.json.simple.JSONObject json)
Converts a JSONObject to a Map<String, Object> where values are JSONObjects, JSONArrays, or JSON primitives.


immutable

static java.util.List<java.lang.Object> immutable(org.json.simple.JSONArray json)
Converts a JSONArray to a List<Object> where values are JSONObjects, JSONArrays, or JSON primitives.


immutable

static java.lang.Object immutable(java.lang.Object obj)
Converts a JSON value to an equivalent immutable java representation.


expect

<T> T expect(java.lang.Object obj,
             java.lang.Class<T> clazz,
             java.lang.String part)
   throws ParseException
Abort with a ParseException if obj is not of type clazz, returning obj otherwise.

Throws:
ParseException

optional

<T> T optional(java.lang.Object obj,
               java.lang.Class<T> clazz,
               java.lang.String part)
     throws ParseException
Abort with a ParseException if obj is not either null or of type clazz, returning obj otherwise.

Throws:
ParseException

multimapAdd

static <K,V> void multimapAdd(java.util.Map<K,java.util.List<V>> m,
                              K key,
                              java.util.List<V> newValues)
Adds values for key to the multimap m maintaining the invariant:



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