http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorPresenter.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorPresenter.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorPresenter.java deleted file mode 100644 index 35a765d..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorPresenter.java +++ /dev/null @@ -1,70 +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 org.waveprotocol.box.webclient.widget.error; - -import com.google.gwt.user.client.ui.Panel; - -import org.waveprotocol.wave.client.common.safehtml.SafeHtml; - -/** - * Presents an error message, with asynchronous addition of detail. - */ -public final class ErrorIndicatorPresenter implements ErrorIndicatorView.Listener { - - /** View controlled by this presenter. */ - private final ErrorIndicatorView ui; - - private ErrorIndicatorPresenter(ErrorIndicatorView ui) { - this.ui = ui; - } - - /** - * Creates an error indicator. - * - * @param container panel to which this widget is to be attached - */ - public static ErrorIndicatorPresenter create(Panel container) { - ErrorIndicatorWidget ui = ErrorIndicatorWidget.create(); - ErrorIndicatorPresenter presenter = new ErrorIndicatorPresenter(ui); - ui.init(presenter); - container.add(ui); - return presenter; - } - - /** - * Adds extra detail about the error to the indicator. - * - * @param stack a stack trace - * @param bug a bug report - */ - public void addDetail(SafeHtml stack, SafeHtml bug) { - ui.setStack(stack); - if (bug != null) { - ui.setBug(bug); - } - ui.showDetailLink(); - } - - @Override - public void onShowDetailClicked() { - ui.hideDetailLink(); - ui.expandDetailBox(); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorView.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorView.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorView.java deleted file mode 100644 index 9dfb2e9..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorView.java +++ /dev/null @@ -1,76 +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 org.waveprotocol.box.webclient.widget.error; - -import org.waveprotocol.wave.client.common.safehtml.SafeHtml; - - -/** - * UI for an error indicator. - */ -interface ErrorIndicatorView { - - /** - * Listener interface for UI gestures. - */ - interface Listener { - void onShowDetailClicked(); - } - - /** - * Binds this view to a listener. - */ - void init(Listener listener); - - /** - * Releases this view from its listener. - */ - void reset(); - - /** - * Sets the rendering of the stack trace. - */ - void setStack(SafeHtml stack); - - /** - * Sets the rendering of a known issue. - */ - void setBug(SafeHtml bug); - - /** - * Shows the 'show detail' link. - */ - void showDetailLink(); - - /** - * Hides the 'show detail' link. - */ - void hideDetailLink(); - - /** - * Expands the detail box. - */ - void expandDetailBox(); - - /** - * Collapses the detail box. - */ - void collapseDetailBox(); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorWidget.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorWidget.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorWidget.java deleted file mode 100644 index 0930568..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/ErrorIndicatorWidget.java +++ /dev/null @@ -1,123 +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 org.waveprotocol.box.webclient.widget.error; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.resources.client.CssResource; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.ui.Anchor; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTMLPanel; - -import org.waveprotocol.wave.client.common.safehtml.SafeHtml; - -/** - * GWT implementation of the UI for an error indicator. - */ -public final class ErrorIndicatorWidget extends Composite implements ErrorIndicatorView { - - interface Binder extends UiBinder<HTMLPanel, ErrorIndicatorWidget> { - } - - interface Style extends CssResource { - // Css classes used by code. - String expanded(); - - // Classes not used by code, but forced to be declared thanks to UiBinder. - String detail(); - - String stack(); - } - - private static final Binder BINDER = GWT.create(Binder.class); - - @UiField - Style style; - @UiField - Anchor showDetail; - @UiField - Element detail; - @UiField - Element stack; - @UiField - Element bug; - - private Listener listener; - - - private ErrorIndicatorWidget() { - initWidget(BINDER.createAndBindUi(this)); - } - - public static ErrorIndicatorWidget create() { - return new ErrorIndicatorWidget(); - } - - @Override - public void init(Listener listener) { - this.listener = listener; - } - - @Override - public void reset() { - this.listener = null; - } - - @UiHandler("showDetail") - void handleClick(ClickEvent e) { - if (listener != null) { - listener.onShowDetailClicked(); - } - } - - @Override - public void setStack(SafeHtml stack) { - this.stack.setInnerHTML(stack.asString()); - } - - @Override - public void setBug(SafeHtml bug) { - this.bug.setInnerHTML(bug.asString()); - } - - @Override - public void showDetailLink() { - showDetail.setVisible(true); - } - - @Override - public void hideDetailLink() { - showDetail.setVisible(false); - } - - @Override - public void expandDetailBox() { - detail.addClassName(style.expanded()); - } - - @Override - public void collapseDetailBox() { - detail.removeClassName(style.expanded()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/i18n/ErrorMessages.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/i18n/ErrorMessages.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/i18n/ErrorMessages.java deleted file mode 100644 index d819509..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/error/i18n/ErrorMessages.java +++ /dev/null @@ -1,47 +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 org.waveprotocol.box.webclient.widget.error.i18n; - -import com.google.gwt.i18n.client.Messages; -import com.google.gwt.i18n.client.Messages.DefaultMessage; - -/** - * - * @author akaplanov (Andrew Kaplanov) - */ -public interface ErrorMessages extends Messages { - @DefaultMessage("\"Everything's shiny, Cap'n. Not to fret!\"") - String everythingShiny(); - - @DefaultMessage("An error has occurred") - String errorHasOccurred(); - - @DefaultMessage("Please") - String please(); - - @DefaultMessage("refresh") - String refreshPage(); - - @DefaultMessage("Show error detail") - String showErrorDetail(); - - @DefaultMessage("Stack trace:") - String stackTrace(); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/frame/FramedPanel.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/frame/FramedPanel.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/frame/FramedPanel.java deleted file mode 100644 index eb3b718..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/frame/FramedPanel.java +++ /dev/null @@ -1,186 +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 org.waveprotocol.box.webclient.widget.frame; - -import com.google.common.base.Preconditions; -import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.StyleInjector; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.CssResource; -import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.resources.client.ImageResource.ImageOptions; -import com.google.gwt.resources.client.ImageResource.RepeatStyle; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HasWidgets; -import com.google.gwt.user.client.ui.Widget; - -import org.waveprotocol.wave.client.widget.common.ImplPanel; - -import java.util.Collections; -import java.util.Iterator; - -/** - * A frame around a widget. - * - * @author [email protected] (David Hearnden) - */ -public class FramedPanel extends Composite implements HasWidgets { - - /** Resources used by this widget. */ - public interface Resources extends ClientBundle { - /** Default background images */ - @Source("panel_n.png") - @ImageOptions(repeatStyle = RepeatStyle.Horizontal) - ImageResource chromeNorth(); - - @Source("panel_ne.png") - ImageResource chromeNorthEast(); - - @Source("panel_e.png") - @ImageOptions(repeatStyle = RepeatStyle.Vertical) - ImageResource chromeEast(); - - @Source("panel_se.png") - ImageResource chromeSouthEast(); - - @Source("panel_s.png") - @ImageOptions(repeatStyle = RepeatStyle.Horizontal) - ImageResource chromeSouth(); - - @Source("panel_sw.png") - ImageResource chromeSouthWest(); - - @Source("panel_w.png") - @ImageOptions(repeatStyle = RepeatStyle.Vertical) - ImageResource chromeWest(); - - @Source("panel_nw.png") - ImageResource chromeNorthWest(); - - /** CSS */ - @Source("FramedPanel.css") - Css css(); - } - - /** CSS for this widget. */ - public interface Css extends CssResource { - // Background images for the bread crumb. - String north(); - - String northEast(); - - String east(); - - String southEast(); - - String south(); - - String southWest(); - - String west(); - - String northWest(); - - /** Whole frame. */ - String frame(); - - /** Element containing the content. */ - String contentContainer(); - } - - @UiField(provided = true) - final static Css css = GWT.<Resources> create(Resources.class).css(); - - static { - StyleInjector.inject(css.getText(), true); - } - - interface Binder extends UiBinder<ImplPanel, FramedPanel> { - } - - private static final Binder BINDER = GWT.create(Binder.class); - - /** This widget's implementation. */ - private final ImplPanel self; - /** Element to which contents are to be attached. */ - @UiField - Element contentContainer; - /** Element containing the title-bar text. */ - @UiField - Element title; - /** The widget in this frame, if there is one. */ - private Widget contents; - - /** - * Creates a framed panel. - */ - public FramedPanel() { - initWidget(self = BINDER.createAndBindUi(this)); - } - - /** - * Creates a framed panel around a widget. - */ - public static FramedPanel of(Widget w) { - FramedPanel frame = new FramedPanel(); - frame.add(w); - return frame; - } - - /** - * Sets the text in the title bar. - */ - public void setTitleText(String text) { - title.setInnerText(text); - } - - @Override - public void add(Widget w) { - Preconditions.checkState(contents == null); - self.add(w, contentContainer); - contents = w; - } - - @Override - public boolean remove(Widget w) { - if (w == contents) { - clear(); - return true; - } else { - return false; - } - } - - @Override - public void clear() { - if (contents != null) { - contents.removeFromParent(); - contents = null; - } - } - - @Override - public Iterator<Widget> iterator() { - return Collections.singleton(contents).iterator(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/LoadingIndicator.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/LoadingIndicator.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/LoadingIndicator.java deleted file mode 100644 index 443ac0b..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/LoadingIndicator.java +++ /dev/null @@ -1,80 +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 org.waveprotocol.box.webclient.widget.loading; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.StyleInjector; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.CssResource; -import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; - -/** - * A loading indicator widget. - * - * @author [email protected] (David Hearnden) - */ -public class LoadingIndicator { - - /** Resources used by this widget. */ - public interface Resources extends ClientBundle { - @Source("loading.gif") - ImageResource loading(); - - /** CSS */ - @Source("Loading.css") - Css css(); - } - - /** CSS for this widget. */ - public interface Css extends CssResource { - String loading(); - - String loadingImage(); - } - - @UiField(provided = true) - final static Css css = GWT.<Resources> create(Resources.class).css(); - - static { - StyleInjector.inject(css.getText(), true); - } - - interface Binder extends UiBinder<Element, LoadingIndicator> { - } - - private static final Binder BINDER = GWT.create(Binder.class); - - /** Loading indicator. */ - private final Element loading; - - /** - * Creates a framed panel. - */ - public LoadingIndicator() { - loading = BINDER.createAndBindUi(this); - } - - public Element getElement() { - return loading; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/i18n/LoadingMessages.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/i18n/LoadingMessages.java b/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/i18n/LoadingMessages.java deleted file mode 100644 index 7f43505..0000000 --- a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/i18n/LoadingMessages.java +++ /dev/null @@ -1,32 +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 org.waveprotocol.box.webclient.widget.loading.i18n; - -import com.google.gwt.i18n.client.Messages; -import com.google.gwt.i18n.client.Messages.DefaultMessage; - -/** - * - * @author akaplanov (Andrew Kaplanov) - */ -public interface LoadingMessages extends Messages { - @DefaultMessage("Loading") - String loading(); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/loading.gif ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/loading.gif b/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/loading.gif deleted file mode 100644 index 8318e9a..0000000 Binary files a/wave/src/main/java/org/waveprotocol/box/webclient/widget/loading/loading.gif and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/examples/robots/dataapi/ParseRawDelta.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/examples/robots/dataapi/ParseRawDelta.java b/wave/src/main/java/org/waveprotocol/examples/robots/dataapi/ParseRawDelta.java deleted file mode 100644 index c4af97c..0000000 --- a/wave/src/main/java/org/waveprotocol/examples/robots/dataapi/ParseRawDelta.java +++ /dev/null @@ -1,52 +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 org.waveprotocol.examples.robots.dataapi; - -import org.waveprotocol.wave.federation.Proto.ProtocolAppliedWaveletDelta; -import org.waveprotocol.wave.model.util.CharBase64; - -/** - * Parses a base64 encoded raw delta. - * - * You can compile and run this program by building the dist jars with "ant dist" - * and then running the follwing commands in the src directory: - * - * javac -classpath '../dist/*' org/waveprotocol/examples/robots/dataapi/ParseRawDelta.java - * java -classpath '../dist/*:.' org.waveprotocol.examples.robots.dataapi.ParseRawDelta <x> - * - * where <x> is your base 64 encoded raw delta. - * - * @author [email protected] (Soren Lassen) - */ -public class ParseRawDelta { - - public static void main(String[] args) throws Exception { - if (args.length != 1) { - System.err.println( - "Usage: java [options] " + ParseRawDelta.class.getName() + " <base64 encoded raw delta>"); - System.exit(1); - } else { - System.out.println("Parsing base64 string: " + args[0]); - byte[] bytes = CharBase64.decode(args[0]); - ProtocolAppliedWaveletDelta parsed = ProtocolAppliedWaveletDelta.parseFrom(bytes); - System.out.println(parsed.toString()); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/examples/robots/echoey/Echoey.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/examples/robots/echoey/Echoey.java b/wave/src/main/java/org/waveprotocol/examples/robots/echoey/Echoey.java deleted file mode 100644 index 9f6ac80..0000000 --- a/wave/src/main/java/org/waveprotocol/examples/robots/echoey/Echoey.java +++ /dev/null @@ -1,174 +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 org.waveprotocol.examples.robots.echoey; - -import com.google.common.base.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.wave.api.AbstractRobot; -import com.google.wave.api.Annotation; -import com.google.wave.api.Blip; -import com.google.wave.api.Context; -import com.google.wave.api.Wavelet; -import com.google.wave.api.event.AnnotatedTextChangedEvent; -import com.google.wave.api.event.DocumentChangedEvent; -import com.google.wave.api.event.WaveletBlipCreatedEvent; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * Robot that echoes the changes to a wave. - * - * @author [email protected] (Lennard de Rijk) - */ -public class Echoey extends AbstractRobot { - - /** Annotation for text by Echoey */ - private static final String ECHOEY_ANNOTATION = "www.waveprotocol.org/echoey"; - - private final Map<String, String> shadowBlipMap; - - public Echoey() { - shadowBlipMap = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).<String, String>build().asMap(); - } - - @Override - protected String getRobotName() { - return "Echoey"; - } - - @Override - protected String getRobotProfilePageUrl() { - return "http://www.waveprotocol.org/"; - } - - @Capability(contexts = {Context.SELF, Context.SIBLINGS}) - @Override - public void onWaveletBlipCreated(WaveletBlipCreatedEvent event) { - Blip blip = event.getNewBlip(); - if (!isShadowBlip(blip)) { - createShadowBlip(blip); - } - } - - @Capability(contexts = {Context.SELF, Context.SIBLINGS}) - @Override - public void onDocumentChanged(DocumentChangedEvent event) { - Blip blip = event.getBlip(); - if (!isShadowBlip(blip)) { - createOrUpdateShadowBlip(blip); - } - } - - @Capability(contexts = {Context.SELF, Context.SIBLINGS}) - @Override - public void onAnnotatedTextChanged(AnnotatedTextChangedEvent event) { - Blip blip = event.getBlip(); - if (!isShadowBlip(blip)) { - createOrUpdateShadowBlip(blip); - } - } - - /** - * Creates a new shadow blip. - * - * Note that this method will not know the id of the new blip since the - * server will generate it. - * - * @param blip the blip to create a new shadow blip for. - */ - private void createShadowBlip(Blip blip) { - Blip newBlip = blip.continueThread(); - newBlip.all().replace(blip.getContent()); - newBlip.all().annotate(ECHOEY_ANNOTATION, blip.getBlipId()); - } - - /** - * Creates or updates an existing shadow blip that should shadow the given - * blip. - * - * @param blipToShadow the blip that should be shadowed. - */ - private void createOrUpdateShadowBlip(Blip blipToShadow) { - Wavelet wavelet = blipToShadow.getWavelet(); - String blipId = blipToShadow.getBlipId(); - if (shadowBlipMap.containsKey(blipId)) { - Blip shadowBlip = wavelet.getBlip(shadowBlipMap.get(blipId)); - updateShadowBlip(shadowBlip, blipToShadow); - } else { - updateShadowMap(wavelet); - - if (!shadowBlipMap.containsKey(blipId)) { - createShadowBlip(blipToShadow); - } else { - // Update existing shadow Blip - Blip shadowBlip = wavelet.getBlip(shadowBlipMap.get(blipId)); - updateShadowBlip(shadowBlip, blipToShadow); - } - } - } - - /** - * Updates an existing shadow blip. - * - * @param shadowBlip the blip that is shadowing. - * @param blipToShadow the blip being shadowed. - */ - private void updateShadowBlip(Blip shadowBlip, Blip blipToShadow) { - Preconditions.checkNotNull(shadowBlip, "Shadow blip can't be null"); - Preconditions.checkNotNull(blipToShadow, "Blip to shadow can't be null"); - shadowBlip.all().replace(blipToShadow.getContent()); - - for (Annotation annotation : blipToShadow.getAnnotations()) { - if (annotation.getName().equals(ECHOEY_ANNOTATION)) { - continue; - } - shadowBlip.range(annotation.getRange().getStart(), annotation.getRange().getEnd()).annotate( - annotation.getName(), annotation.getValue()); - } - shadowBlip.all().annotate(ECHOEY_ANNOTATION, blipToShadow.getBlipId()); - - shadowBlipMap.put(blipToShadow.getBlipId(), shadowBlip.getBlipId()); - } - - /** - * Updates the shadow map for a given wavelet. - */ - private void updateShadowMap(Wavelet wavelet) { - for (Blip blip : wavelet.getBlips().values()) { - if (isShadowBlip(blip)) { - String shadowBlipId = blip.getBlipId(); - if (!shadowBlipMap.containsValue(shadowBlipId)) { - String originalBlipId = blip.getAnnotations().get(ECHOEY_ANNOTATION).get(0).getValue(); - shadowBlipMap.put(originalBlipId, shadowBlipId); - } - } - } - } - - /** - * Return true if the given blip is a blip in which Echoey has written. - */ - private boolean isShadowBlip(Blip blip) { - List<Annotation> annotations = blip.getAnnotations().get(ECHOEY_ANNOTATION); - return annotations != null && !annotations.isEmpty(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/api/api.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/api/api.st b/wave/src/main/java/org/waveprotocol/pst/templates/api/api.st deleted file mode 100644 index 583e0f7..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/api/api.st +++ /dev/null @@ -1,40 +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 $m.package$; - -$m.referencedMessages: {t| - import $t.fullJavaType$; -}$ - -$m.referencedEnums: {t| - import $t.fullJavaType$; -}$ - -import org.waveprotocol.wave.communication.Blob; -import org.waveprotocol.wave.communication.ProtoEnums; - -import java.util.List; - -/** - * Model interface for $m.name$. - * - * Generated from $m.filename$. Do not edit. - */ -$interface(m=m)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/api/beans.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/api/beans.st b/wave/src/main/java/org/waveprotocol/pst/templates/api/beans.st deleted file mode 100644 index 4bc3add..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/api/beans.st +++ /dev/null @@ -1,69 +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. - */ - -$if (f.optional)$ - - /** Returns whether $f.name$ has been set. */ - boolean has$f.capName$(); - - /** Clears the value of $f.name$. */ - void clear$f.capName$(); - -$endif$ - -$if (f.repeated)$ - - /** Returns $f.name$, or null if hasn't been set. */ - $if (f.message)$ - List<? extends $f.javaType$> $f.getter$(); - $else$ - List<$f.boxedJavaType$> $f.getter$(); - $endif$ - - /** Adds an element to $f.name$. */ - void add$f.capName$($f.javaType$ value); - - /** Adds a list of elements to $f.name$. */ - $if (f.message)$ - void addAll$f.capName$(List<? extends $f.javaType$> $f.name$); - $else$ - void addAll$f.capName$(List<$f.boxedJavaType$> $f.name$); - $endif$ - - /** Returns the nth element of $f.name$. */ - $f.javaType$ $f.getter$(int n); - - /** Sets the nth element of $f.name$. */ - void $f.setter$(int n, $f.javaType$ value); - - /** Returns the length of $f.name$. */ - int $f.getter$Size(); - - /** Clears $f.name$. */ - void clear$f.capName$(); - -$else$ - - /** Returns $f.name$, or null if hasn't been set. */ - $f.javaType$ $f.getter$(); - - /** Sets $f.name$. */ - void $f.setter$($f.javaType$ $f.name$); - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/api/enum.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/api/enum.st b/wave/src/main/java/org/waveprotocol/pst/templates/api/enum.st deleted file mode 100644 index b083dd9..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/api/enum.st +++ /dev/null @@ -1,34 +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. - */ - -enum $e.javaType$ implements ProtoEnums.HasIntValue { - $e.values: {v|$v.name$($v.number$),$\n$}$ - UNKNOWN(-1); - - private final int value; - - private $e.javaType$(int value) { - this.value = value; - } - - @Override - public int getValue() { - return value; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/api/interface.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/api/interface.st b/wave/src/main/java/org/waveprotocol/pst/templates/api/interface.st deleted file mode 100644 index 040af4a..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/api/interface.st +++ /dev/null @@ -1,43 +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. - */ - -public interface $m.javaType$ { - - $m.nestedEnums: {e|$enum(e=e)$}$ - $m.nestedMessages: {nested|$interface(m=nested)$}$ - - /** Does a deep copy from model. */ - void copyFrom($m.javaType$ model); - - /** - * Tests if this model is equal to another object. - * "Equal" is recursively defined as: - * <ul> - * <li>both objects implement this interface,</li> - * <li>all corresponding primitive fields of both objects have the same value, and</li> - * <li>all corresponding nested-model fields of both objects are "equal".</li> - * </ul> - * - * This is a coarser equivalence than provided by the equals() methods. Two - * objects may not be equal() to each other, but may be isEqualTo() each other. - */ - boolean isEqualTo(Object o); - - $m.fields: {f|$beans(f=f)$}$ -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/api/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/api/properties b/wave/src/main/java/org/waveprotocol/pst/templates/api/properties deleted file mode 100644 index 3cc7891..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/api/properties +++ /dev/null @@ -1,19 +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. - -template.name = -package.suffix = http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/beans.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/beans.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/beans.st deleted file mode 100644 index 0446faf..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/beans.st +++ /dev/null @@ -1,88 +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. - */ - -$if (f.optional)$ - - public $m.javaType$ clear$f.capName$() { - $f.name$ = null; - return this; - } - -$endif$ - -$if (f.repeated)$ - - $if (f.message)$ - public $m.javaType$ addAll$f.capName$(List<? extends $f.messageType$> messages) { - for ($f.messageType$ message : messages) { - add$f.capName$(message); - } - return this; - } - $else$ - public $m.javaType$ addAll$f.capName$(List<$f.boxedJavaType$> values) { - this.$f.name$.addAll(values); - return this; - } - $endif$ - - $if (f.message)$ - public $m.javaType$ $f.setter$(int n, $f.messageType$ message) { - this.$f.name$.set(n, message); - return this; - } - $else$ - public $m.javaType$ $f.setter$(int n, $f.javaType$ value) { - this.$f.name$.set(n, value); - return this; - } - $endif$ - - $if (f.message)$ - public $m.javaType$ add$f.capName$($f.messageType$ message) { - this.$f.name$.add(message); - return this; - } - $else$ - public $m.javaType$ add$f.capName$($f.javaType$ value) { - this.$f.name$.add(value); - return this; - } - $endif$ - - public $m.javaType$ clear$f.capName$() { - $f.name$.clear(); - return this; - } - -$else$ - - $if (f.message)$ - public $m.javaType$ $f.setter$($f.messageType$ message) { - this.$f.name$ = message; - return this; - } - $else$ - public $m.javaType$ $f.setter$($f.javaType$ value) { - this.$f.name$ = value; - return this; - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/buildField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/buildField.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/buildField.st deleted file mode 100644 index a2d085a..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/buildField.st +++ /dev/null @@ -1,25 +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. - */ - -$if (f.repeated)$ - $target$.clear$f.capName$(); - $target$.addAll$f.capName$($f.name$); -$else$ - $target$.set$f.capName$($f.name$); -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/builder.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/builder.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/builder.st deleted file mode 100644 index 4a797fa..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/builder.st +++ /dev/null @@ -1,35 +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 $m.package$; - -$imports(m=m)$ - -import org.waveprotocol.wave.communication.Blob; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Builder for $m.name$s. - * - * Generated from $m.filename$. Do not edit. - */ -$class(m=m)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/class.st deleted file mode 100644 index 6a49641..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/class.st +++ /dev/null @@ -1,42 +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. - */ - -public $if(m.inner)$static$endif$ final class $m.javaType$ { - - /** Factory to pass to {@link #build()}. */ - public interface Factory { - $m.name$ create(); - } - - $m.nestedMessages: {nested|$class(m=nested)$}$ - - $m.fields: {f|$fieldDeclaration(f=f)$}$ - - public $m.javaType$() { - } - - $m.fields: {f|$beans(m=m, f=f)$}$ - - /** Builds a {@link $m.name$} using this builder and a factory. */ - public $m.name$ build(Factory factory) { - $m.name$ message = factory.create(); - $m.fields: {f|$buildField(f=f, target="message")$}$ - return message; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/fieldDeclaration.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/fieldDeclaration.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/fieldDeclaration.st deleted file mode 100644 index b956417..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/fieldDeclaration.st +++ /dev/null @@ -1,36 +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. - */ - -$if (f.repeated)$ - - $if (f.message)$ - private final List<$f.messageType$> $f.name$ = new ArrayList<$f.messageType$>(); - $else$ - private final List<$f.boxedJavaType$> $f.name$ = new ArrayList<$f.boxedJavaType$>(); - $endif$ - -$else$ - - $if (f.message)$ - private $f.messageType$ $f.name$; - $else$ - private $f.boxedJavaType$ $f.name$; - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/importUtil.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/importUtil.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/importUtil.st deleted file mode 100644 index b71749c..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/importUtil.st +++ /dev/null @@ -1,24 +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. - */ - -import $p$.$m.name$Util; - -$m.nestedMessages: {t| - $importUtil(m=t,p=p+"."+m.name+"Util")$ -}$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/builder/imports.st deleted file mode 100644 index 72c228e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/imports.st +++ /dev/null @@ -1,32 +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. - */ - -$m.referencedMessages: {t| - import $t.fullName$; -}$ - -$m.referencedEnums: {t| - import $t.fullName$; -}$ - -$m.referencedMessages: {t| - import $t.fullJavaType$; -}$ - -$importUtil(m=m,p=m.packageBase)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/builder/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/builder/properties b/wave/src/main/java/org/waveprotocol/pst/templates/builder/properties deleted file mode 100644 index b0ef0e5..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/builder/properties +++ /dev/null @@ -1,18 +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. - -template.name = Builder http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/class.st deleted file mode 100644 index f2a1237..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/class.st +++ /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. - */ - -public $if(m.inner)$static$endif$ final class $m.javaType$ extends $m.name$Impl - implements GsonSerializable { - - $m.nestedMessages: {nested|$class(m=nested)$}$ - - public $m.javaType$() { - super(); - } - - public $m.javaType$($m.name$ message) { - super(message); - } - - @Override - public JsonElement toGson(RawStringData raw, Gson gson) { - return toGsonHelper(this, raw, gson); - } - - /** - * Static implementation-independent GSON serializer. Call this from - * {@link #toGson} to avoid subclassing issues with inner message types. - */ - public static JsonElement toGsonHelper($m.name$ message, RawStringData raw, Gson gson) { - JsonObject json = new JsonObject(); - $m.fields: {f|$toGsonField(f=f, source="message", target="json")$}$ - return json; - } - - @Override - public void fromGson(JsonElement json, Gson gson, RawStringData raw) throws GsonException { - reset(); - JsonObject jsonObject = json.getAsJsonObject(); - // NOTE: always check with has(...) as the json might not have all required - // fields set. - $m.fields: {f|$fromGsonField(f=f, target="jsonObject")$}$ - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/clearField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/clearField.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/clearField.st deleted file mode 100644 index 6bde0f0..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/clearField.st +++ /dev/null @@ -1,24 +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. - */ - -$if (f.repeated)$ - this.$f.name$.clear(); -$else$ - this.$f.name$ = null; -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonField.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonField.st deleted file mode 100644 index 6b52b53..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonField.st +++ /dev/null @@ -1,29 +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. - */ - -if ($target$.has("$f.number$")) { - $if (f.optional)$ - JsonElement elem = $target$.get("$f.number$"); - if (!elem.isJsonNull()) { - $fromGsonFieldInner(expr="elem")$ - } - $else$ - $fromGsonFieldInner(expr={$target$.get("$f.number$")})$ - $endif$ -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonFieldInner.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonFieldInner.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonFieldInner.st deleted file mode 100644 index 11ef6d1..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/fromGsonFieldInner.st +++ /dev/null @@ -1,51 +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. - */ - -$if (f.repeated)$ - JsonArray array = $expr$.getAsJsonArray(); - for (int i = 0; i < array.size(); i++) { - $if (f.message)$ - $f.javaType$ payload = new $f.javaType$(); - GsonUtil.extractJsonObject(payload, array.get(i), gson, raw); - add$f.capName$(payload); - $elseif (f.enum)$ - add$f.capName$(ProtoEnums.valOf(array.get(i).getAsInt(), $f.javaType$.values())); - $elseif (f.blob)$ - add$f.capName$(new Blob(array.get(i).getAsString())); - $elseif (f.long)$ - add$f.capName$(GsonUtil.fromJson(array.get(i))); - $else$ - add$f.capName$(array.get(i).getAs$f.capJavaType$()); - $endif$ - } -$else$ - $if (f.message)$ - $f.javaType$ payload = new $f.javaType$(); - GsonUtil.extractJsonObject(payload, $expr$, gson, raw); - $f.setter$(payload); - $elseif (f.enum)$ - $f.setter$(ProtoEnums.valOf($expr$.getAsInt(), $f.javaType$.values())); - $elseif (f.blob)$ - $f.setter$(new Blob($expr$.getAsString())); - $elseif (f.long)$ - $f.setter$(GsonUtil.fromJson($expr$)); - $else$ - $f.setter$($expr$.getAs$f.capJavaType$()); - $endif$ -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/gson.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/gson.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/gson.st deleted file mode 100644 index 476d39e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/gson.st +++ /dev/null @@ -1,45 +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 $m.package$; - -// Import order matters here due to what looks like a javac bug. -// Eclipse doesn't seem to have this problem. -import org.waveprotocol.wave.communication.gson.GsonSerializable; - -$imports(m=m)$ - -import org.waveprotocol.wave.communication.Blob; -import org.waveprotocol.wave.communication.ProtoEnums; -import org.waveprotocol.wave.communication.gson.GsonException; -import org.waveprotocol.wave.communication.gson.GsonUtil; -import org.waveprotocol.wave.communication.json.RawStringData; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -/** - * Pojo implementation of $m.name$ with gson serialization and deserialization. - * - * Generated from $m.filename$. Do not edit. - */ -$class(m=m)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/importUtil.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/importUtil.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/importUtil.st deleted file mode 100644 index 6d548ec..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/importUtil.st +++ /dev/null @@ -1,26 +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. - */ - -import $m.fullName$; -import $utilScope$.$m.name$Util; -import $pojoScope$.$m.name$Impl; - -$m.nestedMessages: {t| - $importUtil(m=t,utilScope=utilScope+"."+m.name+"Util",pojoScope=pojoScope+"."+m.name+"Impl")$ -}$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/imports.st deleted file mode 100644 index 20ed3e7..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/imports.st +++ /dev/null @@ -1,32 +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. - */ - -$importUtil(m=m,utilScope=m.packageBase,pojoScope=m.packageBase+".impl")$ - -$m.referencedMessages: {t| - import $t.fullName$; -}$ - -$m.referencedEnums: {t| - import $t.fullName$; -}$ - -$m.referencedMessages: {t| - import $t.fullJavaType$; -}$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/properties b/wave/src/main/java/org/waveprotocol/pst/templates/gson/properties deleted file mode 100644 index e312ed2..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/properties +++ /dev/null @@ -1,19 +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. - -template.name = GsonImpl -package.suffix = gson http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonField.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonField.st deleted file mode 100644 index 6ccc177..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonField.st +++ /dev/null @@ -1,30 +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. - */ - -$if (f.optional)$ -if ($source$.has$f.capName$()) { - $toGsonFieldInner()$ -} -$elseif (f.repeated)$ -{ - $toGsonFieldInner()$ -} -$else$ -$toGsonFieldInner()$ -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonFieldInner.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonFieldInner.st b/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonFieldInner.st deleted file mode 100644 index 54d5865..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/gson/toGsonFieldInner.st +++ /dev/null @@ -1,49 +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. - */ - -$if (f.repeated)$ - JsonArray array = new JsonArray(); - for (int i = 0; i < $source$.$f.getter$Size(); i++) { - $if (f.message)$ - // NOTE(kalman): if multistage parsing worked, we would add split points here. - array.add($f.javaType$.toGsonHelper($source$.$f.getter$(i), raw, gson)); - $elseif (f.enum)$ - array.add(new JsonPrimitive($source$.$f.getter$(i).getValue())); - $elseif (f.blob)$ - array.add(new JsonPrimitive($source$.$f.getter$(i).getData())); - $elseif (f.long)$ - array.add(GsonUtil.toJson($source$.$f.getter$(i))); - $else$ - array.add(new JsonPrimitive($source$.$f.getter$(i))); - $endif$ - } - $target$.add("$f.number$", array); -$else$ - $if (f.message)$ - $target$.add("$f.number$", $f.javaType$.toGsonHelper($source$.$f.getter$(), raw, gson)); - $elseif (f.enum)$ - $target$.add("$f.number$", new JsonPrimitive($source$.$f.getter$().getValue())); - $elseif (f.blob)$ - $target$.add("$f.number$", new JsonPrimitive($source$.$f.getter$().getData())); - $elseif (f.long)$ - $target$.add("$f.number$", GsonUtil.toJson($source$.$f.getter$())); - $else$ - $target$.add("$f.number$", new JsonPrimitive($source$.$f.getter$())); - $endif$ -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/beans.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/beans.st b/wave/src/main/java/org/waveprotocol/pst/templates/jso/beans.st deleted file mode 100644 index 9682cab..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/beans.st +++ /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. - */ - -$if (f.optional)$ - - @Override - public boolean has$f.capName$() { - return hasProperty(this, key$f.capName$); - } - - @Override - public void clear$f.capName$() { - if (hasProperty(this, key$f.capName$)) { - deleteProperty(this, key$f.capName$); - } - } - -$endif$ - -$if (f.repeated)$ - - @Override - public List<$f.boxedJavaType$> $f.getter$() { - initArray(this, key$f.capName$); - List<$f.boxedJavaType$> list = new ArrayList<$f.boxedJavaType$>(); - for (int i = 0; i < $f.getter$Size(); i++) { - list.add($f.getter$(i)); - } - return list; - } - - $if (f.message)$ - @Override - public void addAll$f.capName$(List<? extends $f.messageType$> models) { - for ($f.messageType$ model : models) { - add$f.capName$(model); - } - } - $else$ - @Override - public void addAll$f.capName$(List<$f.boxedJavaType$> values) { - for ($f.javaType$ value : values) { - add$f.capName$(value); - } - } - $endif$ - - @Override - @SuppressWarnings("unchecked") - public $f.javaType$ $f.getter$(int n) { - initArray(this, key$f.capName$); - $if (f.message)$ - JsArray<$f.javaType$> array = getPropertyAsObject(this, key$f.capName$).cast(); - $elseif (f.enum)$ - JsArrayInteger array = getPropertyAsObject(this, key$f.capName$).cast(); - $elseif (f.blob)$ - JsArrayString array = getPropertyAsObject(this, key$f.capName$).cast(); - $else$ - JsArray$f.boxedJavaType$ array = getPropertyAsObject(this, key$f.capName$).cast(); - $endif$ - if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); - if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); - $if (f.enum)$ - return ProtoEnums.valOf(array.get(n), $f.javaType$.values()); - $elseif (f.blob)$ - return new Blob(array.get(n)); - $else$ - return array.get(n); - $endif$ - } - - $if (f.message)$ - @Override - @SuppressWarnings("unchecked") - public void $f.setter$(int n, $f.messageType$ model) { - if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); - initArray(this, key$f.capName$); - ((JsArray<$f.javaType$>) getPropertyAsObject(this, key$f.capName$)).set(n, ($f.javaType$) model); - } - $elseif (f.enum)$ - @Override - public void $f.setter$(int n, $f.javaType$ enumValue) { - if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); - initArray(this, key$f.capName$); - ((JsArrayInteger) getPropertyAsObject(this, key$f.capName$)).set(n, enumValue.getValue()); - } - $elseif (f.blob)$ - @Override - public void $f.setter$(int n, $f.javaType$ blob) { - if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); - initArray(this, key$f.capName$); - ((JsArrayString) getPropertyAsObject(this, key$f.capName$)).set(n, blob.getData()); - } - $else$ - @Override - public void $f.setter$(int n, $f.javaType$ value) { - if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); - initArray(this, key$f.capName$); - ((JsArray$f.boxedJavaType$) getPropertyAsObject(this, key$f.capName$)).set(n, value); - } - $endif$ - - @Override - public int $f.getter$Size() { - return hasProperty(this, key$f.capName$) ? ((JsArray<?>) getPropertyAsObject(this, key$f.capName$)).length() : 0; - } - - $if (f.message)$ - @Override - @SuppressWarnings("unchecked") - public void add$f.capName$($f.messageType$ model) { - initArray(this, key$f.capName$); - ((JsArray<$f.javaType$>) getPropertyAsObject(this, key$f.capName$)).push(($f.javaType$) model); - } - $elseif (f.enum)$ - @Override - public void add$f.capName$($f.javaType$ enumValue) { - initArray(this, key$f.capName$); - ((JsArrayInteger) getPropertyAsObject(this, key$f.capName$)).push(enumValue.getValue()); - } - $elseif (f.blob)$ - @Override - public void add$f.capName$($f.javaType$ blob) { - initArray(this, key$f.capName$); - ((JsArrayString) getPropertyAsObject(this, key$f.capName$)).push(blob.getData()); - } - $else$ - @Override - public void add$f.capName$($f.javaType$ value) { - initArray(this, key$f.capName$); - ((JsArray$f.boxedJavaType$) getPropertyAsObject(this, key$f.capName$)).push(value); - } - $endif$ - - @Override - public void clear$f.capName$() { - clearArray(this, key$f.capName$); - } - -$else$ - - @Override - $if (f.message)$ - public $f.messageType$ $f.getter$() { - return hasProperty(this, key$f.capName$) ? (($f.javaType$) getPropertyAsObject(this, key$f.capName$)) : null; - } - $elseif (f.enum)$ - public $f.javaType$ $f.getter$() { - return hasProperty(this, key$f.capName$) ? ProtoEnums.valOf(getPropertyAsInteger(this, key$f.capName$), $f.javaType$.values()) : null; - } - $elseif (f.blob)$ - public $f.javaType$ $f.getter$() { - return hasProperty(this, key$f.capName$) ? new Blob(getPropertyAsString(this, key$f.capName$)) : null; - } - $else$ - public $f.javaType$ $f.getter$() { - return hasProperty(this, key$f.capName$) ? getPropertyAs$f.boxedJavaType$(this, key$f.capName$) : $f.defaultValue$; - } - $endif$ - - $if (f.message)$ - @Override - public void $f.setter$($f.messageType$ model) { - setPropertyAsObject(this, key$f.capName$, ($f.javaType$) model); - } - $elseif (f.enum)$ - @Override - public void $f.setter$($f.javaType$ enumValue) { - setPropertyAsInteger(this, key$f.capName$, enumValue.getValue()); - } - $elseif (f.blob)$ - @Override - public void $f.setter$($f.javaType$ blob) { - setPropertyAsString(this, key$f.capName$, blob.getData()); - } - $else$ - @Override - public void $f.setter$($f.javaType$ value) { - setPropertyAs$f.boxedJavaType$(this, key$f.capName$, value); - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/jso/class.st deleted file mode 100644 index 9b9d843..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/class.st +++ /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. - */ - -/** We have to use fully-qualified name of the GsonSerializable class here in order to make it - * visible in case of nested classes. - */ -public $if(m.inner)$static$endif$ final class $m.javaType$ extends org.waveprotocol.wave.communication.gwt.JsonMessage - implements $m.name$ { - - $m.nestedMessages: {nested|$class(m=nested)$}$ - - $m.fields: {f| - private static final String key$f.capName$ = "$f.number$"; - }$ - - protected $m.javaType$() { - } - - public static $m.javaType$ create() { - $m.javaType$ instance = ($m.javaType$) JsonMessage.createJsonMessage(); - - // Force all lists to start with an empty list rather than no property for - // the list. This is so that the native JS equality works, since (obviously) - // {} != {"foo": []} while in the context of messages they should be. - $m.fields: {f| - $if (f.repeated)$ - instance.clear$f.capName$(); - $endif$ - }$ - - return instance; - } - - @Override - public void copyFrom($m.name$ message) { - super.copyFrom(($m.javaType$) message); - } - - $m.fields: {f|$beans(m=m, f=f)$}$ - - @Override - public boolean isEqualTo(Object o) { - if (o instanceof $m.javaType$) { - return nativeIsEqualTo(o); - } else if (o instanceof $m.name$) { - return $m.name$Util.isEqual(this, ($m.name$) o); - } else { - return false; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/importUtil.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/importUtil.st b/wave/src/main/java/org/waveprotocol/pst/templates/jso/importUtil.st deleted file mode 100644 index 6459929..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/importUtil.st +++ /dev/null @@ -1,25 +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. - */ - -import $m.fullName$; -import $p$.$m.name$Util; - -$m.nestedMessages: {t| - $importUtil(m=t,p=p+"."+m.name+"Util")$ -}$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/jso/imports.st deleted file mode 100644 index 72c228e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/imports.st +++ /dev/null @@ -1,32 +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. - */ - -$m.referencedMessages: {t| - import $t.fullName$; -}$ - -$m.referencedEnums: {t| - import $t.fullName$; -}$ - -$m.referencedMessages: {t| - import $t.fullJavaType$; -}$ - -$importUtil(m=m,p=m.packageBase)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/jso.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/jso.st b/wave/src/main/java/org/waveprotocol/pst/templates/jso/jso.st deleted file mode 100644 index 738f06b..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/jso.st +++ /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 $m.package$; - -import static org.waveprotocol.wave.communication.gwt.JsonHelper.*; - -import com.google.gwt.core.client.*; - -$imports(m=m)$ - -import org.waveprotocol.wave.communication.Blob; -import org.waveprotocol.wave.communication.ProtoEnums; - -import org.waveprotocol.wave.communication.gwt.*; -import org.waveprotocol.wave.communication.json.*; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Client implementation of $m.name$ backed by a GWT JavaScriptObject. - * - * Generated from $m.filename$. Do not edit. - */ -$class(m=m)$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/jso/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/jso/properties b/wave/src/main/java/org/waveprotocol/pst/templates/jso/properties deleted file mode 100644 index 8d8415e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/jso/properties +++ /dev/null @@ -1,19 +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. - -template.name = JsoImpl -package.suffix = jso
