com.google.wave.api
Class Blip

java.lang.Object
  extended by com.google.wave.api.Blip
All Implemented Interfaces:
java.io.Serializable

public class Blip
extends java.lang.Object
implements java.io.Serializable

A class that models a single blip instance. Blips are essentially the documents that make up a conversation, that contain annotations, content and elements.

See Also:
Serialized Form

Method Summary
protected  void addThread(BlipThread thread)
          Adds the given BlipThread as a reply or inline reply thread.
 BlipContentRefs all()
          Returns a reference to the entire content of the blip.
 BlipContentRefs all(ElementType target, int maxResult, Restriction... restrictions)
          Returns all references to this blip's content that match target and restrictions.
 BlipContentRefs all(ElementType target, Restriction... restrictions)
          Returns all references to this blip's content that match target and restrictions.
 BlipContentRefs all(java.lang.String target)
          Returns all references to this blip's content that match target.
 BlipContentRefs all(java.lang.String target, int maxResult)
          Returns all references to this blip's content that match target.
 BlipContentRefs append(BlipContent argument)
          Appends the given argument (element, text, or markup) to the blip.
 BlipContentRefs append(java.lang.String argument)
          Appends the given string to the blip.
 void appendMarkup(java.lang.String markup)
          Appends markup (HTML) content.
 BlipContentRefs at(int index)
          Returns the reference to this blip's content at the specified index.
 Blip continueThread()
          Continues the containing thread of this blip..
protected  void deleteAnnotations(int start, int end)
          Deletes all annotations that span from start to end.
protected  void deleteChildBlipId(java.lang.String childBlipId)
          Deletes the given blip id from the list of child blip ids.
static Blip deserialize(OperationQueue operationQueue, Wavelet wavelet, BlipData blipData)
          Deserializes the given BlipData object into an instance of Blip.
 BlipContentRefs first(ElementType target, Restriction... restrictions)
          Returns the first reference to this blip's content that matches target and restrictions.
 BlipContentRefs first(java.lang.String target)
          Returns the first reference to this blip's content that matches target.
 Annotations getAnnotations()
          Returns the annotations for this blip's content.
 java.lang.String getBlipId()
          Returns the id of this blip.
 java.util.List<java.lang.String> getChildBlipIds()
          Returns the list of ids of this blip children.
 java.util.List<Blip> getChildBlips()
          Returns the list of child blips.
 java.lang.String getContent()
          Returns the text content of this blip.
 java.util.List<java.lang.String> getContributors()
          Returns the participant ids of the contributors of this blip.
 java.lang.String getCreator()
          Returns the participant id of the creator of this blip.
 java.util.SortedMap<java.lang.Integer,Element> getElements()
          Returns the elements content of this blip.
 int getInlineBlipOffset()
          Deprecated. please use getThread().getLocation() to get the offset of the inline reply thread that contains this blip.
 java.util.Collection<BlipThread> getInlineReplyThreads()
           
 long getLastModifiedTime()
          Returns the last modified time of this blip.
protected  OperationQueue getOperationQueue()
          Returns the operation queue for sending outgoing operations to the robot proxy.
 Blip getParentBlip()
          Returns the parent blip.
 java.lang.String getParentBlipId()
          Returns the id of this blip's parent, or null if this blip is in the root thread.
 java.util.Collection<BlipThread> getReplyThreads()
           
 BlipThread getThread()
           
 long getVersion()
          Returns the version of this blip.
 WaveId getWaveId()
          Returns the id of the wave that owns this blip.
 Wavelet getWavelet()
          Returns the wavelet that owns this Blip.
 WaveletId getWaveletId()
          Returns the id of the wavelet that owns this blip.
 Blip insertInlineBlip(int position)
          Inserts an inline blip at the given position.
 boolean isRoot()
          Checks whether this is a root blip or not.
 int length()
          Returns the length/size of the blip, denoted by the length of this blip's text content.
 Blip proxyFor(java.lang.String proxyForId)
          Returns a view of this blip that will proxy for the specified id.
 BlipContentRefs range(int start, int end)
          Returns the reference to this blip's content at the specified range.
protected  void removeThread(BlipThread thread)
          Removes the given BlipThread from the reply or inline reply thread.
 Blip reply()
          Creates a reply to this blip.
 BlipData serialize()
          Serializes this Blip into a BlipData.
protected  void shift(int position, int shiftAmount)
          Moves all elements and annotations after the given position by shiftAmount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBlipId

public java.lang.String getBlipId()
Returns the id of this blip.

Returns:
the blip id.

getWaveId

public WaveId getWaveId()
Returns the id of the wave that owns this blip.

Returns:
the wave id.

getWaveletId

public WaveletId getWaveletId()
Returns the id of the wavelet that owns this blip.

Returns:
the wavelet id.

getChildBlipIds

public java.util.List<java.lang.String> getChildBlipIds()
Returns the list of ids of this blip children.

Returns:
the children's ids.

getChildBlips

public java.util.List<Blip> getChildBlips()
Returns the list of child blips.

Returns:
the children of this blip.

getInlineReplyThreads

public java.util.Collection<BlipThread> getInlineReplyThreads()
Returns:
the inline reply threads of this blip, sorted by the offset.

getReplyThreads

public java.util.Collection<BlipThread> getReplyThreads()
Returns:
the reply threads of this blip.

getContributors

public java.util.List<java.lang.String> getContributors()
Returns the participant ids of the contributors of this blip.

Returns:
the blip's contributors.

getCreator

public java.lang.String getCreator()
Returns the participant id of the creator of this blip.

Returns:
the blip's creator.

getLastModifiedTime

public long getLastModifiedTime()
Returns the last modified time of this blip.

Returns:
the blip's last modified time.

getVersion

public long getVersion()
Returns the version of this blip.

Returns:
the blip's version.

getParentBlipId

public java.lang.String getParentBlipId()
Returns the id of this blip's parent, or null if this blip is in the root thread.

Returns:
the blip's parent's id.

getParentBlip

public Blip getParentBlip()
Returns the parent blip.

Returns:
the parent of this blip.

getThread

public BlipThread getThread()
Returns:
the containing thread.

isRoot

public boolean isRoot()
Checks whether this is a root blip or not.

Returns:
true if this is a root blip, denoted by null parent id.

getAnnotations

public Annotations getAnnotations()
Returns the annotations for this blip's content.

Returns:
the blip's annotations.

getElements

public java.util.SortedMap<java.lang.Integer,Element> getElements()
Returns the elements content of this blip.

Returns:
the blip's elements.

getContent

public java.lang.String getContent()
Returns the text content of this blip.

Returns:
blip's content.

length

public int length()
Returns the length/size of the blip, denoted by the length of this blip's text content.

Returns:
the size of the blip.

getWavelet

public Wavelet getWavelet()
Returns the wavelet that owns this Blip.

Returns:
the wavelet.

getOperationQueue

protected OperationQueue getOperationQueue()
Returns the operation queue for sending outgoing operations to the robot proxy.

Returns:
the operation queue.

all

public BlipContentRefs all()
Returns a reference to the entire content of the blip.

Returns:
an instance of BlipContentRefs.

all

public BlipContentRefs all(java.lang.String target)
Returns all references to this blip's content that match target.

Parameters:
target - the text to search for.
Returns:
an instance of BlipContentRefs.

all

public BlipContentRefs all(java.lang.String target,
                           int maxResult)
Returns all references to this blip's content that match target. This blip references object will have at most maxResult hits.

Parameters:
target - the text to search for.
maxResult - the maximum number of hits. Specify -1 for no limit.
Returns:
an instance of BlipContentRefs.

all

public BlipContentRefs all(ElementType target,
                           Restriction... restrictions)
Returns all references to this blip's content that match target and restrictions.

Parameters:
target - the element type to search for.
restrictions - the element properties that need to be matched.
Returns:
an instance of BlipContentRefs.

all

public BlipContentRefs all(ElementType target,
                           int maxResult,
                           Restriction... restrictions)
Returns all references to this blip's content that match target and restrictions. This blip references object will have at most maxResult hits.

Parameters:
target - the element type to search for.
maxResult - the maximum number of hits. Specify -1 for no limit.
restrictions - the element properties that need to be matched.
Returns:
an instance of BlipContentRefs.

first

public BlipContentRefs first(java.lang.String target)
Returns the first reference to this blip's content that matches target.

Parameters:
target - the text to search for.
Returns:
an instance of BlipContentRefs.

first

public BlipContentRefs first(ElementType target,
                             Restriction... restrictions)
Returns the first reference to this blip's content that matches target and restrictions.

Parameters:
target - the type of element to search for.
restrictions - the list of restrictions to filter the search.
Returns:
an instance of BlipContentRefs.

at

public BlipContentRefs at(int index)
Returns the reference to this blip's content at the specified index.

Parameters:
index - the index to reference.
Returns:
an instance of BlipContentRefs.

range

public BlipContentRefs range(int start,
                             int end)
Returns the reference to this blip's content at the specified range.

Parameters:
start - the start index of the range to reference.
end - the end index of the range to reference.
Returns:
an instance of BlipContentRefs.

append

public BlipContentRefs append(BlipContent argument)
Appends the given argument (element, text, or markup) to the blip.

Parameters:
argument - the element, text, or markup to be appended.
Returns:
an instance of BlipContentRefs.

append

public BlipContentRefs append(java.lang.String argument)
Appends the given string to the blip.

Parameters:
argument - the string to be appended.
Returns:
an instance of BlipContentRefs.

reply

public Blip reply()
Creates a reply to this blip.

Returns:
an instance of Blip that represents a reply to the blip.

continueThread

public Blip continueThread()
Continues the containing thread of this blip..

Returns:
an instance of Blip that represents a the new continuation reply blip.

insertInlineBlip

public Blip insertInlineBlip(int position)
Inserts an inline blip at the given position.

Parameters:
position - the index to insert the inline blip at. This has to be greater than 0.
Returns:
an instance of Blip that represents the new inline blip.

appendMarkup

public void appendMarkup(java.lang.String markup)
Appends markup (HTML) content.

Parameters:
markup - the markup content to add.

proxyFor

public Blip proxyFor(java.lang.String proxyForId)
Returns a view of this blip that will proxy for the specified id. A shallow copy of the current blip is returned with the proxyingFor field set. Any modifications made to this copy will be done using the proxyForId, i.e. the robot+<proxyForId>@appspot.com address will be used.

Parameters:
proxyForId - the id to proxy. Please note that this parameter should be properly encoded to ensure that the resulting participant id is valid (see Util.checkIsValidProxyForId(String) for more details).
Returns:
a shallow copy of this blip with the proxying information set.

getInlineBlipOffset

@Deprecated
public int getInlineBlipOffset()
Deprecated. please use getThread().getLocation() to get the offset of the inline reply thread that contains this blip.

Returns the offset of this blip if it is inline, or -1 if it's not. If the parent is not in the offset, this method will always return -1 since it can't determine the inline blip status.

Returns:
the offset of this blip if it is inline, or -1 if it's not inline or if the parent is not in the context.

shift

protected void shift(int position,
                     int shiftAmount)
Moves all elements and annotations after the given position by shiftAmount.

Parameters:
position - the anchor position.
shiftAmount - the amount to shift the annotations range and elements position.

deleteAnnotations

protected void deleteAnnotations(int start,
                                 int end)
Deletes all annotations that span from start to end.

Parameters:
start - the start position.
end - the end position.

deleteChildBlipId

protected void deleteChildBlipId(java.lang.String childBlipId)
Deletes the given blip id from the list of child blip ids.

Parameters:
childBlipId - the blip id to delete.

addThread

protected void addThread(BlipThread thread)
Adds the given BlipThread as a reply or inline reply thread.

Parameters:
thread - the new thread to add.

removeThread

protected void removeThread(BlipThread thread)
Removes the given BlipThread from the reply or inline reply thread.

Parameters:
thread - the new thread to remove.

serialize

public BlipData serialize()
Serializes this Blip into a BlipData.

Returns:
an instance of BlipData that represents this blip.

deserialize

public static Blip deserialize(OperationQueue operationQueue,
                               Wavelet wavelet,
                               BlipData blipData)
Deserializes the given BlipData object into an instance of Blip.

Parameters:
operationQueue - the operation queue.
wavelet - the wavelet that owns this blip.
blipData - the blip data to be deserialized.
Returns:
an instance of Wavelet.