text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>
CollectionUtils (Commons Collections 3.2.1 API)
</TITLE>

<META NAME="keywords" CONTENT="org.apache.commons.collections.CollectionUtils class">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

org.apache.commons.collections

Class CollectionUtils

java.lang.Object
  org.apache.commons.collections.CollectionUtils

public class CollectionUtils
extends java.lang.Object

Provides utility methods and decorators for Collection instances.

Since:

Commons Collections 1.0

Version:

$Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $

Author:

Rodney Waldhoff, Paul Jack, Stephen Colebourne, Steve Downey, Herve Quiroz, Peter KoBek, Matthew Hawthorne, Janek Bogucki, Phil Steitz, Steven Melzer, Jon Schewe, Neil O'Toole, Stephen Smith

Field Summary

static java.util.Collection
EMPTY_COLLECTION

          An empty unmodifiable collection.

Constructor Summary

CollectionUtils()

          CollectionUtils should not normally be instantiated.

Method Summary

static void
addAll(java.util.Collection collection,
       java.util.Enumeration enumeration)

          Adds all elements in the enumeration to the given collection.

static void
addAll(java.util.Collection collection,
       java.util.Iterator iterator)

          Adds all elements in the iteration to the given collection.

static void
addAll(java.util.Collection collection,
       java.lang.Object[] elements)

          Adds all elements in the array to the given collection.

static boolean
addIgnoreNull(java.util.Collection collection,
              java.lang.Object object)

          Adds an element to the collection unless the element is null.

static int
cardinality(java.lang.Object obj,
            java.util.Collection coll)

          Returns the number of occurrences of obj in coll.

static java.util.Collection
collect(java.util.Collection inputCollection,
        Transformer transformer)

          Returns a new Collection consisting of the elements of inputCollection transformed
 by the given transformer.

static java.util.Collection
collect(java.util.Collection inputCollection,
        Transformer transformer,
        java.util.Collection outputCollection)

          Transforms all elements from inputCollection with the given transformer
 and adds them to the outputCollection.

static java.util.Collection
collect(java.util.Iterator inputIterator,
        Transformer transformer)

          Transforms all elements from the inputIterator with the given transformer
 and adds them to the outputCollection.

static java.util.Collection
collect(java.util.Iterator inputIterator,
        Transformer transformer,
        java.util.Collection outputCollection)

          Transforms all elements from the inputIterator with the given transformer
 and adds them to the outputCollection.

static boolean
containsAny(java.util.Collection coll1,
            java.util.Collection coll2)

          Returns true iff at least one element is in both collections.

static int
countMatches(java.util.Collection inputCollection,
             Predicate predicate)

          Counts the number of elements in the input collection that match the predicate.

static java.util.Collection
disjunction(java.util.Collection a,
            java.util.Collection b)

          Returns a Collection containing the exclusive disjunction
 (symmetric difference) of the given Collections.

static boolean
exists(java.util.Collection collection,
       Predicate predicate)

          Answers true if a predicate is true for at least one element of a collection.

static void
filter(java.util.Collection collection,
       Predicate predicate)

          Filter the collection by applying a Predicate to each element.

static java.lang.Object
find(java.util.Collection collection,
     Predicate predicate)

          Finds the first element in the given collection which matches the given predicate.

static void
forAllDo(java.util.Collection collection,
         Closure closure)

          Executes the given closure on each element in the collection.

static java.lang.Object
get(java.lang.Object object,
    int index)

          Returns the index-th value in object, throwing
 IndexOutOfBoundsException if there is no such element or
 IllegalArgumentException if object is not an
 instance of one of the supported types.

static java.util.Map
getCardinalityMap(java.util.Collection coll)

          Returns a Map mapping each unique element in the given
 Collection to an Integer representing the number
 of occurrences of that element in the Collection.

static java.lang.Object
index(java.lang.Object obj,
      int idx)

          Deprecated. use get(Object, int) instead. Will be removed in v4.0

static java.lang.Object
index(java.lang.Object obj,
      java.lang.Object index)

          Deprecated. use get(Object, int) instead. Will be removed in v4.0

static java.util.Collection
intersection(java.util.Collection a,
             java.util.Collection b)

          Returns a Collection containing the intersection
 of the given Collections.

static boolean
isEmpty(java.util.Collection coll)

          Null-safe check if the specified collection is empty.

static boolean
isEqualCollection(java.util.Collection a,
                  java.util.Collection b)

          Returns <tt>true</tt> iff the given Collections contain
 exactly the same elements with exactly the same cardinalities.

static boolean
isFull(java.util.Collection coll)

          Returns true if no more elements can be added to the Collection.

static boolean
isNotEmpty(java.util.Collection coll)

          Null-safe check if the specified collection is not empty.

static boolean
isProperSubCollection(java.util.Collection a,
                      java.util.Collection b)

          Returns <tt>true</tt> iff a is a proper sub-collection of b,
 that is, iff the cardinality of e in a is less
 than or equal to the cardinality of e in b,
 for each element e in a, and there is at least one
 element f such that the cardinality of f in b
 is strictly greater than the cardinality of f in a.

static boolean
isSubCollection(java.util.Collection a,
                java.util.Collection b)

          Returns <tt>true</tt> iff a is a sub-collection of b,
 that is, iff the cardinality of e in a is less
 than or equal to the cardinality of e in b,
 for each element e in a.

static int
maxSize(java.util.Collection coll)

          Get the maximum number of elements that the Collection can contain.

static java.util.Collection
predicatedCollection(java.util.Collection collection,
                     Predicate predicate)

          Returns a predicated (validating) collection backed by the given collection.

static java.util.Collection
removeAll(java.util.Collection collection,
          java.util.Collection remove)

          Removes the elements in remove from collection.

static java.util.Collection
retainAll(java.util.Collection collection,
          java.util.Collection retain)

          Returns a collection containing all the elements in collection
 that are also in retain.

static void
reverseArray(java.lang.Object[] array)

          Reverses the order of the given array.

static java.util.Collection
select(java.util.Collection inputCollection,
       Predicate predicate)

          Selects all elements from input collection which match the given predicate
 into an output collection.

static void
select(java.util.Collection inputCollection,
       Predicate predicate,
       java.util.Collection outputCollection)

          Selects all elements from input collection which match the given predicate
 and adds them to outputCollection.

static java.util.Collection
selectRejected(java.util.Collection inputCollection,
               Predicate predicate)

          Selects all elements from inputCollection which don't match the given predicate
 into an output collection.

static void
selectRejected(java.util.Collection inputCollection,
               Predicate predicate,
               java.util.Collection outputCollection)

          Selects all elements from inputCollection which don't match the given predicate
 and adds them to outputCollection.

static int
size(java.lang.Object object)

          Gets the size of the collection/iterator specified.

static boolean
sizeIsEmpty(java.lang.Object object)

          Checks if the specified collection/array/iterator is empty.

static java.util.Collection
subtract(java.util.Collection a,
         java.util.Collection b)

          Returns a new Collection containing <tt>a - b</tt>.

static java.util.Collection
synchronizedCollection(java.util.Collection collection)

          Returns a synchronized collection backed by the given collection.

static void
transform(java.util.Collection collection,
          Transformer transformer)

          Transform the collection by applying a Transformer to each element.

static java.util.Collection
transformedCollection(java.util.Collection collection,
                      Transformer transformer)

          Returns a transformed bag backed by the given collection.

static java.util.Collection
typedCollection(java.util.Collection collection,
                java.lang.Class type)

          Returns a typed collection backed by the given collection.

static java.util.Collection
union(java.util.Collection a,
      java.util.Collection b)

          Returns a Collection containing the union
 of the given Collections.

static java.util.Collection
unmodifiableCollection(java.util.Collection collection)

          Returns an unmodifiable collection backed by the given collection.

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

EMPTY_COLLECTION

public static final java.util.Collection EMPTY_COLLECTION

An empty unmodifiable collection.
 The JDK provides empty Set and List implementations which could be used for
 this purpose. However they could be cast to Set or List which might be
 undesirable. This implementation only implements Collection.

Constructor Detail

CollectionUtils

public CollectionUtils()

CollectionUtils should not normally be instantiated.

Method Detail

union

public static java.util.Collection union(java.util.Collection a,
                                         java.util.Collection b)

Returns a Collection containing the union
 of the given Collections.

 The cardinality of each element in the returned Collection
 will be equal to the maximum of the cardinality of that element
 in the two given Collections.

Parameters:
a - the first collection, must not be null
b - the second collection, must not be null

Returns:
the union of the two collections
See Also:
Collection.addAll(java.util.Collection)

intersection

public static java.util.Collection intersection(java.util.Collection a,
                                                java.util.Collection b)

Returns a Collection containing the intersection
 of the given Collections.

 The cardinality of each element in the returned Collection
 will be equal to the minimum of the cardinality of that element
 in the two given Collections.

Parameters:
a - the first collection, must not be null
b - the second collection, must not be null

Returns:
the intersection of the two collections
See Also:
Collection.retainAll(java.util.Collection),
containsAny(java.util.Collection, java.util.Collection)

disjunction

public static java.util.Collection disjunction(java.util.Collection a,
                                               java.util.Collection b)

Returns a Collection containing the exclusive disjunction
 (symmetric difference) of the given Collections.

 The cardinality of each element e in the returned Collection
 will be equal to
 <tt>max(cardinality(e,a),cardinality(e,b)) - min(cardinality(e,a),cardinality(e,b))</tt>.

 This is equivalent to
 <tt>subtract(union(a,b),intersection(a,b))</tt>
 or
 <tt>union(subtract(a,b),subtract(b,a))</tt>.

Parameters:
a - the first collection, must not be null
b - the second collection, must not be null

Returns:
the symmetric difference of the two collections

subtract

public static java.util.Collection subtract(java.util.Collection a,
                                            java.util.Collection b)

Returns a new Collection containing <tt>a - b</tt>.
 The cardinality of each element e in the returned Collection
 will be the cardinality of e in a minus the cardinality
 of e in b, or zero, whichever is greater.

Parameters:
a - the collection to subtract from, must not be null
b - the collection to subtract, must not be null

Returns:
a new collection with the results
See Also:
Collection.removeAll(java.util.Collection)

containsAny

public static boolean containsAny(java.util.Collection coll1,
                                  java.util.Collection coll2)

Returns true iff at least one element is in both collections.

 In other words, this method returns true iff the
 intersection(java.util.Collection, java.util.Collection) of coll1 and coll2 is not empty.

Parameters:
coll1 - the first collection, must not be null
coll2 - the first collection, must not be null

Returns:
true iff the intersection of the collections is non-empty
Since:

2.1

See Also:
intersection(java.util.Collection, java.util.Collection)

getCardinalityMap

public static java.util.Map getCardinalityMap(java.util.Collection coll)

Returns a Map mapping each unique element in the given
 Collection to an Integer representing the number
 of occurrences of that element in the Collection.

 Only those elements present in the collection will appear as
 keys in the map.

Parameters:
coll - the collection to get the cardinality map for, must not be null

Returns:
the populated cardinality map

isSubCollection

public static boolean isSubCollection(java.util.Collection a,
                                      java.util.Collection b)

Returns <tt>true</tt> iff a is a sub-collection of b,
 that is, iff the cardinality of e in a is less
 than or equal to the cardinality of e in b,
 for each element e in a.

Parameters:
a - the first (sub?) collection, must not be null
b - the second (super?) collection, must not be null

Returns:
true iff a is a sub-collection of b
See Also:
isProperSubCollection(java.util.Collection, java.util.Collection),
Collection.containsAll(java.util.Collection)

isProperSubCollection

public static boolean isProperSubCollection(java.util.Collection a,
                                            java.util.Collection b)

Returns <tt>true</tt> iff a is a proper sub-collection of b,
 that is, iff the cardinality of e in a is less
 than or equal to the cardinality of e in b,
 for each element e in a, and there is at least one
 element f such that the cardinality of f in b
 is strictly greater than the cardinality of f in a.

 The implementation assumes

a.size() and b.size() represent the
    total cardinality of a and b, resp.

a.size() < Integer.MAXVALUE

Parameters:
a - the first (sub?) collection, must not be null
b - the second (super?) collection, must not be null

Returns:
true iff a is a proper sub-collection of b
See Also:
isSubCollection(java.util.Collection, java.util.Collection),
Collection.containsAll(java.util.Collection)

isEqualCollection

public static boolean isEqualCollection(java.util.Collection a,
                                        java.util.Collection b)

Returns <tt>true</tt> iff the given Collections contain
 exactly the same elements with exactly the same cardinalities.

 That is, iff the cardinality of e in a is
 equal to the cardinality of e in b,
 for each element e in a or b.

Parameters:
a - the first collection, must not be null
b - the second collection, must not be null

Returns:
true iff the collections contain the same elements with the same cardinalities.

cardinality

public static int cardinality(java.lang.Object obj,
                              java.util.Collection coll)

Returns the number of occurrences of obj in coll.

Parameters:
obj - the object to find the cardinality of
coll - the collection to search

Returns:
the the number of occurrences of obj in coll

find

public static java.lang.Object find(java.util.Collection collection,
                                    Predicate predicate)

Finds the first element in the given collection which matches the given predicate.

 If the input collection or predicate is null, or no element of the collection
 matches the predicate, null is returned.

Parameters:
collection - the collection to search, may be null
predicate - the predicate to use, may be null

Returns:
the first element of the collection which matches the predicate or null if none could be found

forAllDo

public static void forAllDo(java.util.Collection collection,
                            Closure closure)

Executes the given closure on each element in the collection.

 If the input collection or closure is null, there is no change made.

Parameters:
collection - the collection to get the input from, may be null
closure - the closure to perform, may be null

filter

public static void filter(java.util.Collection collection,
                          Predicate predicate)

Filter the collection by applying a Predicate to each element. If the
 predicate returns false, remove the element.

 If the input collection or predicate is null, there is no change made.

Parameters:
collection - the collection to get the input from, may be null
predicate - the predicate to use as a filter, may be null

transform

public static void transform(java.util.Collection collection,
                             Transformer transformer)

Transform the collection by applying a Transformer to each element.

 If the input collection or transformer is null, there is no change made.

 This routine is best for Lists, for which set() is used to do the
 transformations "in place."  For other Collections, clear() and addAll()
 are used to replace elements.

 If the input collection controls its input, such as a Set, and the
 Transformer creates duplicates (or are otherwise invalid), the
 collection may reduce in size due to calling this method.

Parameters:
collection - the collection to get the input from, may be null
transformer - the transformer to perform, may be null

countMatches

public static int countMatches(java.util.Collection inputCollection,
                               Predicate predicate)

Counts the number of elements in the input collection that match the predicate.

 A null collection or predicate matches no elements.

Parameters:
inputCollection - the collection to get the input from, may be null
predicate - the predicate to use, may be null

Returns:
the number of matches for the predicate in the collection

exists

public static boolean exists(java.util.Collection collection,
                             Predicate predicate)

Answers true if a predicate is true for at least one element of a collection.

 A null collection or predicate returns false.

Parameters:
collection - the collection to get the input from, may be null
predicate - the predicate to use, may be null

Returns:
true if at least one element of the collection matches the predicate

select

public static java.util.Collection select(java.util.Collection inputCollection,
                                          Predicate predicate)

Selects all elements from input collection which match the given predicate
 into an output collection.

 A null predicate matches no elements.

Parameters:
inputCollection - the collection to get the input from, may not be null
predicate - the predicate to use, may be null

Returns:
the elements matching the predicate (new list)

Throws:

java.lang.NullPointerException - if the input collection is null

select

public static void select(java.util.Collection inputCollection,
                          Predicate predicate,
                          java.util.Collection outputCollection)

Selects all elements from input collection which match the given predicate
 and adds them to outputCollection.

 If the input collection or predicate is null, there is no change to the
 output collection.

Parameters:
inputCollection - the collection to get the input from, may be null
predicate - the predicate to use, may be null
outputCollection - the collection to output into, may not be null

selectRejected

public static java.util.Collection selectRejected(java.util.Collection inputCollection,
                                                  Predicate predicate)

Selects all elements from inputCollection which don't match the given predicate
 into an output collection.

 If the input predicate is null, the result is an empty list.

Parameters:
inputCollection - the collection to get the input from, may not be null
predicate - the predicate to use, may be null

Returns:
the elements not matching the predicate (new list)

Throws:

java.lang.NullPointerException - if the input collection is null

selectRejected

public static void selectRejected(java.util.Collection inputCollection,
                                  Predicate predicate,
                                  java.util.Collection outputCollection)

Selects all elements from inputCollection which don't match the given predicate
 and adds them to outputCollection.

 If the input predicate is null, no elements are added to outputCollection.

Parameters:
inputCollection - the collection to get the input from, may be null
predicate - the predicate to use, may be null
outputCollection - the collection to output into, may not be null

collect

public static java.util.Collection collect(java.util.Collection inputCollection,
                                           Transformer transformer)

Returns a new Collection consisting of the elements of inputCollection transformed
 by the given transformer.

 If the input transformer is null, the result is an empty list.

Parameters:
inputCollection - the collection to get the input from, may not be null
transformer - the transformer to use, may be null

Returns:
the transformed result (new list)

Throws:

java.lang.NullPointerException - if the input collection is null

collect

public static java.util.Collection collect(java.util.Iterator inputIterator,
                                           Transformer transformer)

Transforms all elements from the inputIterator with the given transformer
 and adds them to the outputCollection.

 If the input iterator or transformer is null, the result is an empty list.

Parameters:
inputIterator - the iterator to get the input from, may be null
transformer - the transformer to use, may be null

Returns:
the transformed result (new list)

collect

public static java.util.Collection collect(java.util.Collection inputCollection,
                                           Transformer transformer,
                                           java.util.Collection outputCollection)

Transforms all elements from inputCollection with the given transformer
 and adds them to the outputCollection.

 If the input collection or transformer is null, there is no change to the
 output collection.

Parameters:
inputCollection - the collection to get the input from, may be null
transformer - the transformer to use, may be null
outputCollection - the collection to output into, may not be null

Returns:
the outputCollection with the transformed input added

Throws:

java.lang.NullPointerException - if the output collection is null

collect

public static java.util.Collection collect(java.util.Iterator inputIterator,
                                           Transformer transformer,
                                           java.util.Collection outputCollection)

Transforms all elements from the inputIterator with the given transformer
 and adds them to the outputCollection.

 If the input iterator or transformer is null, there is no change to the
 output collection.

Parameters:
inputIterator - the iterator to get the input from, may be null
transformer - the transformer to use, may be null
outputCollection - the collection to output into, may not be null

Returns:
the outputCollection with the transformed input added

Throws:

java.lang.NullPointerException - if the output collection is null

addIgnoreNull

public static boolean addIgnoreNull(java.util.Collection collection,
                                    java.lang.Object object)

Adds an element to the collection unless the element is null.

Parameters:
collection - the collection to add to, must not be null
object - the object to add, if null it will not be added

Returns:
true if the collection changed

Throws:

java.lang.NullPointerException - if the collection is null
Since:

Commons Collections 3.2

addAll

public static void addAll(java.util.Collection collection,
                          java.util.Iterator iterator)

Adds all elements in the iteration to the given collection.

Parameters:
collection - the collection to add to, must not be null
iterator - the iterator of elements to add, must not be null

Throws:

java.lang.NullPointerException - if the collection or iterator is null

addAll

public static void addAll(java.util.Collection collection,
                          java.util.Enumeration enumeration)

Adds all elements in the enumeration to the given collection.

Parameters:
collection - the collection to add to, must not be null
enumeration - the enumeration of elements to add, must not be null

Throws:

java.lang.NullPointerException - if the collection or enumeration is null

addAll

public static void addAll(java.util.Collection collection,
                          java.lang.Object[] elements)

Adds all elements in the array to the given collection.

Parameters:
collection - the collection to add to, must not be null
elements - the array of elements to add, must not be null

Throws:

java.lang.NullPointerException - if the collection or array is null

index

public static java.lang.Object index(java.lang.Object obj,
                                     int idx)

Deprecated. use get(Object, int) instead. Will be removed in v4.0

Given an Object, and an index, returns the nth value in the
 object.

If obj is a Map, returns the nth value from the keySet iterator, unless
     the Map contains an Integer key with integer value = idx, in which case the
     corresponding map entry value is returned.  If idx exceeds the number of entries in
     the map, an empty Iterator is returned.

If obj is a List or an array, returns the nth value, throwing IndexOutOfBoundsException,
     ArrayIndexOutOfBoundsException, resp. if the nth value does not exist.

If obj is an iterator, enumeration or Collection, returns the nth value from the iterator,
     returning an empty Iterator (resp. Enumeration) if the nth value does not exist.

Returns the original obj if it is null or not a Collection or Iterator.

Parameters:
obj - the object to get an index of, may be null
idx - the index to get

Throws:

java.lang.IndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException

index

public static java.lang.Object index(java.lang.Object obj,
                                     java.lang.Object index)

Deprecated. use get(Object, int) instead. Will be removed in v4.0

Given an Object, and a key (index), returns the value associated with
 that key in the Object. The following checks are made:

If obj is a Map, use the index as a key to get a value. If no match continue.

Check key is an Integer. If not, return the object passed in.

If obj is a Map, get the nth value from the keySet iterator.
     If the Map has fewer than n entries, return an empty Iterator.

If obj is a List or an array, get the nth value, throwing IndexOutOfBoundsException,
     ArrayIndexOutOfBoundsException, resp. if the nth value does not exist.

If obj is an iterator, enumeration or Collection, get the nth value from the iterator,
     returning an empty Iterator (resp. Enumeration) if the nth value does not exist.

Return the original obj.

Parameters:
obj - the object to get an index of
index - the index to get

Returns:
the object at the specified index

Throws:

java.lang.IndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException

get

public static java.lang.Object get(java.lang.Object object,
                                   int index)

Returns the index-th value in object, throwing
 IndexOutOfBoundsException if there is no such element or
 IllegalArgumentException if object is not an
 instance of one of the supported types.

 The supported types, and associated semantics are:

 Map -- the value returned is the Map.Entry in position
      index in the map's entrySet iterator,
      if there is such an entry.

 List -- this method is equivalent to the list's get method.

 Array -- the index-th array entry is returned,
      if there is such an entry; otherwise an IndexOutOfBoundsException
      is thrown.

 Collection -- the value returned is the index-th object
      returned by the collection's default iterator, if there is such an element.

 Iterator or Enumeration -- the value returned is the
      index-th object in the Iterator/Enumeration, if there
      is such an element.  The Iterator/Enumeration is advanced to
      index (or to the end, if index exceeds the
      number of entries) as a side effect of this method.

Parameters:
object - the object to get a value from
index - the index to get

Returns:
the object at the specified index

Throws:

java.lang.IndexOutOfBoundsException - if the index is invalid

java.lang.IllegalArgumentException - if the object type is invalid

size

public static int size(java.lang.Object object)

Gets the size of the collection/iterator specified.

 This method can handles objects as follows

Collection - the collection size

Map - the map size

Array - the array size

Iterator - the number of elements remaining in the iterator

Enumeration - the number of elements remaining in the enumeration

Parameters:
object - the object to get the size of

Returns:
the size of the specified collection

Throws:

java.lang.IllegalArgumentException - thrown if object is not recognised or null
Since:

Commons Collections 3.1

sizeIsEmpty

public static boolean sizeIsEmpty(java.lang.Object object)

Checks if the specified collection/array/iterator is empty.

 This method can handles objects as follows

Collection - via collection isEmpty

Map - via map isEmpty

Array - using array size

Iterator - via hasNext

Enumeration - via hasMoreElements

 Note: This method is named to avoid clashing with
 isEmpty(Collection).

Parameters:
object - the object to get the size of, not null

Returns:
true if empty

Throws:

java.lang.IllegalArgumentException - thrown if object is not recognised or null
Since:

Commons Collections 3.2

isEmpty

public static boolean isEmpty(java.util.Collection coll)

Null-safe check if the specified collection is empty.

 Null returns true.

Parameters:
coll - the collection to check, may be null

Returns:
true if empty or null
Since:

Commons Collections 3.2

isNotEmpty

public static boolean isNotEmpty(java.util.Collection coll)

Null-safe check if the specified collection is not empty.

 Null returns false.

Parameters:
coll - the collection to check, may be null

Returns:
true if non-null and non-empty
Since:

Commons Collections 3.2

reverseArray

public static void reverseArray(java.lang.Object[] array)

Reverses the order of the given array.

Parameters:
array - the array to reverse

isFull

public static boolean isFull(java.util.Collection coll)

Returns true if no more elements can be added to the Collection.

 This method uses the BoundedCollection interface to determine the
 full status. If the collection does not implement this interface then
 false is returned.

 The collection does not have to implement this interface directly.
 If the collection has been decorated using the decorators subpackage
 then these will be removed to access the BoundedCollection.

Parameters:
coll - the collection to check

Returns:
true if the BoundedCollection is full

Throws:

java.lang.NullPointerException - if the collection is null

maxSize

public static int maxSize(java.util.Collection coll)

Get the maximum number of elements that the Collection can contain.

 This method uses the BoundedCollection interface to determine the
 maximum size. If the collection does not implement this interface then
 -1 is returned.

 The collection does not have to implement this interface directly.
 If the collection has been decorated using the decorators subpackage
 then these will be removed to access the BoundedCollection.

Parameters:
coll - the collection to check

Returns:
the maximum size of the BoundedCollection, -1 if no maximum size

Throws:

java.lang.NullPointerException - if the collection is null

retainAll

public static java.util.Collection retainAll(java.util.Collection collection,
                                             java.util.Collection retain)

Returns a collection containing all the elements in collection
 that are also in retain. The cardinality of an element e
 in the returned collection is the same as the cardinality of e
 in collection unless retain does not contain e, in which
 case the cardinality is zero. This method is useful if you do not wish to modify
 the collection c and thus cannot call c.retainAll(retain);.

Parameters:
collection - the collection whose contents are the target of the #retailAll operation
retain - the collection containing the elements to be retained in the returned collection

Returns:
a Collection containing all the elements of collection
 that occur at least once in retain.

Throws:

java.lang.NullPointerException - if either parameter is null
Since:

Commons Collections 3.2

removeAll

public static java.util.Collection removeAll(java.util.Collection collection,
                                             java.util.Collection remove)

Removes the elements in remove from collection. That is, this
 method returns a collection containing all the elements in c
 that are not in remove. The cardinality of an element e
 in the returned collection is the same as the cardinality of e
 in collection unless remove contains e, in which
 case the cardinality is zero. This method is useful if you do not wish to modify
 the collection c and thus cannot call collection.removeAll(remove);.

Parameters:
collection - the collection from which items are removed (in the returned collection)
remove - the items to be removed from the returned collection

Returns:
a Collection containing all the elements of collection except
 any elements that also occur in remove.

Throws:

java.lang.NullPointerException - if either parameter is null
Since:

Commons Collections 3.2

synchronizedCollection

public static java.util.Collection synchronizedCollection(java.util.Collection collection)

Returns a synchronized collection backed by the given collection.

 You must manually synchronize on the returned buffer's iterator to
 avoid non-deterministic behavior:

 Collection c = CollectionUtils.synchronizedCollection(myCollection);
 synchronized (c) {
     Iterator i = c.iterator();
     while (i.hasNext()) {
         process (i.next());
     }
 }

 This method uses the implementation in the decorators subpackage.

Parameters:
collection - the collection to synchronize, must not be null

Returns:
a synchronized collection backed by the given collection

Throws:

java.lang.IllegalArgumentException - if the collection is null

unmodifiableCollection

public static java.util.Collection unmodifiableCollection(java.util.Collection collection)

Returns an unmodifiable collection backed by the given collection.

 This method uses the implementation in the decorators subpackage.

Parameters:
collection - the collection to make unmodifiable, must not be null

Returns:
an unmodifiable collection backed by the given collection

Throws:

java.lang.IllegalArgumentException - if the collection is null

predicatedCollection

public static java.util.Collection predicatedCollection(java.util.Collection collection,
                                                        Predicate predicate)

Returns a predicated (validating) collection backed by the given collection.

 Only objects that pass the test in the given predicate can be added to the collection.
 Trying to add an invalid object results in an IllegalArgumentException.
 It is important not to use the original collection after invoking this method,
 as it is a backdoor for adding invalid objects.

Parameters:
collection - the collection to predicate, must not be null
predicate - the predicate for the collection, must not be null

Returns:
a predicated collection backed by the given collection

Throws:

java.lang.IllegalArgumentException - if the Collection is null

typedCollection

public static java.util.Collection typedCollection(java.util.Collection collection,
                                                   java.lang.Class type)

Returns a typed collection backed by the given collection.

 Only objects of the specified type can be added to the collection.

Parameters:
collection - the collection to limit to a specific type, must not be null
type - the type of objects which may be added to the collection

Returns:
a typed collection backed by the specified collection

transformedCollection

public static java.util.Collection transformedCollection(java.util.Collection collection,
                                                         Transformer transformer)

Returns a transformed bag backed by the given collection.

 Each object is passed through the transformer as it is added to the
 Collection. It is important not to use the original collection after invoking this
 method, as it is a backdoor for adding untransformed objects.

Parameters:
collection - the collection to predicate, must not be null
transformer - the transformer for the collection, must not be null

Returns:
a transformed collection backed by the given collection

Throws:

java.lang.IllegalArgumentException - if the Collection or Transformer is null

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.


text:
Audio output latency as measured by WALT is the time that passes from the moment an application
decides to output a tone until it can be detected via the headphone jack. Microphone latency is
defined similarly.

Low latency audio IO on Android can be achieved via JNI C/C++ code.
Documentation and sample code can be found on the
 [High Performance Audio website](http://googlesamples.github.io/android-audio-high-performance/).

### Reported values

We are trying to stick to the following (overlapping) principles
1. Timestamp events as close to hardware as possible. Most events up the stack can be easily timed with software alone.
1. Measure time intervals that are likely to have low variability.

##### Playback

In order to avoid warm up latency during audio playback it is
[recommended to constantly enqueue buffers containing silence](http://googlesamples.github.io/android-audio-high-performance/guides/audio-output-latency.html#avoid-warm-up-latency).
WALT app follows this pattern.

The audio data buffers are enqueued in the
[player callback](https://github.com/google/walt/blob/v0.1.6/android/WALT/app/src/main/jni/player.c#L107)
and the latency reported by WALT app is the time from the
[Enqueue() call](https://github.com/google/walt/blob/v0.1.6/android/WALT/app/src/main/jni/player.c#L123)
until there is a detectable signal on the wire. Note that this does not include the time between the moment the app decided to output a tone until the Enqueue() call. This is somewhat counterintuitive but this time is deliberately omitted. In case of the WALT app code this time is likely be uniformly distributed between 0 and the length of the buffer (5 ms in case of Nexus 5) and therefore would contribute considerable variance but little interesting information if included in the reported latency.

##### Recording
The reported latency is the time from the moment the last frame in a buffer was recorded until the
[recorder callback](https://github.com/google/walt/blob/v0.1.6/android/WALT/app/src/main/jni/player.c#L345)
receiving that buffer is executed.

TODO: Is the round trip latency expected to be Recording latency + Playback latency + one buffer length?

### Sample measurements

| Device       | OS version     |  Buffer                      | Playback [ms] | Recording* [ms] |
| :---         | :---           | :---                         |          ---: |            ---: |
| Nexus 5      | M4B30Z (6.0.1) | 240 frames @ 48 kHz = 5 ms   |          27.6 |             2.5 |
| Nexus 5X     | NRD91P (7.0)   | 192 frames @ 48 kHz = 4 ms   |          14.9 |             3.5 |
| Nexus 7      | LMY47Q (5.1)   | 240 frames @ 48 kHz = 5 ms   |          32.1 |            16.3 |
| Nexus 9      | MMB29K (6.0.1) | 128 frames @ 48 kHz = 2.6 ms |           9.8 |             1.0 |
| Nexus 6P     | MHC19I (6.0.1) | 192 frames @ 48 kHz = 4 ms   |          15.3 |             1.6 |
| Pixel        | NDE63P (7.1)   | 192 frames @ 48 kHz = 4 ms   |           8.9 |             1.7 |
| Pixel XL     | NDE63H (7.1)   | 192 frames @ 48 kHz = 4 ms   |           9.1 |             1.6 |

\* WALT clock synchronization accuracy is about 1 ms hence the relative error for recording latency can be fairly high.

#### Published round trip measurements
Superpowered Inc. maintains an open source app for measuring round trip audio latency -
[Superpowered Latency App](https://github.com/superpoweredSDK/SuperpoweredLatency).

* [Audio round trip measurements published by Android group](https://source.android.com/devices/audio/latency_measurements.html#measurements)
* [Audio round trip measurements published by Superpowered Inc.](http://superpowered.com/latency)

### Hardware

Audio signal for measuring microphone latency is generated as a square wave using the Teensy tone()
function ([currently at 5 kHz](https://github.com/google/walt/blob/v0.1.6/arduino/walt/walt.ino#L310)).
The signal is attenuated by a simple circuit similar to the
[ChromeOS/Android audio loopback dongle](https://source.android.com/devices/audio/loopback.html).

Audio output signal from the phone is detected when audio line voltage crosses a predefined
threshold (currently about 65 mV).

redpajama_set_name: RedPajamaGithub


text:
package com.faforever.client.filter.function;

import com.faforever.client.domain.GameBean;

import java.util.function.BiFunction;

public class SimModsFilterFunction implements BiFunction<Boolean, GameBean, Boolean> {
  @Override
  public Boolean apply(Boolean selected, GameBean game) {
    return !selected || game.getSimMods()
        .isEmpty();
  }
}


text:
Удаление

Удалить текущий ранг?

    <button class="btn btn-primary" type="button" ng-click="VmDeleteRank.delete();VmModal.cancel()">Удалить</button>
    <button class="btn btn-warning" type="button" ng-click="VmModal.cancel()">Отмена</button>


text:
We maintain a list of events (conferences, meetups, etc.) where our team has or will be presenting.
This data is stored in `events.json`.

## How to get an event listed

The `events.json` file is periodically generated from data stored in a Firebase database.
See [here](https://github.com/angular/angular/blob/main/aio/scripts/generate-events/README.md) for more details.

If you want to get an event listed, please get in touch with the Angular DevRel team at [devrel@angular.io](mailto:devrel@angular.io).

> WARNING:
> The `events.json` file is only intended to be updated via a [script](https://github.com/angular/angular/blob/main/aio/scripts/generate-events/index.mjs).
> Do not manually edit the file, because your changes will be overwritten the next time the script runs.


text:
My collection of packages that I install on my development boxes

## Projects
 - https://asciinema.org/
 - https://apidocs.joyent.com/manta/commands-reference.html
 - http://sourabhbajaj.com/mac-setup/iTerm/zsh.html
 - https://nodejs.org/download/
 - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
 - http://rvm.io/

## Brew Commands
```
brew tap homebrew/boneyard
```

```
brew install more autoconf automake cscope docker gdbm gettext glib gmp gnu-tar go gradle221 libevent libffi libgpg-error libksba libtool libyaml macvim markdown maven mdbtools mercurial openssl pandoc pcre pkg-config readline s3cmd siege sproxy tmux wget zsh zsh-completions tree fortune cowsay
```


text:
<!DOCTYPE html>
<html>
<head>
    <title>RallyAppTest</title>

    <script type="text/javascript" src="/apps/2.0/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function () {
                Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function() {
        //Write app code here
        console.log("Hello World");
        this._loadData();
        console.log("What is This?" , this);

        //API Docs: https://help.rallydev.com/apps/2.0/doc/
    },

    _loadData: function(){

        console.log("inside data block");

        var MyStore = Ext.create('Rally.data.wsapi.Store', {

            model: "User Story",

            autoLoad: true ,

            listeners: {
                load: function(myStore,myData,success){
                    console.log("My Store is" , myStore);
                    console.log("My Data is" , myData);

                    this._loadDataGrid(myStore);
                },
                scope: this
            },

            filters: [
                {
                    property: "c_KanbanState",
                    operator: "=",
                    value:    "Accepted"
                }

            ],

            context: this.getContext().getProject()._ref,

            fetch: ["FormattedID", "Name", "Feature", "Owner", "InProgressDate", "ScheduleState" , "c_KanbanState"]
        });
    },

    _loadDataGrid: function(myDataStore){

        var myGrid = Ext.create("Rally.ui.grid.Grid", {
            store: myDataStore,
            columnCfgs: ["FormattedID", "Name", "Feature", "Owner", "InProgressDate", "ScheduleState" , "c_KanbanState"]
        });

        this.add(myGrid);
    }
});

            Rally.launchApp('CustomApp', {
                name:"RallyAppTest",
	            parentRepos:""
            });

        });
    </script>

    <style type="text/css">
        .app {
  /* Add app styles here */
}

    </style>
</head>
<body>
</body>
</html>


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:orientation="horizontal"
	android:gravity="center_vertical"
	android:paddingBottom="4sp"
	android:paddingTop="4sp"
	android:paddingLeft="8sp"
	android:paddingRight="8sp"
	android:descendantFocusability="blocksDescendants">

	<ImageView android:id="@+id/ivThemePicture"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:src="@drawable/icon_header_default" />
	<LinearLayout android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:layout_weight="1"
		android:layout_marginLeft="8sp"
		android:layout_marginRight="2sp"
		android:orientation="vertical">
		<LinearLayout android:layout_width="fill_parent"
		    android:layout_height="wrap_content"
		    android:gravity="center_vertical"
		    android:orientation="horizontal">
		    <TextView android:id="@+id/tvThemeName"
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:ellipsize="end"
			    android:singleLine="true"
			    style="@style/list_user_profile_name">
		    </TextView>
		</LinearLayout>

		<TextView android:id="@+id/tvFileSize"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			style="@style/list_user_impress">
		</TextView>
	</LinearLayout>
	<Button
		android:id="@+id/btnThemeOperate"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="4sp"
		android:minWidth="78sp"
		android:focusable="false" />
</LinearLayout>


text:
from mudwyrm_users.admin.achaea import ScriptState, ScriptError
from mudwyrm_users.admin.achaea.trigger import Trigger, Alias, OnEvent
from mudwyrm_users.admin.achaea.action import Action, Outcome, EventOutcome
from mudwyrm_users.admin.achaea.common import not_, AttrDict

from mudwyrm_users.admin.achaea.scripts import char
from mudwyrm_users.admin.achaea.scripts import achaea
from mudwyrm_users.admin.achaea.scripts.actions3p import aspects as aa
from mudwyrm_users.admin.achaea.scripts.actions import all_actions as actions
from mudwyrm_users.admin.achaea.scripts.denizen import Denizen

p = None
s = ScriptState()

def init(processor):
    assert processor is not None
    global p
    p = processor

name = "the Mesmerium"

class dream_horror(Denizen):
    info_line = 'a dream horror'
    aggressive = True

    @Trigger(r'^Focusing its eyes upon you, (a dream horror) paws at you with its diseased claws\.$')
    def attack1_start(match):
        p.act(dream_horror.attack1, match.group(1))

    class attack1(Action, aa.EndsWithPrompt,
                  aa.Offensive, aa.Physical,
                  aa.Loki):
        def start(action, actor):
            pass


text:
package org.noorganization.instalist.view.touchlistener.sidebar;

import android.content.Context;
import android.view.View;
import android.widget.EditText;

import org.noorganization.instalist.R;
import org.noorganization.instalist.presenter.ICategoryController;
import org.noorganization.instalist.presenter.IListController;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.model.Category;
import org.noorganization.instalist.model.ShoppingList;
import org.noorganization.instalist.view.event.ShoppingListSelectedMessage;
import org.noorganization.instalist.view.fragment.ShoppingListOverviewFragment;
import org.noorganization.instalist.view.interfaces.IBaseActivity;
import org.noorganization.instalist.view.utils.ViewUtils;

import de.greenrobot.event.EventBus;

/**
 * Used to process various add list processes to categories.
 * Created by TS on 27.06.2015.
 */
public class OnShoppingListAddClickListener implements View.OnClickListener {

    /**
     * The Category Id.
     */
    private String mCategoryId;

    /**
     * The EditText where the new ShoppingList name is placed.
     */
    private EditText mNewNameEditText;

    private IListController mListController;
    private ICategoryController mCategoryController;

    /**
     * Constructor of OnShoppingListAddClickListener
     * @param _CategoryId the CategoryId where the list should be added. If in PlainList Mode then use the default category.
     */
    public OnShoppingListAddClickListener(Context _context, String _CategoryId, EditText _NewNameEditText) {
        mCategoryId = _CategoryId;
        mNewNameEditText = _NewNameEditText;
        mListController = ControllerFactory.getListController(_context);
        mCategoryController = ControllerFactory.getCategoryController(_context);
    }

    @Override
    public void onClick(View _View) {
        Context context = _View.getContext();

        String listName = ViewUtils.validateAndGetResultEditText(context, mNewNameEditText);
        if (listName == null) {
            return;
        }

        ShoppingList shoppingList = mListController.addList(listName);
        if (shoppingList == null) {
            mNewNameEditText.setError(context.getResources().getString(R.string.list_exists));
            return;
        }
        Category category = mCategoryController.getCategoryByID(mCategoryId);
        shoppingList = mListController.moveToCategory(shoppingList, category);

        if(shoppingList == null){
            mNewNameEditText.setError(context.getResources().getString(R.string.list_to_category_failed));
            return;
        }

        ViewUtils.removeSoftKeyBoard(_View.getContext(), mNewNameEditText);
        _View.setVisibility(View.GONE);
        mNewNameEditText.clearFocus();
        // clear the field
        mNewNameEditText.setText("");
        EventBus.getDefault().post(new ShoppingListSelectedMessage(shoppingList));
    }
}


text:
using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;

namespace RefactoringEssentials.CSharp.CodeRefactorings
{
    [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Sort usings")]
    public class SortUsingsAction : CodeRefactoringProvider
    {
        public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
        {
            var document = context.Document;
            var span = context.Span;
            var cancellationToken = context.CancellationToken;
            var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
            if (model.IsFromGeneratedCode(cancellationToken))
                return;
            var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
            var node = root.FindNode(span);
            if (node == null)
                return;

            var usingDirective = node.FirstAncestorOrSelf<SyntaxNode>(n => n is UsingDirectiveSyntax);

            // a CodeAction that doesn't change the document seems to crash VS
            // so we have to check if the usings are already sorted, and cancel if necessary.
            if (usingDirective == null || CheckAllSorted(root, model))
                return;

            context.RegisterRefactoring(
                CodeActionFactory.Create(span, DiagnosticSeverity.Info, GettextCatalog.GetString("Sort usings"), cancellation =>
                {
                    var newRoot = root;
                    var blocks = EnumerateUsingBlocks(root);

                    foreach (var block in blocks)
                    {
                        var originalNodes = block.Select(n => new UsingInfo(n, model)).ToArray();

                        newRoot = newRoot.TrackNodes(originalNodes.Select(n => n.Node));

                        var sortedNodes = originalNodes.OrderBy(_ => _).ToArray();

                        for (var i = 0; i < originalNodes.Length; ++i)
                        {
                            var replacement = sortedNodes[i].Node
                                .WithTrailingTrivia(originalNodes[i].Node.GetTrailingTrivia())
                                .WithLeadingTrivia(originalNodes[i].Node.GetLeadingTrivia());
                            newRoot = newRoot.ReplaceNode(newRoot.GetCurrentNode(originalNodes[i].Node), replacement);
                        }
                    }

                    return Task.FromResult(document.WithSyntaxRoot(newRoot));
                })
            );
        }

        private static bool CheckAllSorted(SyntaxNode root, SemanticModel model)
        {
            var blocks = EnumerateUsingBlocks(root);

            foreach (var block in blocks)
            {
                var nodes = block.Select(n => new UsingInfo(n, model)).ToArray();
                var sorted = nodes.OrderBy(_ => _).ToArray();
                if (!nodes.SequenceEqual(sorted))
                    return false;
            }

            return true;
        }

        private static IEnumerable<IEnumerable<UsingDirectiveSyntax>> EnumerateUsingBlocks(SyntaxNode root)
        {
            var alreadyAddedNodes = new HashSet<UsingDirectiveSyntax>();

            foreach (var child in root.DescendantNodes())
            {
                if (child is UsingDirectiveSyntax && !alreadyAddedNodes.Contains(child))
                {
                    var blockNodes = child.Parent.ChildNodes().OfType<UsingDirectiveSyntax>().ToArray();

                    alreadyAddedNodes.UnionWith(blockNodes);
                    yield return blockNodes;
                }
            }
        }

        private sealed class UsingInfo : IComparable<UsingInfo>
        {
            public UsingDirectiveSyntax Node;

            public string Alias;
            public string Name;

            public bool IsAlias;
            public bool HasTypesFromOtherAssemblies;
            public bool IsSystem;

            public UsingInfo(UsingDirectiveSyntax node, SemanticModel context)
            {
                Alias = node.Alias?.Name?.Identifier.ValueText;
                Name = node.Name.ToString();
                IsAlias = Alias != null;

                var result = context.GetSymbolInfo(node.Name);
                if (result.Symbol is INamespaceSymbol)
                {
                    HasTypesFromOtherAssemblies = ((INamespaceSymbol)result.Symbol).ConstituentNamespaces.Select(cn => cn.ContainingAssembly).Any(a => context.Compilation.Assembly != a);
                }

                IsSystem = HasTypesFromOtherAssemblies && (Name == "System" || Name.StartsWith("System.", StringComparison.Ordinal));

                Node = node;
            }

            public int CompareTo(UsingInfo y)
            {
                UsingInfo x = this;
                if (x.IsAlias != y.IsAlias)
                    return x.IsAlias ? 1 : -1;
                else if (x.HasTypesFromOtherAssemblies != y.HasTypesFromOtherAssemblies)
                    return x.HasTypesFromOtherAssemblies ? -1 : 1;
                else if (x.IsSystem != y.IsSystem)
                    return x.IsSystem ? -1 : 1;
                else if (x.Alias != y.Alias)
                    return StringComparer.Ordinal.Compare(x.Alias, y.Alias);
                else if (x.Name != y.Name)
                    return StringComparer.Ordinal.Compare(x.Name, y.Name);
                else
                    return 0;
            }
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="#7f7f7f7f" />
    <item android:state_window_focused="false" android:color="#7f7f7f7f" />
    <item android:state_pressed="true" android:color="#ff7f7f7f" />
    <item android:state_focused="true" android:color="#ff7f7f7f" />
    <item android:color="#ff7f7f7f" android:state_activated="true" />
    <item android:color="#ff7f7f7f" />
</selector>


text:
#include "config.h"

#include "modules/mediastream/RTCSessionDescription.h"

#include "bindings/v8/Dictionary.h"
#include "core/dom/ExceptionCode.h"
#include "public/platform/WebRTCSessionDescription.h"

namespace WebCore {

static bool verifyType(const String& type)
{
    return type == "offer" || type == "pranswer" || type == "answer";
}

PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(const Dictionary& dictionary, ExceptionCode& ec)
{
    String type;
    bool ok = dictionary.get("type", type);
    if (!ok || !verifyType(type)) {
        ec = TYPE_MISMATCH_ERR;
        return 0;
    }

    String sdp;
    ok = dictionary.get("sdp", sdp);
    if (!ok || sdp.isEmpty()) {
        ec = TYPE_MISMATCH_ERR;
        return 0;
    }

    return adoptRef(new RTCSessionDescription(WebKit::WebRTCSessionDescription(type, sdp)));
}

PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(WebKit::WebRTCSessionDescription webSessionDescription)
{
    return adoptRef(new RTCSessionDescription(webSessionDescription));
}

RTCSessionDescription::RTCSessionDescription(WebKit::WebRTCSessionDescription webSessionDescription)
    : m_webSessionDescription(webSessionDescription)
{
    ScriptWrappable::init(this);
}

RTCSessionDescription::~RTCSessionDescription()
{
}

String RTCSessionDescription::type()
{
    return m_webSessionDescription.type();
}

void RTCSessionDescription::setType(const String& type, ExceptionCode& ec)
{
    if (verifyType(type))
        m_webSessionDescription.setType(type);
    else
        ec = TYPE_MISMATCH_ERR;
}

String RTCSessionDescription::sdp()
{
    return m_webSessionDescription.sdp();
}

void RTCSessionDescription::setSdp(const String& sdp, ExceptionCode& ec)
{
    m_webSessionDescription.setSDP(sdp);
}

WebKit::WebRTCSessionDescription RTCSessionDescription::webSessionDescription()
{
    return m_webSessionDescription;
}

} // namespace WebCore


text:
require 'spec_helper'

describe Virtus::Attribute, '#coerce' do
  subject { object.coerce(value) }

  let(:object)          { described_class.new(:name, options)                              }
  let(:options)         { { :primitive => primitive, :coercion_method => coercion_method } }
  let(:primitive)       { stub('primitive')                                                }
  let(:coercion_method) { stub('coercion_method')                                          }
  let(:value)           { mock('value', :class => value_class)                             }
  let(:value_class)     { stub('value_class')                                              }
  let(:coercer)         { mock('coercer', :public_send => coerced)                         }
  let(:coerced)         { stub('coerced')                                                  }

  before do
    Virtus::Coercion.stub(:[]).with(value_class).and_return(coercer)
  end

  it { should be(coerced) }

  it 'asks for a coercer object' do
    Virtus::Coercion.should_receive(:[]).with(value_class)
    subject
  end

  it 'asks the coercer to coerce the value' do
    coercer.should_receive(:public_send).with(coercion_method, value)
    subject
  end
end


text:
/**
 * Description: Health check route which responds with status of 'ok'.
 *
 * @param  {object} req Express's request object
 * @param  {object} res Express's callback response object
 * @return  {null}
 */

const handleGetServerStatusRequest = (req, res) => {
    req.log.info({ modulePath: global.getCurrentModuleId(__filename) }, 'Handling GET Server Status Request');

    res.json({
        id: 'pangiia-api',
        status: 'ok'
    })
}

export default handleGetServerStatusRequest


text: {% systemjs_import 'app/dummy2' %}


text:
namespace content {
class ResourceContext;
}

// Delegate to handle unlocking a slot or indicating which slot to store a key
// in. When passing to NSS functions which take a wincx argument, use the value
// returned from the wincx() method.
class ChromeNSSCryptoModuleDelegate
    : public crypto::NSSCryptoModuleDelegate {
 public:
  // Create a ChromeNSSCryptoModuleDelegate. |reason| is used to select what
  // string to show the user, |server| is displayed to indicate which connection
  // is causing the dialog to appear.
  ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason,
                                const net::HostPortPair& server);

  virtual ~ChromeNSSCryptoModuleDelegate();

  // Must be called on IO thread. Returns true if the delegate is ready for use.
  // Otherwise, if |initialization_complete_callback| is non-null, the
  // initialization will proceed asynchronously and the callback will be run
  // once the delegate is ready to use. In that case, the caller must ensure the
  // delegate remains alive until the callback is run.
  bool InitializeSlot(content::ResourceContext* context,
                      const base::Closure& initialization_complete_callback)
      WARN_UNUSED_RESULT;

  // crypto::NSSCryptoModuleDelegate implementation.
  virtual crypto::ScopedPK11Slot RequestSlot() OVERRIDE;

  // crypto::CryptoModuleBlockingPasswordDelegate implementation.
  virtual std::string RequestPassword(const std::string& slot_name,
                                      bool retry,
                                      bool* cancelled) OVERRIDE;

 private:
  void ShowDialog(const std::string& slot_name, bool retry);

  void GotPassword(const std::string& password);

  void DidGetSlot(const base::Closure& callback, crypto::ScopedPK11Slot slot);

  // Parameters displayed in the dialog.
  const chrome::CryptoModulePasswordReason reason_;
  net::HostPortPair server_;

  // Event to block worker thread while waiting for dialog on UI thread.
  base::WaitableEvent event_;

  // Stores the results from the dialog for access on worker thread.
  std::string password_;
  bool cancelled_;

  // The slot which will be returned by RequestSlot.
  crypto::ScopedPK11Slot slot_;

  DISALLOW_COPY_AND_ASSIGN(ChromeNSSCryptoModuleDelegate);
};

// Create a delegate which only handles unlocking slots.
crypto::CryptoModuleBlockingPasswordDelegate*
    CreateCryptoModuleBlockingPasswordDelegate(
        chrome::CryptoModulePasswordReason reason,
        const net::HostPortPair& server);

#endif  // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_


text:
package org.killbill.billing.client;

// Copied over from org.killbill.billing.jaxrs.resources.JaxRsResourceBase
// to avoid a cyclic dependency in the build
public interface JaxrsResource {

    public static final String API_PREFIX = "";
    public static final String API_VERSION = "/1.0";
    public static final String API_POSTFIX = "/kb";

    public static final String PREFIX = API_PREFIX + API_VERSION + API_POSTFIX;

    /*
     * Resource paths
     */
    public static final String ACCOUNTS = "accounts";
    public static final String ACCOUNTS_PATH = PREFIX + "/" + ACCOUNTS;
    public static final String AUDIT_LOGS = "auditLogs";
    public static final String AUDIT_LOG_WITH_HISTORY = "auditLogsWithHistory";
    public static final String ATTEMPTS = "attempts";
    public static final String BUNDLES = "bundles";
    public static final String BUNDLES_PATH = PREFIX + "/" + BUNDLES;
    public static final String CATALOG = "catalog";
    public static final String CATALOG_PATH = PREFIX + "/" + CATALOG;
    public static final String CHARGEBACKS = "chargebacks";
    public static final String CHARGES = "charges";
    public static final String CHILDREN = "children";
    public static final String CREDITS = "credits";
    public static final String CREDITS_PATH = PREFIX + "/" + CREDITS;
    public static final String CUSTOM_FIELDS = "customFields";
    public static final String ALL_CUSTOM_FIELDS = "allCustomFields";
    public static final String CUSTOM_FIELDS_PATH = PREFIX + "/" + CUSTOM_FIELDS;
    public static final String EMAILS = "emails";
    public static final String EMAIL_NOTIFICATIONS = "emailNotifications";
    public static final String FORM = "form";
    public static final String HOSTED = "hosted";
    public static final String INVOICE_HTML = "html";
    public static final String INVOICES = "invoices";
    public static final String INVOICES_PATH = PREFIX + "/" + INVOICES;
    public static final String INVOICE_ITEMS = "invoiceItems";
    public static final String INVOICE_ITEMS_PATH = PREFIX + "/" + INVOICE_ITEMS;
    public static final String DRY_RUN = "dryRun";
    public static final String INVOICE_PAYMENTS = "invoicePayments";
    public static final String INVOICE_PAYMENTS_PATH = PREFIX + "/" + INVOICE_PAYMENTS;
    public static final String NOTIFICATION = "notification";
    public static final String OVERDUE = "overdue";
    public static final String OVERDUE_PATH = PREFIX + "/" + OVERDUE;
    public static final String PAGINATION = "pagination";
    public static final String PAYMENTS = "payments";
    public static final String PAYMENTS_PATH = PREFIX + "/" + PAYMENTS;
    public static final String PAYMENT_TRANSACTIONS = "paymentTransactions";
    public static final String PAYMENT_TRANSACTIONS_PATH = PREFIX + "/" + PAYMENT_TRANSACTIONS;
    public static final String PAYMENT_GATEWAYS = "paymentGateways";
    public static final String PAYMENT_GATEWAYS_PATH = PREFIX + "/" + PAYMENT_GATEWAYS;
    public static final String PAYMENT_METHODS = "paymentMethods";
    public static final String PAYMENT_METHODS_DEFAULT_PATH_POSTFIX = "setDefault";
    public static final String PAYMENT_METHODS_PATH = PREFIX + "/" + PAYMENT_METHODS;
    public static final String PLUGINS = "plugins";
    public static final String PLUGINS_PATH = "/" + PLUGINS;
    public static final String REFUNDS = "refunds";
    public static final String REGISTER_NOTIFICATION_CALLBACK = "registerNotificationCallback";
    public static final String UPLOAD_PLUGIN_CONFIG = "uploadPluginConfig";
    public static final String UPLOAD_PER_TENANT_CONFIG = "uploadPerTenantConfig";
    public static final String UPLOAD_PLUGIN_PAYMENT_STATE_MACHINE_CONFIG = "uploadPluginPaymentStateMachineConfig";
    public static final String SEARCH = "search";
    public static final String SECURITY = "security";
    public static final String SECURITY_PATH = PREFIX + "/" + SECURITY;
    public static final String SUBSCRIPTIONS = "subscriptions";
    public static final String SUBSCRIPTIONS_PATH = PREFIX + "/" + SUBSCRIPTIONS;
    public static final String TAGS = "tags";
    public static final String ALL_TAGS = "allTags";
    public static final String TAGS_PATH = PREFIX + "/" + TAGS;
    public static final String TAG_DEFINITIONS = "tagDefinitions";
    public static final String TAG_DEFINITIONS_PATH = PREFIX + "/" + TAG_DEFINITIONS;
    public static final String TENANTS = "tenants";
    public static final String TENANTS_PATH = PREFIX + "/" + TENANTS;
    public static final String ADMIN = "admin";
    public static final String ADMIN_PATH = PREFIX + "/" + ADMIN;
    public static final String CACHE = "cache";
    public static final String TIMELINE = "timeline";
    public static final String USAGES = "usages";
    public static final String USAGES_PATH = PREFIX + "/" + USAGES;
    public static final String COMBO = "combo";
    public static final String MIGRATION = "migration";
    public static final String BLOCK = "block";
    public static final String BCD = "bcd";
    public static final String TRANSFER_CREDIT = "transferCredit";
    public static final String SIMPLE_PLAN = "simplePlan";
    public static final String CANCEL_SCHEDULED_PAYMENT_TRANSACTION = "cancelScheduledPaymentTransaction";
    public static final String VERSIONS = "versions";

    /*
     * Multi-Tenancy headers
     */
    public static final String HDR_API_KEY = "X-Killbill-ApiKey";
    public static final String HDR_API_SECRET = "X-Killbill-ApiSecret";

    /*
     * Metadata Additional headers
     */
    public static final String HDR_CREATED_BY = "X-Killbill-CreatedBy";
    public static final String HDR_REASON = "X-Killbill-Reason";
    public static final String HDR_COMMENT = "X-Killbill-Comment";
    public static final String HDR_PAGINATION_CURRENT_OFFSET = "X-Killbill-Pagination-CurrentOffset";
    public static final String HDR_PAGINATION_NEXT_OFFSET = "X-Killbill-Pagination-NextOffset";
    public static final String HDR_PAGINATION_TOTAL_NB_RECORDS = "X-Killbill-Pagination-TotalNbRecords";
    public static final String HDR_PAGINATION_MAX_NB_RECORDS = "X-Killbill-Pagination-MaxNbRecords";
    public static final String HDR_PAGINATION_NEXT_PAGE_URI = "X-Killbill-Pagination-NextPageUri";
    public static final String HDR_REQUEST_ID = "X-Request-Id";

    /*
     * Query parameters
     */
    public static final String QUERY_ACCOUNT_ID = "accountId";
    public static final String QUERY_ACCOUNT_WITH_BALANCE = "accountWithBalance";
    public static final String QUERY_ACCOUNT_WITH_BALANCE_AND_CBA = "accountWithBalanceAndCBA";
    public static final String QUERY_ACCOUNT_TREAT_NULL_AS_RESET = "treatNullAsReset";
    public static final String QUERY_AUDIT = "audit";
    public static final String QUERY_CACHE_NAME = "cacheName";
    public static final String QUERY_TENANT_API_KEY = "tenantApiKey";
    public static final String QUERY_BILLING_POLICY = "billingPolicy";
    public static final String QUERY_CALL_COMPLETION = "callCompletion";
    public static final String QUERY_CALL_TIMEOUT = "callTimeoutSec";
    public static final String QUERY_CUSTOM_FIELDS = "customFieldList";
    public static final String QUERY_DELETE_DEFAULT_PM_WITH_AUTO_PAY_OFF = "deleteDefaultPmWithAutoPayOff";
    public static final String QUERY_FORCE_DEFAULT_PM_DELETION = "forceDefaultPmDeletion";
    public static final String QUERY_DRY_RUN = "dryRun";
    public static final String QUERY_ENTITLEMENT_POLICY = "entitlementPolicy";
    public static final String QUERY_EXTERNAL_KEY = "externalKey";
    public static final String QUERY_INVOICE_WITH_ITEMS = "withItems";
    public static final String QUERY_INVOICE_WITH_CHILDREN_ITEMS = "withChildrenItems";
    public static final String QUERY_NOTIFICATION_CALLBACK = "cb";
    public static final String QUERY_PAYMENT_EXTERNAL = "externalPayment";
    public static final String QUERY_PAYMENT_METHOD_ID = "paymentMethodId";
    public static final String QUERY_PAYMENT_METHOD_IS_DEFAULT = "isDefault";
    public static final String QUERY_PAYMENT_PLUGIN_NAME = "pluginName";
    public static final String QUERY_PAY_INVOICE = "payInvoice";
    public static final String QUERY_PLUGIN_PROPERTY = "pluginProperty";
    public static final String QUERY_REQUESTED_DT = "requestedDate";
    public static final String QUERY_ENTITLEMENT_REQUESTED_DT = "entitlementDate";
    public static final String QUERY_BILLING_REQUESTED_DT = "billingDate";
    public static final String QUERY_PAYMENT_EXT_KEY = "paymentExternalKey";
    public static final String QUERY_TRANSACTION_EXT_KEY = "transactionExternalKey";
    public static final String QUERY_SEARCH_LIMIT = "limit";
    public static final String QUERY_SEARCH_OFFSET = "offset";
    public static final String QUERY_TAGS = "tagList";
    public static final String QUERY_OBJECT_TYPE = "objectType";
    public static final String QUERY_TARGET_DATE = "targetDate";
    public static final String QUERY_UNPAID_INVOICES_ONLY = "unpaidInvoicesOnly";
    public static final String QUERY_PAYMENT_METHOD_PLUGIN_NAME = "pluginName";
    public static final String QUERY_WITH_PLUGIN_INFO = "withPluginInfo";
    public static final String QUERY_AUTO_COMMIT = "autoCommit";
    public static final String QUERY_WITH_MIGRATION_INVOICES = "withMigrationInvoices";
    public static final String QUERY_INCLUDE_VOIDED_INVOICES = "includeVoidedInvoices";
    public static final String QUERY_BLOCKING_STATE_TYPES = "blockingStateTypes";
    public static final String QUERY_BLOCKING_STATE_SVCS = "blockingStateSvcs";
    public static final String QUERY_ENTITLEMENT_EFFECTIVE_FROM_DT = "effectiveFromDate";
    public static final String QUERY_TENANT_USE_GLOBAL_DEFAULT = "useGlobalDefault";

    public static final String QUERY_WITH_ATTEMPTS = "withAttempts";
    public static final String UPCOMING_INVOICE_TARGET_DATE = "upcomingInvoiceTargetDate";
    public static final String QUERY_START_DATE = "startDate";
    public static final String QUERY_END_DATE = "endDate";
    public static final String QUERY_USE_REQUESTED_DATE_FOR_BILLING = "useRequestedDateForBilling";
    public static final String QUERY_INCLUDED_DELETED = "includedDeleted";
    public static final String QUERY_MIGRATED = "migrated";

    public static final String QUERY_CANCEL_ALL_SUBSCRIPTIONS = "cancelAllSubscriptions";
    public static final String QUERY_WRITE_OFF_UNPAID_INVOICES = "writeOffUnpaidInvoices";
    public static final String QUERY_ITEM_ADJUST_UNPAID_INVOICES = "itemAdjustUnpaidInvoices";
}


text:
@implementation TTSolidFillStyle

@synthesize color = _color;

///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Class public

///////////////////////////////////////////////////////////////////////////////////////////////////
+ (TTSolidFillStyle*)styleWithColor:(UIColor*)color next:(TTStyle*)next {
  TTSolidFillStyle* style = [[self alloc] initWithNext:next];
  style.color = color;
  return style;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark TTStyle

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)draw:(TTStyleContext*)context {
  CGContextRef ctx = UIGraphicsGetCurrentContext();

  CGContextSaveGState(ctx);
  [context.shape addToPath:context.frame];

  [_color setFill];
  CGContextFillPath(ctx);
  CGContextRestoreGState(ctx);

  return [self.next draw:context];
}

@end


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed to the Austrian Association for Software Tool Integration (AASTI)
    under one or more contributor license agreements. See the NOTICE file
    distributed with this work for additional information regarding copyright
    ownership. The AASTI licenses this file to you under the Apache License,
    Version 2.0 (the "License"); you may not use this file except in compliance
    with the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.openengsb.connector</groupId>
    <artifactId>openengsb-connector-parent</artifactId>
    <version>3.0.0-SNAPSHOT</version>
  </parent>

  <properties>
    <bundle.symbolicName>org.openengsb.connector.gcalendar</bundle.symbolicName>
    <bundle.namespace>org.openengsb.connector.gcalendar</bundle.namespace>
    <google.calendar.version>1.41.5</google.calendar.version>
    <google.gdata.wrapped.version>1.41.5.w1</google.gdata.wrapped.version>
    <openengsb.domain.version>3.0.0-SNAPSHOT</openengsb.domain.version>
    <openengsb.domain.range>[3.0,4)</openengsb.domain.range>
    <openengsb.framework.version>3.0.0-SNAPSHOT</openengsb.framework.version>
  </properties>

  <groupId>org.openengsb.connector</groupId>
  <artifactId>org.openengsb.connector.gcalendar</artifactId>
  <version>3.0.0-SNAPSHOT</version>

  <name>OpenEngSB :: Connector :: Gcalendar</name>

  <packaging>bundle</packaging>

  <description>Implements the connector to Google Calendar for appointment domain</description>

  <url>http://www.openengsb.org</url>

  <inceptionYear>2010</inceptionYear>

  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:git://github.com/openengsb/openengsb-connector-gcalendar.git</connection>
    <developerConnection>scm:git:git@github.com:openengsb/openengsb-connector-gcalendar.git</developerConnection>
    <url>http://github.com/openengsb/openengsb-connector-gcalendar</url>
  </scm>

  <issueManagement>
    <system>JIRA</system>
    <url>http://issues.openengsb.org/jira/browse/OPENENGSB</url>
  </issueManagement>

  <ciManagement>
    <system>OpenCIT</system>
    <url>http://build.openengsb.org/opencit/</url>
  </ciManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Import-Package>
              ${openengsb.imports},
              org.openengsb.domain.appointment.*;version="${openengsb.domain.range}",
              *
            </Import-Package>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.openengsb</groupId>
        <artifactId>openengsb-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.agilejava.docbkx</groupId>
        <artifactId>docbkx-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- OpenEngSB References -->
    <dependency>
      <groupId>org.openengsb.framework</groupId>
      <artifactId>org.openengsb.framework.api</artifactId>
      <version>${openengsb.framework.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.openengsb.framework</groupId>
      <artifactId>org.openengsb.framework.common</artifactId>
      <version>${openengsb.framework.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.openengsb.framework</groupId>
      <artifactId>org.openengsb.framework.test</artifactId>
      <version>${openengsb.framework.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- Appointment Domain References -->
    <dependency>
      <groupId>org.openengsb.domain</groupId>
      <artifactId>org.openengsb.domain.appointment</artifactId>
      <version>${openengsb.domain.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Library References -->
    <dependency>
      <groupId>com.google.gdata</groupId>
      <artifactId>gdata-calendar-2.0</artifactId>
      <version>${google.calendar.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <repositories>
    <repository> <!-- OEB snapshots are deployed here -->
     <id>sonatype-snapshots</id>
      <name>Sonaype Snapsht Repository</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
    <repository>
      <id>mandubian-mvn</id>
      <url>http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository</url>
    </repository>
  </repositories>

</project>


text:
import akka.actor.{Actor, ActorRef, Terminated}

import scala.collection.mutable

class Reaper extends Actor {

  def allSoulsReaped(): Unit = {
    context.system.terminate()
  }

  final def receive = {
    case WatchMe(ref) =>
      context.watch(ref)
      watched += ref
    case Terminated(ref) =>
      watched -= ref
      if (watched.isEmpty) allSoulsReaped()
  }

  private[this] val watched = mutable.ArrayBuffer.empty[ActorRef]

}


text:
import codecs
import os
import re

def read(*parts):
    """
    Build an absolute path from *parts* and and return the contents of the
    resulting file.  Assume UTF-8 encoding.
    """
    here = os.path.abspath(os.path.dirname(__file__))
    with codecs.open(os.path.join(here, *parts), "rb", "utf-8") as f:
        return f.read()

def find_version(*file_paths):
    """
    Build a path from *file_paths* and search for a ``__version__``
    string inside.
    """
    version_file = read(*file_paths)
    version_match = re.search(
        r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M
    )
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.doctest",
    "sphinx.ext.intersphinx",
    "sphinx.ext.todo",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# General information about the project.
project = u"attrs"
copyright = u"2015, Hynek Schlawack"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
release = find_version("../src/attr/__init__.py")
version = release.rsplit(u".", 1)[0]
# The full version, including alpha/beta/rc tags.

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]

# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"

# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.

html_theme = "alabaster"
html_theme_options = {
    "font_family": '"Avenir Next", Calibri, "PT Sans", sans-serif',
    "head_font_family": '"Avenir Next", Calibri, "PT Sans", sans-serif',
    "font_size": "18px",
    "page_width": "980px",
    "show_relbars": True,
}

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "_static/attrs_logo.svg"

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# If false, no module index is generated.
html_domain_indices = True

# If false, no index is generated.
html_use_index = True

# If true, the index is split into individual pages for each letter.
html_split_index = False

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''

# Output file base name for HTML help builder.
htmlhelp_basename = "attrsdoc"

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ("index", "attrs", u"attrs Documentation", [u"Hynek Schlawack"], 1)
]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (
        "index",
        "attrs",
        u"attrs Documentation",
        u"Hynek Schlawack",
        "attrs",
        "One line description of project.",
        "Miscellaneous",
    )
]

intersphinx_mapping = {"https://docs.python.org/3": None}

# Allow non-local URIs so we can have images in CHANGELOG etc.
suppress_warnings = ["image.nonlocal_uri"]


text:
"""
test_meta:
==========

A module intended for use with Nose.

"""
from __future__ import absolute_import

import random
import string

from unittest import skip

from chart_studio import plotly as py
from chart_studio.exceptions import PlotlyRequestError
from chart_studio.grid_objs import Column, Grid
from chart_studio.tests.utils import PlotlyTestCase

class MetaTest(PlotlyTestCase):

    _grid = grid = Grid([Column([1, 2, 3, 4], "first column")])
    _meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}}

    def setUp(self):
        super(MetaTest, self).setUp()
        py.sign_in("PythonTest", "xnyU0DEwvAQQCwHVseIL")

    def random_filename(self):
        random_chars = [random.choice(string.ascii_uppercase) for _ in range(5)]
        unique_filename = "Valid Grid with Meta " + "".join(random_chars)
        return unique_filename

    def test_upload_meta(self):
        unique_filename = self.random_filename()
        grid_url = py.grid_ops.upload(self._grid, unique_filename, auto_open=False)

        # Add some Metadata to that grid
        py.meta_ops.upload(self._meta, grid_url=grid_url)

    def test_upload_meta_with_grid(self):
        c1 = Column([1, 2, 3, 4], "first column")
        Grid([c1])

        unique_filename = self.random_filename()

        py.grid_ops.upload(
            self._grid, unique_filename, meta=self._meta, auto_open=False
        )

    @skip(
        "adding this for now so test_file_tools pass, more info"
        + "https://github.com/plotly/python-api/issues/263"
    )
    def test_metadata_to_nonexistent_grid(self):
        non_exist_meta_url = "https://local.plotly.com/~GridTest/999999999"
        with self.assertRaises(PlotlyRequestError):
            py.meta_ops.upload(self._meta, grid_url=non_exist_meta_url)


text:
module RoarMatchers
  def self.missing(actual,expected)
    if (mp = (expected - actual)).any?
      ["Representer", mp]
    else
      ["Spec", actual - expected]
    end
  end

  def self.get_actual_property_names(representer)
    representer.instance_variable_get("@representable_attrs").reject do |key, attrs|
      attrs.options[:collection]
    end.keys
  end

  def self.get_actual_link_names(representer, options={})
    representer.to_json(options);
    representer.links.keys
  end

  def self.extract_options!(args)
    args.last.is_a?(::Hash) ? args.pop : {}
  end

  def self.get_actual_collection_names(representer)
    representer.instance_variable_get("@representable_attrs").select do |key, attrs|
      attrs.options[:collection] && attrs.name != "links_array"
    end.keys
  end
end