http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/BlipData.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/BlipData.java b/src/com/google/wave/api/BlipData.java deleted file mode 100644 index 6aa9466..0000000 --- a/src/com/google/wave/api/BlipData.java +++ /dev/null @@ -1,491 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * BlipData is the serializable data representation of a Blip. It contains - * metadata, a text-only representation of the document content, and a list of - * annotations. - * - * @author [email protected] (Seth Covitz) - * @author [email protected] (Marcel Prasetya) - */ -public class BlipData { - - /** - * The list of annotations for the document content. - */ - private List<Annotation> annotations; - - /** - * The list of elements embedded within the document. - */ - private Map<Integer, Element> elements; - - /** - * The blip id for this blip. - */ - private String blipId; - - /** - * A list of child blip ids for this blip. - */ - private List<String> childBlipIds; - - /** - * A list of contributors to this blip. - */ - private List<String> contributors; - - /** - * The creator of this blip. - */ - private String creator; - - /** - * The text document content for this blip. - */ - private String content; - - /** - * The time this blip was last modified. - */ - private long lastModifiedTime; - - /** - * The parent blip id for this blip. - */ - private String parentBlipId; - - /** - * The latest version number for this blip. - */ - private long version; - - /** - * The Wave ID for the wave containing this blip. - */ - private String waveId; - - /** - * The Wavelet ID for the wavelet containing this blip. - */ - private String waveletId; - - /** - * The inline and non-inline reply thread ids. - */ - private List<String> replyThreadIds; - - /** - * Get the thread to which this blip belongs. - */ - private String threadId; - - /** - * Constructs an empty BlipData object. - */ - public BlipData() { - annotations = new ArrayList<Annotation>(); - elements = new HashMap<Integer, Element>(); - childBlipIds = new ArrayList<String>(); - content = "\n"; - contributors = new ArrayList<String>(); - lastModifiedTime = -1L; - version = -1L; - replyThreadIds = new ArrayList<String>(); - } - - /** - * Constructs a BlipData object. - * - * @param waveId the wave id of the blip. - * @param waveletId the wavelet id of the blip. - * @param blipId the blip id. - * @param initialContent the initial content of the blip. If the supplied - * content doesn't start with a newline character, this constructor will - * auto-prepend that. - */ - public BlipData(String waveId, String waveletId, String blipId, String initialContent) { - this.annotations = new ArrayList<Annotation>(); - this.elements = new HashMap<Integer, Element>(); - this.childBlipIds = new ArrayList<String>(); - this.contributors = new ArrayList<String>(); - this.waveId = waveId; - this.waveletId = waveletId; - this.blipId = blipId; - - // Make sure that initial content is valid, and starts with newline. - if (initialContent == null || initialContent.isEmpty()) { - initialContent = "\n"; - } else if (!initialContent.startsWith("\n")) { - initialContent = "\n" + initialContent; - } - - this.content = initialContent; - } - - /** - * Creates a deep copy/clone of a blip's data. - * - * @param blip The original blip to be copied. - */ - public BlipData(BlipData blip) { - // Deep copy annotations. - annotations = new ArrayList<Annotation>(); - for (Annotation annotation : blip.getAnnotations()) { - Range range = annotation.getRange(); - annotations.add(new Annotation(annotation.getName(), annotation.getValue(), - range.getStart(), range.getEnd())); - } - - // Deep copy form elements. - elements = new HashMap<Integer, Element>(); - for (Entry<Integer, Element> entry : blip.getElements().entrySet()) { - ElementType type = entry.getValue().getType(); - Element result = null; - if (FormElement.getFormElementTypes().contains(type)) { - result = new FormElement(type, entry.getValue().getProperties()); - } else if (type == ElementType.GADGET) { - result = new Gadget(entry.getValue().getProperties()); - } else if (type == ElementType.IMAGE) { - result = new Image(entry.getValue().getProperties()); - } else if (type == ElementType.LINE) { - result = new Line(entry.getValue().getProperties()); - } else { - result = new Element(type, entry.getValue().getProperties()); - } - elements.put(entry.getKey(), result); - } - - creator = blip.getCreator(); - childBlipIds = blip.getChildBlipIds(); - content = blip.getContent(); - contributors = blip.getContributors(); - blipId = blip.getBlipId(); - lastModifiedTime = blip.getLastModifiedTime(); - version = blip.getVersion(); - parentBlipId = blip.getParentBlipId(); - waveId = blip.getWaveId(); - waveletId = blip.getWaveletId(); - replyThreadIds = blip.getReplyThreadIds(); - threadId = blip.getThreadId(); - } - - /** - * Adds an annotation to the end of the list of annotations. - * - * @param annotation the annotation to be added. - */ - public void addAnnotation(Annotation annotation) { - annotations.add(annotation); - } - - /** - * Returns the list of annotations modifying this document's content. - * - * @return a list of annotations. - */ - public List<Annotation> getAnnotations() { - return annotations == null ? new ArrayList<Annotation>() : annotations; - } - - /** - * Adds an element to the blip at a given index into the text document. - * - * @param position The character position / index into the document to insert - * the form element. - * @param element The form element to be added. - */ - public void addElement(int position, Element element) { - elements.put(position, element); - } - - /** - * Returns a map of the elements in the blip and the positions where - * they have been inserted. - * - * @return the map of form elements to document positions. - */ - public Map<Integer, Element> getElements() { - return elements; - } - - /** - * Returns the Blip ID for this blip. - * - * @return the blip id for this blip. - */ - public String getBlipId() { - return blipId; - } - - /** - * Returns a list of child Blip IDs for this blip. - * - * @return a list of child Blip IDs. - */ - public List<String> getChildBlipIds() { - return childBlipIds; - } - - /** - * Returns the list of email addresses corresponding to the contributors who - * have modified this blip's content. - * - * @return the list of contributors. - */ - public List<String> getContributors() { - return contributors; - } - - /** - * Returns the email address corresponding to the creator of this blip. - * - * @return the creator of this blip. - */ - public String getCreator() { - return creator; - } - - /** - * Returns the text document content for this blip. - * - * @return the text document content for this blip. - */ - public String getContent() { - return content; - } - - /** - * Returns the time in milliseconds since the UNIX epoch when this blip was - * last modified. - * - * @return the last modified time for this blip. - */ - public long getLastModifiedTime() { - return lastModifiedTime; - } - - /** - * Returns the parent Blip ID for this blip. - * - * @return the parent Blip ID for this blip. - */ - public String getParentBlipId() { - return parentBlipId; - } - - /** - * Returns the version number for this blip. - * - * @return the version number for this blip. - */ - public long getVersion() { - return version; - } - - /** - * Returns the Wave ID for the wave containing this blip. - * - * @return the Wave ID for the wave containing this blip. - */ - public String getWaveId() { - return waveId; - } - - /** - * Returns the Wavelet ID for the wavelet containing this blip. - * - * @return the Wavelet ID for the wavelet containing this blip. - */ - public String getWaveletId() { - return waveletId; - } - - /** - * Replaces the blip's list of annotations with a new list of annotations. - * - * @param annotations the new list of annotations. - */ - public void setAnnotations(List<Annotation> annotations) { - this.annotations = annotations; - } - - /** - * Replaces the blip's list of elements with a new list of elements. - * - * @param map the new list of elements. - */ - public void setElements(Map<Integer, Element> map) { - this.elements = map; - } - - /** - * Returns the Blip ID for this blip. - * - * @param blipId the Blip ID for this blip. - */ - public void setBlipId(String blipId) { - this.blipId = blipId; - } - - /** - * Replaces the blip's list of child Blip IDs with a new list. - * - * @param childBlipIds the new list of child Blip IDs. - */ - public void setChildBlipIds(List<String> childBlipIds) { - this.childBlipIds = childBlipIds; - } - - /** - * Adds a new child blip id to this blip's list of child id's. - * - * @param blipId the Blip ID to be added. - */ - public void addChildBlipId(String blipId) { - this.childBlipIds.add(blipId); - } - - /** - * Replaces the blip's list of contributors with a new list. - * - * @param contributors the new list of contributors. - */ - public void setContributors(List<String> contributors) { - this.contributors = contributors; - } - - /** - * Adds a contributor to this blip's list of contributors. - * - * @param contributor a new contributor to the blip. - */ - public void addContributor(String contributor) { - this.contributors.add(contributor); - } - - /** - * Sets the creator of the blip. - * - * @param creator the creator of the blip. - */ - public void setCreator(String creator) { - this.creator = creator; - } - - /** - * Replaces the blip's text document content. - * - * @param content the new text content for the blip. - */ - public void setContent(String content) { - this.content = content; - } - - /** - * Sets the last modified time measured in milliseconds since the UNIX epoch - * when the blip was last modified. - * - * @param lastModifiedTime the last modified time of the blip. - */ - public void setLastModifiedTime(long lastModifiedTime) { - this.lastModifiedTime = lastModifiedTime; - } - - /** - * Set's the parent Blip ID for the blip. - * - * @param parentBlipId the parent blip id. - */ - public void setParentBlipId(String parentBlipId) { - this.parentBlipId = parentBlipId; - } - - /** - * Sets the version of the blip. - * - * @param version the version of the blip. - */ - public void setVersion(long version) { - this.version = version; - } - - /** - * Sets the Wave ID of the blip. - * - * @param waveId the Wave ID of the blip. - */ - public void setWaveId(String waveId) { - this.waveId = waveId; - } - - /** - * Sets the Wavelet ID of the blip. - * - * @param waveletId the Wavelet ID of the blip. - */ - public void setWaveletId(String waveletId) { - this.waveletId = waveletId; - } - - public void removeChildBlipId(String blipId) { - childBlipIds.remove(blipId); - } - - /** - * @return the inline and non-inline reply threads' ids. - */ - public List<String> getReplyThreadIds() { - return replyThreadIds; - } - - /** - * Sets the list of inline and non-inline reply threads' ids. - * - * @param replyThreadIds a list of ids of the reply threads. - */ - public void setReplyThreadIds(List<String> replyThreadIds) { - this.replyThreadIds = replyThreadIds; - } - - /** - * @return the id of the thread to which this blip belongs to. - */ - public String getThreadId() { - return threadId; - } - - /** - * Sets the id of the thread to which this blip belongs to. - - * @param threadId the id of the parent thread. - */ - public void setThreadId(String threadId) { - this.threadId = threadId; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/BlipIterator.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/BlipIterator.java b/src/com/google/wave/api/BlipIterator.java deleted file mode 100644 index f76d789..0000000 --- a/src/com/google/wave/api/BlipIterator.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Map.Entry; - -/** - * An iterator over blip content, that consists of text or element. - * - * Please note that this iterator does not support {@code remove} operation at - * the moment. - * - * @param <T> the generic type of the target entity to match. - */ -public abstract class BlipIterator<T> implements Iterator<Range> { - - /** The blip to be iterated. */ - protected final Blip blip; - - /** The target to be matched. */ - protected final T target; - - /** The maximum number of iterations allowed. */ - private final int maxHits; - - /** The range size of a match. */ - private final int rangeSize; - - /** The number of allowed iterations left. */ - private int hitsLeft; - - /** The current position of the iterator. */ - protected int position; - - /** - * Constructor. - * - * @param blip the blip to be iterated. - * @param target the target to be matched. - * @param maxHits the maximum number of iterations allowed. - * @param rangeSize the size of a matching range, for example, 1 for element - * iteration, or the length of the {@code target} for text/string - * iteration. - */ - protected BlipIterator(Blip blip, T target, int maxHits, int rangeSize) { - this.blip = blip; - this.target = target; - this.maxHits = maxHits; - this.rangeSize = rangeSize; - reset(); - } - - @Override - public boolean hasNext() { - return hitsLeft != 0 && getNextIndex() != -1; - } - - @Override - public Range next() { - if (hitsLeft == 0) { - throw new NoSuchElementException(); - } - - int index = getNextIndex(); - if (index == -1) { - throw new NoSuchElementException(); - } - - hitsLeft--; - position = index; - return new Range(position, position + rangeSize); - } - - /** - * {@code remove} is not supported. - * - * @throws UnsupportedOperationException this operation is not supported yet. - * it will throw {@link UnsupportedOperationException} on all invocations. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Shifts the iterator cursor. - * - * @param shiftAmount the shift amount. - */ - void shift(int shiftAmount) { - this.position += shiftAmount; - } - - /** - * Shifts the iterator cursor to beginning, to reset iteration. - */ - void reset() { - this.position = -1; - this.hitsLeft = maxHits; - } - - /** - * Returns the index of the next match. - * - * @return the index of the next match, or -1 if there is no more match. - */ - protected abstract int getNextIndex(); - - /** - * A blip iterator that allows a single iteration over a given range. - */ - static final class SingleshotIterator extends BlipIterator<Void> { - - /** The starting index of the range. */ - private final int start; - - /** - * Constructor. - * - * @param blip the blip to iterate. - * @param start the start index of the range to iterate. - * @param end the end index of the range to iterate. - */ - public SingleshotIterator(Blip blip, int start, int end) { - super(blip, null, 1, end - start); - int length = blip.getContent().length(); - this.start = start; - } - - @Override - protected int getNextIndex() { - return start; - } - } - - /** - * A blip iterator that allows iteration over text/string content. - */ - static final class TextIterator extends BlipIterator<String> { - - /** - * Constructor. - * - * @param blip the blip to be iterated. - * @param target the string to be matched. - * @param maxHits the maximum number of iterations allowed. - */ - public TextIterator(Blip blip, String target, int maxHits) { - super(blip, target, maxHits, target.length()); - } - - @Override - protected int getNextIndex() { - return blip.getContent().indexOf(target, position + 1); - } - } - - /** - * A blip iterator that allows iteration over element content, such as, - * gadget, form element, image, and so on. - */ - static final class ElementIterator extends BlipIterator<ElementType> { - - /** A map of restrictions that would be applied during iteration. */ - private final Map<String, String> restrictions; - - /** - * Constructor. - * - * @param blip the blip to be iterated. - * @param target the string to be matched. - * @param restrictions a map of restrictions. - * @param maxHits the maximum number of iterations allowed. - */ - public ElementIterator(Blip blip, ElementType target, Map<String, String> restrictions, - int maxHits) { - super(blip, target, maxHits, 1); - this.restrictions = restrictions; - } - - @Override - protected int getNextIndex() { - int index = -1; - for (Entry<Integer, Element> entry : blip.getElements().tailMap(position + 1).entrySet()) { - if (match(entry.getValue())) { - index = entry.getKey(); - break; - } - } - return index; - } - - /** - * Checks whether the given {@code element} is a match or not, by checking - * the type and the properties. - * - * @param element the element to check. - * @return {@code true} if the element type matches the target type, and - * the all filters/restrictions are satisfied. - */ - private boolean match(Element element) { - if (element.getType() != target) { - return false; - } - - if (restrictions == null) { - return true; - } - - for (Entry<String, String> entry : restrictions.entrySet()) { - if (!entry.getValue().equals(element.getProperty(entry.getKey()))) { - return false; - } - } - return true; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/BlipThread.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/BlipThread.java b/src/com/google/wave/api/BlipThread.java deleted file mode 100644 index f8053f9..0000000 --- a/src/com/google/wave/api/BlipThread.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * A thread represents a group of blips in a wave. - */ -public class BlipThread implements Serializable { - - /** The id of the thread. */ - private final String id; - - /** The offset of the parent blip where this thread is inlined. */ - private int location; - - /** A list of ids of all blips that are in this thread. */ - private final List<String> blipIds; - - /** A map of blips of the wavelet to which this thread belongs to. */ - @NonJsonSerializable private final Map<String, Blip> blips; - - /** - * Constructor. - * - * @param id the id of the thread. - * @param location the location or offset of this thread in the containing - * blip. This should be {@code -1} if this is not an inline thread. - * @param blipIds the ids of the blips that are in this thread. - * @param blips a map of blips of the wavelet to which this thread belongs to. - */ - public BlipThread(String id, int location, List<String> blipIds, Map<String, Blip> blips) { - this.id = id; - this.location = location; - this.blipIds = blipIds; - this.blips = blips; - } - - /** - * @return the id of the thread. - */ - public String getId() { - return id; - } - - /** - * @return the location or offset of this thread in the containing or parent - * blip. This method will return {@code -1} if this {@link BlipThread} is not - * an inline thread. - */ - public int getLocation() { - return location; - } - - /** - * Sets the location of the thread. - * - * @param location the new location. - */ - public void setLocation(int location) { - this.location = location; - } - - /** - * @return a list of all blip ids that are in this thread. - */ - public List<String> getBlipIds() { - return blipIds; - } - - /** - * @return all available blips that are in this thread. - */ - public List<Blip> getBlips() { - List<Blip> result = new ArrayList<Blip>(blipIds.size()); - for (String blipId : blipIds) { - Blip blip = blips.get(blipId); - if (blip != null) { - result.add(blips.get(blipId)); - } - } - return result; - } - - /** - * Appends a blip to the end of this thread. - * - * @param blip the blip to append. - */ - void appendBlip(Blip blip) { - blipIds.add(blip.getBlipId()); - } - - /** - * Removes a blip from this thread. - * - * @param blip the blip to remove. - * @return {@code true} if this thread contained the given id, and removal was - * successful. - */ - boolean removeBlip(Blip blip) { - return blipIds.remove(blip.getBlipId()); - } - - /** - * @return {@code true} if this thread has no blips. - */ - boolean isEmpty() { - return blipIds.isEmpty(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Context.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Context.java b/src/com/google/wave/api/Context.java deleted file mode 100644 index 7d05928..0000000 --- a/src/com/google/wave/api/Context.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -/** - * Enumeration that represents the context that the robot needs to provide when - * calling the Robot's event handler. This is specified in the Robot's - * capabilities.xml. - */ -public enum Context { - /** The first blip in the root thread. */ - ROOT, - /** The preceeding blip in the thread, or parent blip for a new thread. */ - PARENT, - /** The blips in the same thread. */ - SIBLINGS, - /** The next blip in the thread and the first blip in each reply. */ - CHILDREN, - /** Just one blip. */ - SELF, - /** All blips .*/ - ALL; - - public static Context valueOfIgnoreCase(String name) { - return valueOf(name.toUpperCase()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/DataDocuments.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/DataDocuments.java b/src/com/google/wave/api/DataDocuments.java deleted file mode 100644 index e6ee6f6..0000000 --- a/src/com/google/wave/api/DataDocuments.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -/** - * A class that represents wavelet's data documents. This class supports various - * data document related operations, such as, getting, setting, or removing - * data document value from a wavelet. - */ -public class DataDocuments implements Iterable<Entry<String,String>>, Serializable { - - /** A map of data documents values. */ - private final Map<String, String> dataDocuments; - - /** The wavelet that this data document represents. */ - private final Wavelet wavelet; - - /** The operation queue to queue operation to the robot proxy. */ - private final OperationQueue operationQueue; - - /** - * Constructor. - * - * @param dataDocuments a map of initial data documents. - * @param wavelet the wavelet that this data documents represents. - * @param operationQueue the operation queue to queue operation to the robot - * proxy. - */ - public DataDocuments(Map<String, String> dataDocuments, Wavelet wavelet, - OperationQueue operationQueue) { - this.dataDocuments = new HashMap<String, String>(dataDocuments); - this.wavelet = wavelet; - this.operationQueue = operationQueue; - } - - /** - * Associates the given name/key with the given value in the data documents. - * - * @param name the key with which the specified value is to be associated. - * @param value the value to be associated with the given name/key. - * @return the previous value for the given name/key. - */ - public String set(String name, String value) { - if (value == null) { - throw new IllegalArgumentException("Value should not be null."); - } - operationQueue.setDatadocOfWavelet(wavelet, name, value); - return dataDocuments.put(name, value); - } - - /** - * Removes the value of the given key from the data documents. - * - * @param name the key whose value will be removed. - * @return the previous value for the given name/key. - */ - public String remove(String name) { - operationQueue.setDatadocOfWavelet(wavelet, name, null); - return dataDocuments.remove(name); - } - - /** - * Checks whether the given key exists in the data documents. - * - * @param name the key to check. - * @return {@code true} if the set contains the given name/key. - * Otherwise, returns {@code false}. - */ - public boolean contains(String name) { - return dataDocuments.containsKey(name); - } - - /** - * Returns the number of values in the data documents. - * - * @return the size of the data documents. - */ - public int size() { - return dataDocuments.size(); - } - - /** - * Checks whether this data documents is empty or not. - * - * @return {@code true} if the data documents is empty. Otherwise, returns - * {@code false}. - */ - public boolean isEmpty() { - return dataDocuments.isEmpty(); - } - - /** - * Returns the data document by its name. - * @param name the name of the data document. - * - * @return The data document, or {@code null} if it does not exist. - */ - public String get(String name) { - return dataDocuments.get(name); - } - - @Override - public Iterator<Entry<String, String>> iterator() { - return dataDocuments.entrySet().iterator(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Element.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Element.java b/src/com/google/wave/api/Element.java deleted file mode 100644 index 23817b3..0000000 --- a/src/com/google/wave/api/Element.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * Elements are non-text content within a document. What the represent is - * generally abstracted from the Robot. Although a Robot can query the - * properties of an element it can only interact with the specific types that - * the element represents. - */ -public class Element extends BlipContent implements Serializable { - - /** The type of an element. */ - private final ElementType type; - - /** A map of properties representing details of the element. */ - private final Map<String, String> properties; - - /** - * Creates an element of the given type. - * - * @param type the type of element to construct. - */ - public Element(ElementType type) { - this.type = type; - this.properties = new HashMap<String, String>(); - } - - /** - * Constructs an Element of the given type with an initial set of properties. - * - * @param type the type of element to construct. - * @param properties the properties of the element. - */ - public Element(ElementType type, Map<String, String> properties) { - this.type = type; - this.properties = properties; - } - - /** - * Returns the type of the element. - * - * @return the type of the element. - */ - public ElementType getType() { - return type; - } - - /** - * Returns the map of properties for this element. - * - * @return the map of properties for this element. - */ - public Map<String, String> getProperties() { - return properties; - } - - /** - * Creates/replaces a property with the given to a new value. - * - * @param name the name of the property to create/replace. - * @param value the value to be set on this property. - */ - public void setProperty(String name, String value) { - this.properties.put(name, value); - } - - /** - * Returns the named property of this element. - * - * @param name the name of the property. - * @return the value of the property or null if the property was not found. - */ - public String getProperty(String name) { - return getProperty(name, null); - } - - /** - * Returns the named property of this element, or the default value if the - * property was not found. - * - * @param name the name of the property. - * @param defaultValue the default value of the property. - * @return the value of the property or the default value if the property was - * not found. - */ - public String getProperty(String name, String defaultValue) { - Object property = this.properties.get(name); - if (property != null) { - // We can't safely assume that the property is of type String, so we need - // to call toString(). - return property.toString(); - } - return defaultValue; - } - - /** - * Returns whether this element is a form element. - * - * @return true if the element is a form element, false otherwise. - */ - public boolean isFormElement() { - return FormElement.getFormElementTypes().contains(type); - } - - /** - * Returns whether this element is a gadget. - * - * @return true if the element is a gadget, false otherwise. - */ - public boolean isGadget() { - return type == ElementType.GADGET; - } - - /** - * Returns whether this element is an inline blip. - * - * @return true if the element is an inline blip, false otherwise. - */ - public boolean isInlineBlip() { - return type == ElementType.INLINE_BLIP; - } - - /** - * Returns whether this element is an image. - * - * @return true if the element is an image, false otherwise. - */ - public boolean isImage() { - return type == ElementType.IMAGE; - } - - /** - * Returns whether this element is an attachment. - * - * @return true if the element is an attachment, false otherwise. - */ - public boolean isAttachment() { - return type == ElementType.ATTACHMENT; - } - - @Override - public String toString() { - return "{'type':'" + type + "','properties':" + properties + "}"; - } - - @Override - public String getText() { - return type == ElementType.LINE ? "\n" : " "; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/ElementType.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/ElementType.java b/src/com/google/wave/api/ElementType.java deleted file mode 100644 index d613589..0000000 --- a/src/com/google/wave/api/ElementType.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -/** - * Element Types. - * - * @author [email protected] (Seth Covitz) - * @author [email protected] (Marcel Prasetya) - */ -public enum ElementType { - // Form Elements - INPUT("INPUT"), - PASSWORD("PASSWORD"), - CHECK("CHECK"), - LABEL("LABEL"), - BUTTON("BUTTON"), - RADIO_BUTTON("RADIO_BUTTON"), - RADIO_BUTTON_GROUP("RADIO_BUTTON_GROUP"), - TEXTAREA("TEXTAREA"), - // Other - INLINE_BLIP("INLINE_BLIP"), - GADGET("GADGET"), - INSTALLER("INSTALLER"), - IMAGE("IMAGE"), - LINE("LINE"), - ATTACHMENT("ATTACHMENT"); - - private final String text; - - private ElementType(String text) { - this.text = text; - } - - @Override - public String toString() { - return text; - } - - /** - * Converts a string into an ElementType. This is used primarily during - * deserialization from JSON. - * - * @param name the name of the ElementType. - * @return the ElementType representing that name. - */ - public static ElementType valueOfIgnoreCase(String name) { - return valueOf(name.toUpperCase()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/FetchProfilesRequest.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/FetchProfilesRequest.java b/src/com/google/wave/api/FetchProfilesRequest.java deleted file mode 100644 index a5ac531..0000000 --- a/src/com/google/wave/api/FetchProfilesRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.List; - -/** - * FetchProfilesRequest contain the request for one or more profiles. - */ -public class FetchProfilesRequest { - - private final List<String> participantIds; - private final String language; - - /** - * No-args constructor to keep gson happy. - */ - public FetchProfilesRequest() { - this(null, null); - } - - public FetchProfilesRequest(List<String> participantIds) { - this(participantIds, null); - } - - public FetchProfilesRequest(List<String> participantIds, String language) { - this.participantIds = participantIds; - this.language = language; - } - - /** - * @return the requested language of the profile. - */ - public String getLanguage() { - return language; - } - - /** - * @return the participant ids of the requested profile. - */ - public List<String> getParticipantIds() { - return participantIds; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/FetchProfilesResult.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/FetchProfilesResult.java b/src/com/google/wave/api/FetchProfilesResult.java deleted file mode 100644 index 8444594..0000000 --- a/src/com/google/wave/api/FetchProfilesResult.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.List; - -/** - * FetchProfilesResult contains the results of a fetch profile request. - */ -public class FetchProfilesResult { - - /** The requested profile. */ - private final List<ParticipantProfile> profiles; - - /** - * Constructor. - * - * @param profiles the requested profile. - */ - public FetchProfilesResult(List<ParticipantProfile> profiles) { - this.profiles = profiles; - } - - /** - * @return the requested profiles. - */ - public List<ParticipantProfile> getProfiles() { - return profiles; - } - - /** - * No-args constructor to keep GSON happy. - */ - FetchProfilesResult() { - this.profiles = null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/FormElement.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/FormElement.java b/src/com/google/wave/api/FormElement.java deleted file mode 100644 index c0830bd..0000000 --- a/src/com/google/wave/api/FormElement.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Form Elements allow users and robots to build forms for other users to - * interact with. For each element you can specify its type, name, a default - * value and a label. The current value of the element is stored with in. - */ -public class FormElement extends Element { - - public static final String DEFAULT_VALUE = "defaultValue"; - public static final String NAME = "name"; - public static final String VALUE = "value"; - - private static final List<ElementType> FORM_ELEMENT_TYPES = new ArrayList<ElementType>(8); - static { - Collections.addAll(FORM_ELEMENT_TYPES, ElementType.BUTTON, ElementType.CHECK, - ElementType.INPUT, ElementType.PASSWORD, ElementType.LABEL, ElementType.RADIO_BUTTON, - ElementType.RADIO_BUTTON_GROUP, ElementType.TEXTAREA); - } - - /** - * Constructs a form element of the given type. - */ - public FormElement(ElementType type) { - this(type, "", "", ""); - } - - /** - * Constructs a form element given a type and name. - */ - public FormElement(ElementType type, String name) { - this(type, name, "", ""); - } - - /** - * Constructs a form element given a type, name and default value. - */ - public FormElement(ElementType type, String name, String defaultValue) { - this(type, name, defaultValue, defaultValue); - } - - /** - * Creates a copy of an existing form element. - */ - public FormElement(FormElement formElement) { - this(formElement.getType(), - formElement.getName(), - formElement.getDefaultValue(), - formElement.getValue()); - } - - /** - * Constructs a form element specifying all fields. - */ - public FormElement(ElementType type, String name, String defaultValue, String value) { - super(type); - setProperty(NAME, name); - setProperty(DEFAULT_VALUE, defaultValue); - setProperty(VALUE, value); - } - - /** - * Constructs a form element with a given set of properties. - * - * @param type the type of the form element. - * @param properties the properties of the form element. - */ - public FormElement(ElementType type, Map<String, String> properties) { - super(type, properties); - } - - /** - * Returns the name of the form element. - * - * @return the name of the form element. - */ - public String getName() { - return getPropertyNullCheck(NAME); - } - - private String getPropertyNullCheck(String name) { - String property = getProperty(name); - return property == null ? "" : property; - } - - /** - * Sets the name of the form element. - * - * @param name the new name of the form element. - */ - public void setName(String name) { - setProperty(NAME, name); - } - - /** - * Returns the default value of the form element. - * - * @return the default value. - */ - public String getDefaultValue() { - return getPropertyNullCheck(DEFAULT_VALUE); - } - - /** - * Sets the default value of the form element. The default value is used - * to initialize the form element and to test whether or not it has been - * modified. - * - * @param defaultValue the new default value of the form element. - */ - public void setDefaultValue(String defaultValue) { - setProperty(DEFAULT_VALUE, defaultValue); - } - - /** - * Returns the current value of the form element. - * - * @return the current value of the form element. - */ - public String getValue() { - return getPropertyNullCheck(VALUE); - } - - /** - * Sets the value of the form element. - * - * @param value the new value of the form element. - */ - public void setValue(String value) { - setProperty(VALUE, value); - } - - /** - * Returns a collection of form element types. - * - * @return a collection of form element types. - */ - public static Collection<ElementType> getFormElementTypes() { - return Collections.unmodifiableCollection(FORM_ELEMENT_TYPES); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given default value. - * - * @param defaultValue the default value to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByDefaultValue(String defaultValue) { - return Restriction.of(DEFAULT_VALUE, defaultValue); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given value. - * - * @param value the value to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByValue(String value) { - return Restriction.of(VALUE, value); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given name. - * - * @param name the name to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByName(String name) { - return Restriction.of(NAME, name); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Function.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Function.java b/src/com/google/wave/api/Function.java deleted file mode 100644 index 64e67ae..0000000 --- a/src/com/google/wave/api/Function.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.Map; - -/** - * A function that computes a result object of type {@code V} from an input of - * type {@code K}. - * - * @param <K> the type of the function input. - * @param <V> the type of the function output. - */ -public interface Function<K, V> { - - /** - * Computes {@code V} from the given {@code K}. - * - * @param source the source object. - * @return an instance of {@code V}, based on {@code source}. - */ - V call(K source); - - /** - * A {@link Function} that computes a {@link BlipContent} from another - * {@link BlipContent}. - * - * Note: The sole purpose of this interface is to eliminate compiler warning - * about generic array of {@link Function} creation, since the {@code insert}, - * {@code insertAfter}, {@code replace}, and {@code updateElements} method - * inside {@link BlipContentRefs} take a varargs of functions. - */ - static interface BlipContentFunction extends Function<BlipContent, BlipContent> { } - - /** - * A {@link Function} that computes a {@link Map} from a {@link BlipContent}. - * - * Note: The sole purpose of this interface is to eliminate compiler warning - * about generic array of {@link Function} creation, since the {@code insert}, - * {@code insertAfter}, {@code replace}, and {@code updateElements} method - * inside {@link BlipContentRefs} take a varargs of functions. - */ - static interface MapFunction extends Function<BlipContent, Map<String, String>> { } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Gadget.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Gadget.java b/src/com/google/wave/api/Gadget.java deleted file mode 100644 index a60f67c..0000000 --- a/src/com/google/wave/api/Gadget.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.Map; - -/** - * Gadgets are external code that can be executed within a protected - * environment within a Wave. Gadgets are indentified by the url that points to - * their gadget specification. Gadgets can also maintain state that both they - * and Robots can modify. - */ -public class Gadget extends Element { - - public static final String AUTHOR = "author"; - public static final String CATEGORY = "category"; - public static final String IFRAME = "ifr"; - public static final String PREF = "pref"; - public static final String THUMBNAIL = "thumbnail"; - public static final String TITLE = "title"; - public static final String URL = "url"; - - /** - * Constructs an empty gadget. - */ - public Gadget() { - super(ElementType.GADGET); - setUrl(""); - } - - /** - * Constructs a gadget with a given set of properties. - * - * @param properties the properties of the gadget. - */ - public Gadget(Map<String, String> properties) { - super(ElementType.GADGET, properties); - } - - /** - * Constructs a gadget for the specified url. - * - * @param url the url of the gadget specification. - */ - public Gadget(String url) { - super(ElementType.GADGET); - setUrl(url); - } - - /** - * Returns the author of the gadget. - * - * @return the author of the gadget. - */ - public String getAuthor() { - return getProperty(AUTHOR); - } - - /** - * Changes the author of the gadget to the given author. - * - * @param author the new gadget author. - */ - public void setAuthor(String author) { - setProperty(AUTHOR, author); - } - - /** - * Returns the category of the gadget. - * - * @return the category of the gadget. - */ - public String getCategory() { - return getProperty(CATEGORY); - } - - /** - * Changes the cached IFrame source of the gadget. - * - * @param iframe the new cached gadget iframe source. - */ - public void setIframe(String iframe) { - setProperty(IFRAME, iframe); - } - - /** - * Returns the cached iframe source of the gadget. - * - * @return the cached iframe source of the gadget. - */ - public String getIframe() { - return getProperty(IFRAME); - } - - /** - * Changes the category of the gadget to the given category. - * - * @param category the new gadget category. - */ - public void setCategory(String category) { - setProperty(CATEGORY, category); - } - - /** - * Returns the pref of the gadget. - * - * @return the pref of the gadget. - */ - public String getPref() { - return getProperty(PREF); - } - - /** - * Changes the pref of the gadget to the given pref. - * - * @param pref the new gadget pref. - */ - public void setPref(String pref) { - setProperty(PREF, pref); - } - - /** - * Returns the thumbnail of the gadget. - * - * @return the thumbnail of the gadget. - */ - public String getThumbnail() { - return getProperty(THUMBNAIL); - } - - /** - * Changes the thumbnail of the gadget to the given thumbnail. - * - * @param thumbnail the new gadget thumbnail. - */ - public void setThumbnail(String thumbnail) { - setProperty(THUMBNAIL, thumbnail); - } - - /** - * Returns the title of the gadget. - * - * @return the title of the gadget. - */ - public String getTitle() { - return getProperty(TITLE); - } - - /** - * Changes the title of the gadget to the given title. - * - * @param title the new gadget title. - */ - public void setTitle(String title) { - setProperty(TITLE, title); - } - - /** - * Returns the URL for the gadget. - * - * @return the URL for the gadget. - */ - public String getUrl() { - return getProperty(URL); - } - - /** - * Changes the URL for the gadget to the given url. This will cause the new - * gadget to be initialized and loaded. - * - * @param url the new gadget url. - */ - public void setUrl(String url) { - setProperty(URL, url); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given author. - * - * @param author the author to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByAuthor(String author) { - return Restriction.of(AUTHOR, author); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given category. - * - * @param category the category to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByCategory(String category) { - return Restriction.of(CATEGORY, category); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given cached iframe source. - * - * @param iframe the iframe source to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByIframe(String iframe) { - return Restriction.of(IFRAME, iframe); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given pref. - * - * @param pref the pref to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByPref(String pref) { - return Restriction.of(PREF, pref); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given thumbnail. - * - * @param thumbnail the thumbnail to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByThumbnail(String thumbnail) { - return Restriction.of(THUMBNAIL, thumbnail); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given title. - * - * @param title the title to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByTitle(String title) { - return Restriction.of(TITLE, title); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given URL. - * - * @param url the URL to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByUrl(String url) { - return Restriction.of(URL, url); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * gadget with the given property. - * - * @param key the property key. - * @param value the property value. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByProperty(String key, String value) { - return Restriction.of(key, value); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Image.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Image.java b/src/com/google/wave/api/Image.java deleted file mode 100644 index dd876cf..0000000 --- a/src/com/google/wave/api/Image.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.Map; - -/** - * Represents an image within a Wave. The image can either refer to an external - * resource or a Wave attachment. An external image is defined by the 'url' - * property, while the Wave attachment is defined by the 'attachmentId' - * property. - */ -public class Image extends Element { - - public static final String ATTACHMENT_ID = "attachmentId"; - public static final String CAPTION = "caption"; - public static final String HEIGHT = "height"; - public static final String URL = "url"; - public static final String WIDTH = "width"; - - /** - * Constructs an empty image. - */ - public Image() { - super(ElementType.IMAGE); - } - - /** - * Constructs an image with a given set of properties. - * - * @param properties the properties of the image. - */ - public Image(Map<String, String> properties) { - super(ElementType.IMAGE, properties); - } - - /** - * Constructs a Wave image given an attachment id and a caption. - * - * @param attachmentId the attachment id of the wave image. - * @param caption the caption for the image. - */ - public Image(String attachmentId, String caption) { - this(); - setAttachmentId(attachmentId); - setCaption(caption); - } - - /** - * Constructs an external image given a url, image dimensions, and a caption. - * - * @param url the url for the external image. - * @param width the width of the image. - * @param height the height of the image. - * @param caption the caption for the image. - */ - public Image(String url, int width, int height, String caption) { - this(); - setUrl(url); - setWidth(width); - setHeight(height); - setCaption(caption); - } - - /** - * Returns the URL for the image. - * - * @return the URL for the image. - */ - public String getUrl() { - return getProperty(URL); - } - - /** - * Changes the URL for the image to the given url. This will cause the new - * image to be initialized and loaded. - * - * @param url the new image url. - */ - public void setUrl(String url) { - setProperty(URL, url); - } - - /** - * Sets the fixed width of the image to be displayed. - * - * @param width the fixed width of the image. - */ - public void setWidth(int width) { - setProperty(WIDTH, Integer.toString(width)); - } - - /** - * Returns the fixed width of the image. - * - * @return the fixed width of the image or -1 if no width was specified. - * - * @throws IllegalStateException if no width was specified. - */ - public int getWidth() { - String width = getProperty(WIDTH); - if (width == null) { - throw new IllegalStateException("This image's width has not been set."); - } - return Integer.parseInt(width); - } - - /** - * Sets the fixed height of the image to be displayed. - * - * @param height the fixed height of the image. - */ - public void setHeight(int height) { - setProperty(HEIGHT, Integer.toString(height)); - } - - /** - * Returns the fixed height of the image. - * - * @return the fixed height of the image. - * - * @throws IllegalStateException if no height was specified. - */ - public int getHeight() { - String height = getProperty(HEIGHT); - if (height == null) { - throw new IllegalStateException("This image's height has not been set."); - } - return Integer.parseInt(height); - } - - /** - * Sets the attacmentId for the Wave image. - * - * @param attachmentId the attachment id for the image. - */ - public void setAttachmentId(String attachmentId) { - setProperty(ATTACHMENT_ID, attachmentId); - } - - /** - * Returns the attachmentId for the image. - * - * @return the attachmentId for the image. - */ - public String getAttachmentId() { - return getProperty(ATTACHMENT_ID); - } - - /** - * Sets the caption for the image. - * - * @param caption the caption to display for the image. - */ - public void setCaption(String caption) { - setProperty(CAPTION, caption); - } - - /** - * Returns the caption for the image. - * - * @return the caption for the image. - */ - public String getCaption() { - return getProperty(CAPTION); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * image with the given attachment id. - * - * @param attachmentId the attachment id to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByAttachmentId(String attachmentId) { - return Restriction.of(ATTACHMENT_ID, attachmentId); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * image with the given caption. - * - * @param caption the caption to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByCaption(String caption) { - return Restriction.of(CAPTION, caption); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * image with the given URL. - * - * @param url the URL to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByUrl(String url) { - return Restriction.of(URL, url); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * image with the given width. - * - * @param width the width to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByWidth(int width) { - return Restriction.of(WIDTH, Integer.toString(width)); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * image with the given height. - * - * @param height the height to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByHeight(int height) { - return Restriction.of(HEIGHT, Integer.toString(height)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Installer.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Installer.java b/src/com/google/wave/api/Installer.java deleted file mode 100644 index ba2aea8..0000000 --- a/src/com/google/wave/api/Installer.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -/** - * Installers are widgets that let Wave users install extensions on - * their account. Installers are identified by the URL that points to - * their manifest specification. - * - * @author [email protected] (Pamela Fox) - */ -public class Installer extends Element { - - /** - * Constructs an empty installer. - */ - public Installer() { - super(ElementType.INSTALLER); - setManifest(""); - } - - /** - * Constructs an installer for the specified manifest url. - * - * @param url the url of the manifest XML. - */ - public Installer(String manifest) { - super(ElementType.INSTALLER); - setManifest(manifest); - } - - /** - * Returns the URL of the manifest XML. - * - * @return the URL for the manifest XML. - */ - public String getManifest() { - return getProperty("manifest"); - } - - /** - * Changes the URL for the manifest to the given url. - * This will cause the installer puzzle piece to be re-loaded. - * - * @param manifest the new manifest url. - */ - public void setManifest(String manifest) { - setProperty("manifest", manifest); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/InvalidRequestException.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/InvalidRequestException.java b/src/com/google/wave/api/InvalidRequestException.java deleted file mode 100644 index f9f81fe..0000000 --- a/src/com/google/wave/api/InvalidRequestException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - - -/** - * Checked exception for signaling invalid input supplied by a robot for an - * operation request. - * - * @author [email protected] (David Byttow) - */ -public class InvalidRequestException extends Exception { - - private final OperationRequest invalidOperation; - - /** - * Constructor with a detail message. - * - * @param message detail message for this exception. - */ - public InvalidRequestException(String message, OperationRequest operation) { - super(message); - this.invalidOperation = operation; - } - - public InvalidRequestException(String message, OperationRequest operation, Exception e) { - super(message, e); - this.invalidOperation = operation; - } - - public InvalidRequestException(String message) { - super(message); - this.invalidOperation = null; - } - - public OperationRequest getInvalidOperation() { - return invalidOperation; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/JsonRpcConstant.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/JsonRpcConstant.java b/src/com/google/wave/api/JsonRpcConstant.java deleted file mode 100644 index 376982f..0000000 --- a/src/com/google/wave/api/JsonRpcConstant.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import com.google.wave.api.impl.RawAttachmentData; -import com.google.wave.api.impl.DocumentModifyAction; -import com.google.wave.api.impl.DocumentModifyQuery; -import com.google.wave.api.impl.WaveletData; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -/** - * Enumeration for Google Wave JSON-RPC request properties. - * - * @author [email protected] (Marcel Prasetya) - */ -public class JsonRpcConstant { - - /** - * Enumeration for JSON-RPC request properties. - * - * @author [email protected] (Marcel Prasetya) - */ - public enum RequestProperty { - METHOD("method"), - ID("id"), - PARAMS("params"); - - private final String key; - - private RequestProperty(String key) { - this.key = key; - } - - /** - * Returns the string key to access the property. - * - * @return A string key to access the property. - */ - public String key() { - return key; - } - } - - /** - * Enumeration for JSON-RPC response properties. - * - * @author [email protected] (Marcel Prasetya) - */ - public enum ResponseProperty { - ID("id"), - DATA("data"), - ERROR("error"); - - private final String key; - - private ResponseProperty(String key) { - this.key = key; - } - - /** - * Returns the string key to access the property. - * - * @return A string key to access the property. - */ - public String key() { - return key; - } - } - - /** - * Enumeration for Google Wave specific JSON-RPC request parameters. - * - * @author [email protected] (Marcel Prasetya) - */ - public enum ParamsProperty { - // TODO(mprasetya): Consider combining this with OperationType, or at least - // each OperationType should have a list of ParamsProperty. - - // Commonly used parameters. - WAVE_ID("waveId", String.class), - WAVELET_ID("waveletId", String.class), - BLIP_ID("blipId", String.class), - ATTACHMENT_ID("attachmentId", String.class), - - // Operation specific parameters. - ANNOTATION("annotation", Annotation.class), - BLIP_AUTHOR("blipAuthor", String.class), - BLIP_CREATION_TIME("blipCreationTime", Long.class), - BLIP_DATA("blipData", BlipData.class), - BLIPS("blips", Map.class), - CAPABILITIES_HASH("capabilitiesHash", String.class), - CHILD_BLIP_ID("childBlipId", String.class), - CONTENT("content", String.class), - DATADOC_NAME("datadocName", String.class), - DATADOC_VALUE("datadocValue", String.class), - DATADOC_WRITEBACK("datadocWriteback", String.class), - ELEMENT("element", Element.class), - FETCH_PROFILES_REQUEST("fetchProfilesRequest", FetchProfilesRequest.class), - FETCH_PROFILES_RESULT("fetchProfilesResult", FetchProfilesResult.class), - INDEX("index", Integer.class), - LANGUAGE("language", String.class), - MESSAGE("message", String.class), - MODIFY_ACTION("modifyAction", DocumentModifyAction.class), - MODIFY_HOW("modifyHow", String.class), - MODIFY_QUERY("modifyQuery", DocumentModifyQuery.class), - NAME("name", String.class), - NEW_BLIP_ID("newBlipId", String.class), - NUM_RESULTS("numResults", Integer.class), - PARTICIPANT_ID("participantId", String.class), - PARTICIPANT_PROFILE("participantProfile", ParticipantProfile.class), - PARTICIPANT_ROLE("participantRole", String.class), - PARTICIPANTS_ADDED("participantsAdded", List.class), - PARTICIPANTS_REMOVED("participantsRemoved", List.class), - PROTOCOL_VERSION("protocolVersion", String.class), - PROXYING_FOR("proxyingFor", String.class), - QUERY("query", String.class), - RANGE("range", Range.class), - SEARCH_RESULTS("searchResults", SearchResult.class), - STYLE_TYPE("styleType", String.class), - THREADS("threads", Map.class), - WAVELET_DATA("waveletData", WaveletData.class), - WAVELET_TITLE("waveletTitle", String.class), - RETURN_WAVELET_IDS("returnWaveletIds", Boolean.class), - WAVELET_IDS("waveletIds", List.class), - RAW_SNAPSHOT("rawSnapshot", String.class), - FROM_VERSION("fromVersion", byte[].class), - TO_VERSION("toVersion", byte[].class), - RAW_DELTAS("rawDeltas", List.class), - TARGET_VERSION("targetVersion", byte[].class), - ATTACHMENT_DATA("attachmentData", RawAttachmentData.class), - IMPORTED_FROM_VERSION("importedFromVersion", Long.class); - - private static final Logger LOG = Logger.getLogger(ParamsProperty.class.getName()); - - private static final Map<String, ParamsProperty> reverseLookupMap = - new HashMap<String, ParamsProperty>(); - - static { - for (ParamsProperty property : ParamsProperty.values()) { - if (reverseLookupMap.containsKey(property.key)) { - LOG.warning("Parameter with key " + property.key + " already exist."); - } - reverseLookupMap.put(property.key, property); - } - } - - private final String key; - private final Class<? extends Object> clazz; - - private ParamsProperty(String key, Class<? extends Object> clazz) { - this.key = key; - this.clazz = clazz; - } - - /** - * Returns the string key to access the property. - * - * @return A string key to access the property. - */ - public String key() { - return key; - } - - /** - * Returns the {@link Class} object that represents the type of this - * property. - * - * @return A {@link Class} object that represents the type of this property. - */ - public Class<? extends Object> clazz() { - return clazz; - } - - /** - * Returns a {@link ParamsProperty} enumeration that has the given key. - * - * @param key The method name of a property. - * @return An {@link ParamsProperty} that has the given key. - */ - public static ParamsProperty fromKey(String key) { - return reverseLookupMap.get(key); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/JsonRpcResponse.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/JsonRpcResponse.java b/src/com/google/wave/api/JsonRpcResponse.java deleted file mode 100644 index d675392..0000000 --- a/src/com/google/wave/api/JsonRpcResponse.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import com.google.wave.api.JsonRpcConstant.ParamsProperty; - -import java.util.Map; - -/** - * Encapsulates the response of a JSON-RPC call. - * - * @author [email protected] (Douwe Osinga) - */ -public class JsonRpcResponse { - - private final String id; - private final Map<ParamsProperty, Object> data; - private final String errorMessage; - - /** - * Construct a JSON-RPC error response. - * - * @param id the id of the operation request. - * @param errorMessage the error message. - * @return an instance of {@link JsonRpcResponse} that represents an error. - */ - public static JsonRpcResponse error(String id, String errorMessage) { - return new JsonRpcResponse(id, null, errorMessage); - } - - /** - * Construct a JSON-RPC response. - * - * @param id the id of the operation request. - * @param data a key value pairs of data that was returned as a result of - * operation. - * @return an instance of {@link JsonRpcResponse} that represents a success - * case. - */ - public static JsonRpcResponse result(String id, Map<ParamsProperty, Object> data) { - return new JsonRpcResponse(id, data, null); - } - - private JsonRpcResponse(String id, Map<ParamsProperty, Object> result, String errorMessage) { - this.id = id; - this.data = result; - this.errorMessage = errorMessage; - } - - public Map<ParamsProperty, Object> getData() { - return data; - } - - public String getErrorMessage() { - return errorMessage; - } - - public String getId() { - return id; - } - - public boolean isError() { - return data == null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/com/google/wave/api/Line.java ---------------------------------------------------------------------- diff --git a/src/com/google/wave/api/Line.java b/src/com/google/wave/api/Line.java deleted file mode 100644 index 2d11909..0000000 --- a/src/com/google/wave/api/Line.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package com.google.wave.api; - -import java.util.Map; - -/** - * Represents a line within a Wave. - */ -public class Line extends Element { - - public static final String ALIGNMENT = "alignment"; - public static final String DIRECTION = "direction"; - public static final String INDENT = "indent"; - public static final String LINE_TYPE = "lineType"; - - /** - * Constructs an unstyled line. - */ - public Line() { - super(ElementType.LINE); - } - - /** - * Constructs a line with a given set of properties. - * - * @param properties the properties of the line. - */ - public Line(Map<String, String> properties) { - super(ElementType.LINE, properties); - } - - /** - * The type of the line. Allowed values are 'h1', 'h2', 'h3', 'h4', - * 'h5', and 'li', where h[1-5] is a heading and 'li' an item in a list. - * - * @return the type of the line. - */ - public String getLineType() { - return getProperty(LINE_TYPE); - } - - /** - * Set the type of the line. - */ - public void setLineType(String lineType) { - setProperty(LINE_TYPE, lineType); - } - - /** - * The indentation level (0,1,2,...). This attribute is only meaningful when - * applied to lines of type t="li". - * @return the indent - */ - public String getIndent() { - return getProperty(INDENT); - } - - /** - * Set the indent for the line. - */ - public void setIndent(String value) { - setProperty(INDENT, value); - } - - /** - * The alignment of the text in the line. (a, m, r, j) a = align - * left = centered = aligned right = justified - * @return the alignment - */ - public String getAlignment() { - return getProperty(ALIGNMENT); - } - - /** - * Set the alignment for the line. - */ - public void setAlignment(String attribute) { - setProperty(ALIGNMENT, attribute); - } - - /** - * The display direction of the line l = left to right, r = right to left - * @return the direction - */ - public String getDirection() { - return getProperty(DIRECTION); - } - - /** - * Set the direction for the line. - */ - public void setDirection(String value) { - setProperty(DIRECTION, value); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * line with the given alignment. - * - * @param alignment the alignment to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByAlignment(String alignment) { - return Restriction.of(ALIGNMENT, alignment); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * line with the given direction. - * - * @param direction the direction to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByDirection(String direction) { - return Restriction.of(DIRECTION, direction); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * line with the given indentation. - * - * @param indent the indentation to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restrictByIndent(String indent) { - return Restriction.of(INDENT, indent); - } - - /** - * Creates an instance of {@link Restriction} that can be used to search for - * line with the given line type. - * - * @param lineType the line type to filter. - * @return an instance of {@link Restriction}. - */ - public static Restriction restricByLineType(String lineType) { - return Restriction.of(LINE_TYPE, lineType); - } -}
