com.google.wave.api
Class BlipContentRefs

java.lang.Object
  extended by com.google.wave.api.BlipContentRefs
All Implemented Interfaces:
java.lang.Iterable<Range>

public class BlipContentRefs
extends java.lang.Object
implements java.lang.Iterable<Range>

A class that represents a set of references to contents in a blip. A BlipContentRefs instance for example can represent the results of a search, an explicitly set range, a regular expression, or refer to the entire blip. BlipContentRefs are used to express operations on a blip in a consistent way that can be easily transfered to the server.


Method Summary
static BlipContentRefs all(Blip blip)
          Constructs an instance representing the entire blip content.
static BlipContentRefs all(Blip blip, ElementType target, int maxResult, Restriction... restrictions)
          Constructs an instance representing the search for element ElementType, that has the properties specified in restrictions.
static BlipContentRefs all(Blip blip, java.lang.String target, int maxResult)
          Constructs an instance representing the search for text target.
 BlipContentRefs annotate(java.lang.String key, java.lang.String... values)
          Annotates the contents at the matched positions.
 BlipContentRefs clearAnnotation(java.lang.String key)
          Clears the annotations at the matched positions.
 BlipContentRefs delete()
          Deletes the contents at the matched positions.
 BlipContentRefs insert(BlipContent... arguments)
          Inserts the given arguments at the matched positions.
 BlipContentRefs insert(Function.BlipContentFunction... functions)
          Inserts computed contents at the matched positions.
 BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, BlipContent... arguments)
          Inserts the given arguments at the matched positions.
 BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, Function.BlipContentFunction... functions)
          Inserts computed contents at the matched positions.
 BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, java.lang.String... arguments)
          Inserts the given strings at the matched positions.
 BlipContentRefs insert(java.lang.String... arguments)
          Inserts the given strings at the matched positions.
 BlipContentRefs insertAfter(BlipContent... arguments)
          Inserts the given arguments just after the matched positions.
 BlipContentRefs insertAfter(Function.BlipContentFunction... functions)
          Inserts computed contents just after the matched positions.
 BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, BlipContent... arguments)
          Inserts the given arguments just after the matched positions.
 BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, Function.BlipContentFunction... functions)
          Inserts computed contents just after the matched positions.
 BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, java.lang.String... arguments)
          Inserts the given strings just after the matched positions.
 BlipContentRefs insertAfter(java.lang.String... arguments)
          Inserts the given strings just after the matched positions.
 boolean isEmpty()
          Checks whether this blip references contains any matches or not.
 java.util.Iterator<Range> iterator()
           
static BlipContentRefs range(Blip blip, int start, int end)
          Constructs an instance representing an explicitly set range.
 BlipContentRefs replace(BlipContent... arguments)
          Replaces the matched positions with the given arguments.
 BlipContentRefs replace(Function.BlipContentFunction... functions)
          Replaces the matched positions with computed contents.
 BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, BlipContent... arguments)
          Replaces the matched positions with the given arguments.
 BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, Function.BlipContentFunction... functions)
          Replaces the matched positions with computed contents.
 BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations, java.lang.String... arguments)
          Replaces the matched positions with the given strings.
 BlipContentRefs replace(java.lang.String... arguments)
          Replaces the matched positions with the given strings.
 BlipContentRefs updateElement(Function.MapFunction... functions)
          Updates the properties of all elements at the matched positions with computed properties maps.
 BlipContentRefs updateElement(Function.MapFunction function)
          Updates the properties of all elements at the matched positions with computed properties map.
 BlipContentRefs updateElement(java.util.Map<java.lang.String,java.lang.String>... newProperties)
          Updates the properties of all elements at the matched positions with the given properties maps.
 BlipContentRefs updateElement(java.util.Map<java.lang.String,java.lang.String> newProperties)
          Updates the properties of all elements at the matched positions with the given properties map.
 BlipContent value()
          Returns the first hit.
 java.util.List<BlipContent> values()
          Returns all matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

all

public static BlipContentRefs all(Blip blip,
                                  java.lang.String target,
                                  int maxResult)
Constructs an instance representing the search for text target.

Parameters:
blip - the blip to find target in.
target - the target to search.
maxResult - the maximum number of results.
Returns:
an instance of blip references.

all

public static BlipContentRefs all(Blip blip,
                                  ElementType target,
                                  int maxResult,
                                  Restriction... restrictions)
Constructs an instance representing the search for element ElementType, that has the properties specified in restrictions.

Parameters:
blip - the blip to find target in.
target - the element type to search.
maxResult - the maximum number of results.
restrictions - the additional properties filter that need to be matched.
Returns:
an instance of blip references.

all

public static BlipContentRefs all(Blip blip)
Constructs an instance representing the entire blip content.

Parameters:
blip - the blip to represent.
Returns:
an instance of blip references.

range

public static BlipContentRefs range(Blip blip,
                                    int start,
                                    int end)
Constructs an instance representing an explicitly set range.

Parameters:
blip - the blip to represent.
start - the start index of the range.
end - the end index of the range.
Returns:
an instance of blip references.

insert

public BlipContentRefs insert(BlipContent... arguments)
Inserts the given arguments at the matched positions.

Parameters:
arguments - the new contents to be inserted.
Returns:
an instance of this blip references, for chaining.

insert

public BlipContentRefs insert(Function.BlipContentFunction... functions)
Inserts computed contents at the matched positions.

Parameters:
functions - the functions to compute the new contents based on the matched contents.
Returns:
an instance of this blip references, for chaining.

insert

public BlipContentRefs insert(java.lang.String... arguments)
Inserts the given strings at the matched positions.

Parameters:
arguments - the new strings to be inserted.
Returns:
an instance of this blip references, for chaining.

insert

public BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                              BlipContent... arguments)
Inserts the given arguments at the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new contents to be inserted.
Returns:
an instance of this blip references, for chaining.

insert

public BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                              Function.BlipContentFunction... functions)
Inserts computed contents at the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
functions - the functions to compute the new contents based on the matched contents.
Returns:
an instance of this blip references, for chaining.

insert

public BlipContentRefs insert(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                              java.lang.String... arguments)
Inserts the given strings at the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new strings to be inserted.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(BlipContent... arguments)
Inserts the given arguments just after the matched positions.

Parameters:
arguments - the new contents to be inserted.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(Function.BlipContentFunction... functions)
Inserts computed contents just after the matched positions.

Parameters:
functions - the functions to compute the new contents based on the matched contents.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(java.lang.String... arguments)
Inserts the given strings just after the matched positions.

Parameters:
arguments - the new strings to be inserted.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                                   BlipContent... arguments)
Inserts the given arguments just after the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new contents to be inserted.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                                   Function.BlipContentFunction... functions)
Inserts computed contents just after the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
functions - the functions to compute the new contents based on the matched contents.
Returns:
an instance of this blip references, for chaining.

insertAfter

public BlipContentRefs insertAfter(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                                   java.lang.String... arguments)
Inserts the given strings just after the matched positions.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new strings to be inserted.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(BlipContent... arguments)
Replaces the matched positions with the given arguments.

Parameters:
arguments - the new contents to replace the original contents.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(Function.BlipContentFunction... functions)
Replaces the matched positions with computed contents.

Parameters:
functions - the functions to compute the new contents.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(java.lang.String... arguments)
Replaces the matched positions with the given strings.

Parameters:
arguments - the new strings to replace the original contents.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                               BlipContent... arguments)
Replaces the matched positions with the given arguments.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new contents to replace the original contents.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                               Function.BlipContentFunction... functions)
Replaces the matched positions with computed contents.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
functions - the functions to compute the new contents.
Returns:
an instance of this blip references, for chaining.

replace

public BlipContentRefs replace(java.util.List<com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation> bundledAnnotations,
                               java.lang.String... arguments)
Replaces the matched positions with the given strings.

Parameters:
bundledAnnotations - annotations to immediately apply to the inserted text.
arguments - the new strings to replace the original contents.
Returns:
an instance of this blip references, for chaining.

delete

public BlipContentRefs delete()
Deletes the contents at the matched positions.

Returns:
an instance of this blip references, for chaining.

annotate

public BlipContentRefs annotate(java.lang.String key,
                                java.lang.String... values)
Annotates the contents at the matched positions.

Parameters:
key - the annotation key.
values - the annotation values.
Returns:
an instance of this blip references, for chaining.

clearAnnotation

public BlipContentRefs clearAnnotation(java.lang.String key)
Clears the annotations at the matched positions.

Parameters:
key - the annotation key to be cleared.
Returns:
an instance of this blip references, for chaining.

updateElement

public BlipContentRefs updateElement(java.util.Map<java.lang.String,java.lang.String> newProperties)
Updates the properties of all elements at the matched positions with the given properties map. Note: The purpose of this overloaded version is because the version that takes a var-args generates compiler warning due to the way generics and var-args are implemented in Java. Most of the time, robot only needs to update one gadget at at time, and it can use this version to avoid the compiler warning.

Parameters:
newProperties - the new properties map.
Returns:
an instance of this blip references, for chaining.

updateElement

public BlipContentRefs updateElement(Function.MapFunction function)
Updates the properties of all elements at the matched positions with computed properties map. Note: The purpose of this overloaded version is because the version that takes a var-args generates compiler warning due to the way generics and var-args are implemented in Java. Most of the time, robot only needs to update one gadget at at time, and it can use this version to avoid the compiler warning.

Parameters:
function - the function to compute the new properties map.
Returns:
an instance of this blip references, for chaining.

updateElement

public BlipContentRefs updateElement(java.util.Map<java.lang.String,java.lang.String>... newProperties)
Updates the properties of all elements at the matched positions with the given properties maps.

Parameters:
newProperties - an array of new properties map.
Returns:
an instance of this blip references, for chaining.

updateElement

public BlipContentRefs updateElement(Function.MapFunction... functions)
Updates the properties of all elements at the matched positions with computed properties maps.

Parameters:
functions - an array of function to compute new properties maps.
Returns:
an instance of this blip references, for chaining.

isEmpty

public boolean isEmpty()
Checks whether this blip references contains any matches or not.

Returns:
true if it has any more matches. Otherwise, returns false.

values

public java.util.List<BlipContent> values()
Returns all matches.

Returns:
a list of BlipContent that represents the hits.

value

public BlipContent value()
Returns the first hit.

Returns:
an instance of BlipContent, that represents the first hit.

iterator

public java.util.Iterator<Range> iterator()
Specified by:
iterator in interface java.lang.Iterable<Range>