http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/addHashCode.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/addHashCode.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/addHashCode.st deleted file mode 100644 index 141a4c6..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/addHashCode.st +++ /dev/null @@ -1,28 +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)$ - - $result$ = ($shift$ * $result$) + (has$f.capName$() ? $f.name$.hashCode() : 0); - -$else$ - - $result$ = ($shift$ * $result$) + $f.name$.hashCode(); - -$endif$
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/beans.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/beans.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/beans.st deleted file mode 100644 index 7267807..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/beans.st +++ /dev/null @@ -1,121 +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 $f.name$ != null; - } - - @Override - public void clear$f.capName$() { - $f.name$ = null; - } - -$endif$ - -$if (f.repeated)$ - - @Override - public List<$f.boxedJavaType$> $f.getter$() { - return Collections.unmodifiableList($f.name$); - } - - $if (f.message)$ - @Override - public void addAll$f.capName$(List<? extends $f.messageType$> messages) { - for ($f.messageType$ message : messages) { - add$f.capName$(message); - } - } - $else$ - @Override - public void addAll$f.capName$(List<$f.boxedJavaType$> values) { - this.$f.name$.addAll(values); - } - $endif$ - - @Override - public $f.javaType$ $f.getter$(int n) { - $if (f.message)$ - return new $f.javaType$($f.name$.get(n)); - $else$ - return $f.name$.get(n); - $endif$ - } - - $if (f.message)$ - @Override - public void $f.setter$(int n, $f.messageType$ message) { - this.$f.name$.set(n, new $f.javaType$(message)); - } - $else$ - @Override - public void $f.setter$(int n, $f.javaType$ value) { - this.$f.name$.set(n, value); - } - $endif$ - - @Override - public int $f.getter$Size() { - return $f.name$.size(); - } - - $if (f.message)$ - @Override - public void add$f.capName$($f.messageType$ message) { - this.$f.name$.add(new $f.javaType$(message)); - } - $else$ - @Override - public void add$f.capName$($f.javaType$ value) { - this.$f.name$.add(value); - } - $endif$ - - @Override - public void clear$f.capName$() { - $f.name$.clear(); - } - -$else$ - - @Override - public $f.javaType$ $f.getter$() { - $if (f.message)$ - return new $f.javaType$($f.name$); - $else$ - return $f.name$; - $endif$ - } - - $if (f.message)$ - @Override - public void $f.setter$($f.messageType$ message) { - this.$f.name$ = new $f.javaType$(message); - } - $else$ - @Override - public void $f.setter$($f.javaType$ value) { - this.$f.name$ = value; - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/class.st deleted file mode 100644 index 468403f..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/class.st +++ /dev/null @@ -1,65 +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$ class $m.javaType$ implements $m.name$ { - - $m.nestedMessages: {nested|$class(m=nested)$}$ - - $m.fields: {f|$fieldDeclaration(f=f)$}$ - - public $m.javaType$() { - } - - public $m.javaType$($m.name$ message) { - copyFrom(message); - } - - @Override - public void copyFrom($m.name$ message) { - $m.fields: {f|$copyField(f=f, target="message")$}$ - } - - $m.fields: {f|$beans(m=m, f=f)$}$ - - /** Provided to subclasses to clear all fields, for example when deserializing. */ - protected void reset() { - $m.fields: {f|$clearField(f=f)$}$ - } - - @Override - public boolean equals(Object o) { - return (o instanceof $m.javaType$) && isEqualTo(o); - } - - @Override - public boolean isEqualTo(Object o) { - if (o == this) { - return true; - } else if (o instanceof $m.name$) { - return $m.name$Util.isEqual(this, ($m.name$) o); - } else { - return false; - } - } - - @Override - public int hashCode() { - return $m.name$Util.getHashCode(this); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/clearField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/clearField.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/clearField.st deleted file mode 100644 index 6bde0f0..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/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/pojo/copyField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/copyField.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/copyField.st deleted file mode 100644 index 0e37f70..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/copyField.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. - */ - -$if (f.repeated)$ - - clear$f.capName$(); - $if (f.message)$ - for ($f.messageType$ field : $target$.$f.getter$()) { - add$f.capName$(new $f.javaType$(field)); - } - $else$ - for ($f.javaType$ field : $target$.$f.getter$()) { - add$f.capName$(field); - } - $endif$ - -$else$ - - $if (f.optional)$ - if ($target$.has$f.capName$()) { - $endif$ - $f.setter$($target$.$f.getter$()); - $if (f.optional)$ - } else { - clear$f.capName$(); - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/fieldDeclaration.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/fieldDeclaration.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/fieldDeclaration.st deleted file mode 100644 index fe14d62..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/fieldDeclaration.st +++ /dev/null @@ -1,28 +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)$ - - private final List<$f.boxedJavaType$> $f.name$ = new ArrayList<$f.boxedJavaType$>(); - -$else$ - - private $f.boxedJavaType$ $f.name$; - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/importUtil.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/importUtil.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/importUtil.st deleted file mode 100644 index 6459929..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/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/pojo/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/imports.st deleted file mode 100644 index 72c228e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/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/pojo/pojo.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/pojo.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/pojo.st deleted file mode 100644 index ef0e50f..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/pojo.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; - -/** - * Pojo implementation of $m.name$. - * - * 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/pojo/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/properties b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/properties deleted file mode 100644 index 6e99d13..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/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 = Impl -package.suffix = impl http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/pojo/returnFalseIfNotEqual.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/returnFalseIfNotEqual.st b/wave/src/main/java/org/waveprotocol/pst/templates/pojo/returnFalseIfNotEqual.st deleted file mode 100644 index 629edcc..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/pojo/returnFalseIfNotEqual.st +++ /dev/null @@ -1,41 +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 (has$f.capName$() != $target$.has$f.capName$()) return false; - $if (f.primitive)$ - if (has$f.capName$() && ($f.getter$() != $target$.$f.getter$())) return false; - $else$ - if (has$f.capName$() && !$f.getter$().equals($target$.$f.getter$())) return false; - $endif$ - -$elseif (f.repeated)$ - - if (!$f.getter$().equals($target$.$f.getter$())) return false; - -$else$ - - $if (f.primitive)$ - if ($f.getter$() != $target$.$f.getter$()) return false; - $else$ - if (!$f.getter$().equals($target$.$f.getter$())) return false; - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/beans.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/beans.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/beans.st deleted file mode 100644 index 9de0b91..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/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$() { - switchToProto(); - return proto.has$f.capName$(); - } - - @Override - public void clear$f.capName$() { - switchToProtoBuilder(); - protoBuilder.clear$f.capName$(); - } - -$endif$ - -$if (f.repeated)$ - - @Override - public List<$f.boxedJavaType$> $f.getter$() { - switchToProto(); - $if (f.message)$ - List<$f.javaType$> list = new ArrayList<$f.javaType$>(); - for (int i = 0; i < $f.getter$Size(); i++) { - $f.javaType$ message = new $f.javaType$(proto.$f.getter$(i)); - list.add(message); - } - return list; - $elseif (f.enum)$ - List<$f.javaType$> list = new ArrayList<$f.javaType$>(); - for (int i = 0; i < $f.getter$Size(); i++) { - $f.javaType$ enumValue = ProtoEnums.valOf(proto.$f.getter$(i).getNumber(), $f.javaType$.values()); - list.add(enumValue); - } - return list; - $elseif (f.blob)$ - List<$f.javaType$> list = new ArrayList<$f.javaType$>(); - for (int i = 0; i < $f.getter$Size(); i++) { - $f.javaType$ blob = new Blob(Codec.encode(proto.$f.getter$(i).toByteArray())); - list.add(blob); - } - return list; - $else$ - return Collections.unmodifiableList(proto.$f.getter$List()); - $endif$ - } - - $if (f.message)$ - @Override - public void addAll$f.capName$(List<? extends $f.messageType$> values) { - for ($f.messageType$ message : values) { - add$f.capName$(message); - } - } - $else$ - @Override - public void addAll$f.capName$(List<$f.boxedJavaType$> values) { - $if (f.enum)$ - for ($f.javaType$ enumValue : values) { - add$f.capName$(enumValue); - } - $elseif (f.blob)$ - for ($f.javaType$ blob : values) { - add$f.capName$(blob); - } - $else$ - switchToProtoBuilder(); - protoBuilder.addAll$f.capName$(values); - $endif$ - } - $endif$ - - @Override - public $f.javaType$ $f.getter$(int n) { - switchToProto(); - $if (f.message)$ - return new $f.javaType$(proto.$f.getter$(n)); - $elseif (f.enum)$ - return toPojoEnum$f.javaType$(proto.$f.getter$(n)); - $elseif (f.blob)$ - return new Blob(Codec.encode(proto.$f.getter$(n).toByteArray())); - $elseif (f.int52)$ - return Int52.int64to52(proto.$f.getter$(n)); - $else$ - return proto.$f.getter$(n); - $endif$ - } - - $if (f.message)$ - @Override - public void $f.setter$(int n, $f.messageType$ value) { - switchToProtoBuilder(); - protoBuilder.$f.setter$(n, getOrCreate$f.javaType$(value).getPB()); - } - $else$ - @Override - public void $f.setter$(int n, $f.javaType$ value) { - switchToProtoBuilder(); - $if (f.enum)$ - protoBuilder.$f.setter$(n, toProtoEnum$f.javaType$(value)); - $elseif (f.blob)$ - protoBuilder.$f.setter$(n, ByteString.copyFrom(Codec.decode(value.getData()))); - $else$ - protoBuilder.$f.setter$(n, value); - $endif$ - } - $endif$ - - @Override - public int $f.getter$Size() { - switchToProto(); - return proto.$f.getter$Count(); - } - - $if (f.message)$ - @Override - public void add$f.capName$($f.messageType$ value) { - switchToProtoBuilder(); - protoBuilder.add$f.capName$(getOrCreate$f.javaType$(value).getPB()); - } - $else$ - @Override - public void add$f.capName$($f.javaType$ value) { - switchToProtoBuilder(); - $if (f.enum)$ - protoBuilder.add$f.capName$(toProtoEnum$f.javaType$(value)); - $elseif (f.blob)$ - protoBuilder.add$f.capName$(ByteString.copyFrom(Codec.decode(value.getData()))); - $else$ - protoBuilder.add$f.capName$(value); - $endif$ - } - $endif$ - - @Override - public void clear$f.capName$() { - switchToProtoBuilder(); - protoBuilder.clear$f.capName$(); - } - -$else$ - - @Override - public $f.javaType$ $f.getter$() { - switchToProto(); - $if (f.message)$ - return new $f.javaType$(proto.$f.getter$()); - $elseif (f.enum)$ - return toPojoEnum$f.javaType$(proto.$f.getter$()); - $elseif (f.blob)$ - return new Blob(Codec.encode(proto.$f.getter$().toByteArray())); - $else$ - return proto.$f.getter$(); - $endif$ - } - - $if (f.message)$ - @Override - public void $f.setter$($f.messageType$ value) { - switchToProtoBuilder(); - protoBuilder.clear$f.capName$(); - protoBuilder.$f.setter$(getOrCreate$f.javaType$(value).getPB()); - } - $else$ - @Override - public void $f.setter$($f.javaType$ value) { - switchToProtoBuilder(); - $if (f.enum)$ - protoBuilder.$f.setter$(toProtoEnum$f.javaType$(value)); - $elseif (f.blob)$ - protoBuilder.$f.setter$(ByteString.copyFrom(Codec.decode(value.getData()))); - $elseif (f.int52)$ - protoBuilder.$f.setter$(Int52.int52to64(value)); - $else$ - protoBuilder.$f.setter$(value); - $endif$ - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/class.st deleted file mode 100644 index 4a0530f..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/class.st +++ /dev/null @@ -1,137 +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. - */ - -// NOTE(kalman): It would be nicer to add a proto serialisation -// utility rather than having this class at all. -public $if(m.inner)$static$endif$ final class $m.javaType$ - implements $m.name$, - // Note: fully-qualified path is required for GsonSerializable and ProtoWrapper. - // An import of it is not resolved correctly from inner classes. - // This appears to be a javac bug. The Eclipse compiler handles it fine. - org.waveprotocol.wave.communication.gson.GsonSerializable, - org.waveprotocol.wave.communication.proto.ProtoWrapper<$m.protoType$> { - - $m.nestedMessages: {nested|$class(m=nested)$}$ - - private $m.protoType$ proto = null; - private $m.protoType$.Builder protoBuilder = $m.protoType$.newBuilder(); - - public $m.javaType$() { - } - - public $m.javaType$($m.protoType$ proto) { - this.proto = proto; - } - - public $m.javaType$($m.name$ message) { - copyFrom(message); - } - - @Override - public $m.protoType$ getPB() { - switchToProto(); - return proto; - } - - @Override - public void setPB($m.protoType$ proto) { - this.proto = proto; - this.protoBuilder = null; - } - - @Override - public void copyFrom($m.name$ message) { - $m.fields: {f|$copyField(f=f, target="message")$}$ - } - - $m.fields: {f|$beans(m=m, f=f)$}$ - - $m.referencedMessages: {t|$messageHelpers(t=t)$}$ - $m.referencedEnums: {t|$enumHelpers(t=t)$}$ - - private void switchToProto() { - if (proto == null) { - proto = protoBuilder.build(); - protoBuilder = null; - } - } - - private void switchToProtoBuilder() { - if (protoBuilder == null) { - protoBuilder = (proto == null) - ? $m.protoType$.newBuilder() - : $m.protoType$.newBuilder(proto); - proto = null; - } - } - - private void invalidateAll() { - proto = null; - protoBuilder = $m.protoType$.newBuilder(); - } - - @Override - public JsonElement toGson(RawStringData raw, Gson gson) { - JsonObject json = new JsonObject(); - $m.fields: {f|$toGsonField(f=f, target="json")$}$ - return json; - } - - @Override - public void fromGson(JsonElement json, Gson gson, RawStringData raw) throws GsonException { - JsonObject jsonObject = json.getAsJsonObject(); - // NOTE: always check with has(...) as the json might not have all required - // fields set; however these (obviously) will need to be set by other means - // before accessing this object. - invalidateAll(); - $m.fields: {f|$fromGsonField(f=f, target="jsonObject")$}$ - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } else if (o instanceof $m.javaType$) { - return getPB().equals((($m.javaType$) o).getPB()); - } else { - return false; - } - } - - @Override - public boolean isEqualTo(Object o) { - if (equals(o)) { - return true; - } else if (o instanceof $m.name$) { - return $m.name$Util.isEqual(this, ($m.name$) o); - } else { - return false; - } - } - - @Override - public int hashCode() { - return getPB().hashCode(); - } - - @Override - public String toString() { - return getPB().toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/copyField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/copyField.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/copyField.st deleted file mode 100644 index 8dece10..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/copyField.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)$ - - clear$f.capName$(); - $if (f.message)$ - for ($f.messageType$ field : $target$.$f.getter$()) { - add$f.capName$(new $f.javaType$(field)); - } - $else$ - for ($f.javaType$ field : $target$.$f.getter$()) { - add$f.capName$(field); - } - $endif$ - -$else$ - - $if (f.optional)$ - if ($target$.has$f.capName$()) { - $endif$ - $if (f.message)$ - $f.setter$(new $f.javaType$($target$.$f.getter$())); - $else$ - $f.setter$($target$.$f.getter$()); - $endif$ - $if (f.optional)$ - } else { - clear$f.capName$(); - } - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/enumHelpers.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/enumHelpers.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/enumHelpers.st deleted file mode 100644 index 0b30e7b..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/enumHelpers.st +++ /dev/null @@ -1,28 +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. - */ - -/** Translates a pojo enum to a proto enum. */ -private $t.protoType$ toProtoEnum$t.javaType$($t.javaType$ value) { - return $t.protoType$.valueOf(value.getValue()); -} - -/** Translates a proto enum to a pojo enum. */ -private $t.javaType$ toPojoEnum$t.javaType$($t.protoType$ value) { - return ProtoEnums.valOf(value.getNumber(), $t.javaType$.values()); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/fromGsonField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/fromGsonField.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/fromGsonField.st deleted file mode 100644 index b92771e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/fromGsonField.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. - */ - -if ($target$.has("$f.number$")) { - JsonElement elem = $target$.get("$f.number$"); - - $if (f.optional)$ - if (!elem.isJsonNull()) { - $endif$ - - $if (f.repeated)$ - { - JsonArray array = elem.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, elem, gson, raw); - $f.setter$(payload); - } - $elseif (f.enum)$ - $f.setter$(ProtoEnums.valOf(elem.getAsInt(), $f.javaType$.values())); - $elseif (f.blob)$ - $f.setter$(new Blob(elem.getAsString())); - $elseif (f.long)$ - $f.setter$(GsonUtil.fromJson(elem)); - $else$ - $f.setter$(elem.getAs$f.capJavaType$()); - $endif$ - $endif$ - - $if (f.optional)$ - } - $endif$ -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/importUtil.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/importUtil.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/importUtil.st deleted file mode 100644 index 6459929..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/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/proto/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/imports.st deleted file mode 100644 index 72c228e..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/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/proto/messageHelpers.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/messageHelpers.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/messageHelpers.st deleted file mode 100644 index ed2ddbd..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/messageHelpers.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. - */ - -/** Get or create a $t.javaType$ from a $t.name$. */ -private $t.javaType$ getOrCreate$t.javaType$($t.name$ message) { - if (message instanceof $t.javaType$) { - return ($t.javaType$) message; - } else { - $t.javaType$ messageImpl = new $t.javaType$(); - messageImpl.copyFrom(message); - return messageImpl; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/properties b/wave/src/main/java/org/waveprotocol/pst/templates/proto/properties deleted file mode 100644 index 9d034c6..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/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 = ProtoImpl -package.suffix = proto http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/proto.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/proto.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/proto.st deleted file mode 100644 index e0f52f7..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/proto.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. - */ - -package $m.package$; - -$imports(m=m)$ - -import org.waveprotocol.wave.communication.Blob; -import org.waveprotocol.wave.communication.Codec; -import org.waveprotocol.wave.communication.ProtoEnums; -import org.waveprotocol.wave.communication.proto.Int52; -import org.waveprotocol.wave.communication.proto.ProtoWrapper; -import org.waveprotocol.wave.communication.gson.GsonException; -import org.waveprotocol.wave.communication.gson.GsonSerializable; -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; - -import com.google.protobuf.ByteString; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Server implementation of $m.name$. - * - * 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/proto/splitPoint.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/splitPoint.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/splitPoint.st deleted file mode 100644 index aa4caa6..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/splitPoint.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. - */ - -$!! - ! NOTE: template unused, since split points (aka multi-stage parsing) isn't - ! supported. If it is, some time, then this template could be used. - !$ - -((raw != null && gson != null) ? new JsonPrimitive(raw.addString(gson.toJson($e$))) : $e$) http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/proto/toGsonField.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/proto/toGsonField.st b/wave/src/main/java/org/waveprotocol/pst/templates/proto/toGsonField.st deleted file mode 100644 index 3bfa1a2..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/proto/toGsonField.st +++ /dev/null @@ -1,63 +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 (has$f.capName$()) { -$endif$ - - $if (f.repeated)$ - { - JsonArray array = new JsonArray(); - for (int i = 0; i < $f.getter$Size(); i++) { - $if (f.message)$ - JsonElement elem = ((GsonSerializable) $f.getter$(i)).toGson(raw, gson); - // NOTE(kalman): if multistage parsing worked, split point would go here. - array.add(elem); - $elseif (f.enum)$ - array.add(new JsonPrimitive($f.getter$(i).getValue())); - $elseif (f.blob)$ - array.add(new JsonPrimitive($f.getter$(i).getData())); - $elseif (f.long)$ - array.add(GsonUtil.toJson($f.getter$(i))); - $else$ - array.add(new JsonPrimitive($f.getter$(i))); - $endif$ - } - $target$.add("$f.number$", array); - } - $else$ - $if (f.message)$ - { - JsonElement elem = ((GsonSerializable) $f.getter$()).toGson(raw, gson); - $target$.add("$f.number$", elem); - } - $elseif (f.enum)$ - $target$.add("$f.number$", new JsonPrimitive($f.getter$().getValue())); - $elseif (f.blob)$ - $target$.add("$f.number$", new JsonPrimitive($f.getter$().getData())); - $elseif (f.long)$ - $target$.add("$f.number$", GsonUtil.toJson($f.getter$())); - $else$ - $target$.add("$f.number$", new JsonPrimitive($f.getter$())); - $endif$ - $endif$ - -$if (f.optional)$ -} -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/util/addHashCode.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/addHashCode.st b/wave/src/main/java/org/waveprotocol/pst/templates/util/addHashCode.st deleted file mode 100644 index 3bb6dc6..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/addHashCode.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. - */ - -$if (f.primitiveAndNotRepeated)$ - $if (f.optional)$ - $result$ = ($shift$ * $result$) + ($target$.has$f.capName$() ? $f.boxedJavaType$.valueOf($target$.$f.getter$()).hashCode() : 0); - $else$ - $result$ = ($shift$ * $result$) + $f.boxedJavaType$.valueOf($target$.$f.getter$()).hashCode(); - $endif$ -$else$ - $if (f.optional)$ - $result$ = ($shift$ * $result$) + ($target$.has$f.capName$() ? $target$.$f.getter$().hashCode() : 0); - $else$ - $result$ = ($shift$ * $result$) + $target$.$f.getter$().hashCode(); - $endif$ -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/util/class.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/class.st b/wave/src/main/java/org/waveprotocol/pst/templates/util/class.st deleted file mode 100644 index 078ae6f..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/class.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. - */ - -public $if(m.inner)$static$endif$ final class $m.javaType$ { - $m.nestedMessages: {nested|$class(m=nested)$}$ - - private $m.javaType$() {} - - /** Returns true if m1 and m2 are structurally equal. */ - public static boolean isEqual($m.name$ m1, $m.name$ m2) { - $m.fields: {f|$returnFalseIfNotEqual(f=f, target1="m1", target2="m2")$}$ - return true; - } - - /** Returns true if m1 and m2 are equal according to isEqual. */ - public static boolean areAllEqual(List<? extends $m.name$> m1, - List<? extends $m.name$> m2) { - if (m1.size() != m2.size()) return false; - Iterator<? extends $m.name$> i1 = m1.iterator(); - Iterator<? extends $m.name$> i2 = m2.iterator(); - while (i1.hasNext()) { - if (!isEqual(i1.next(), i2.next())) return false; - } - return true; - } - - /** Returns a structural hash code of message. */ - public static int getHashCode($m.name$ message) { - int result = 1; - $m.fields: {f|$addHashCode(f=f, shift="31", result="result", target="message")$}$ - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/util/imports.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/imports.st b/wave/src/main/java/org/waveprotocol/pst/templates/util/imports.st deleted file mode 100644 index 9894c5a..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/imports.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. - */ - -$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/util/properties ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/properties b/wave/src/main/java/org/waveprotocol/pst/templates/util/properties deleted file mode 100644 index 8a1b71a..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/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 = Util http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/util/returnFalseIfNotEqual.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/returnFalseIfNotEqual.st b/wave/src/main/java/org/waveprotocol/pst/templates/util/returnFalseIfNotEqual.st deleted file mode 100644 index f42b066..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/returnFalseIfNotEqual.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.optional)$ - - if ($target1$.has$f.capName$() != $target2$.has$f.capName$()) return false; - $if (f.primitive)$ - if ($target1$.has$f.capName$() && ($target1$.$f.getter$() != $target2$.$f.getter$())) return false; - $elseif (f.message)$ - if ($target1$.has$f.capName$() && !$f.javaType$.isEqual($target1$.$f.getter$(), $target2$.$f.getter$())) return false; - $else$ - if ($target1$.has$f.capName$() && !$target1$.$f.getter$().equals($target2$.$f.getter$())) return false; - $endif$ - -$elseif (f.repeated)$ - - $if (f.message)$ - if (!$f.javaType$.areAllEqual($target1$.$f.getter$(), $target2$.$f.getter$())) return false; - $else$ - if (!$target1$.$f.getter$().equals($target2$.$f.getter$())) return false; - $endif$ - -$else$ - - $if (f.primitive)$ - if ($target1$.$f.getter$() != $target2$.$f.getter$()) return false; - $elseif (f.message)$ - if (!$f.javaType$.isEqual($target1$.$f.getter$(), $target2$.$f.getter$())) return false; - $else$ - if (!$target1$.$f.getter$().equals($target2$.$f.getter$())) return false; - $endif$ - -$endif$ http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/pst/templates/util/util.st ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/pst/templates/util/util.st b/wave/src/main/java/org/waveprotocol/pst/templates/util/util.st deleted file mode 100644 index fa3d0dc..0000000 --- a/wave/src/main/java/org/waveprotocol/pst/templates/util/util.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. - */ - -package $m.package$; - -import $m.package$.$m.name$.*; - -$imports(m=m)$ - -import org.waveprotocol.wave.communication.Blob; - -import java.util.Iterator; -import java.util.List; - -/** - * Compares {@link $m.name$}s for equality. - * - * 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/wave/client/OptimalGroupingScheduler.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/wave/client/OptimalGroupingScheduler.java b/wave/src/main/java/org/waveprotocol/wave/client/OptimalGroupingScheduler.java deleted file mode 100644 index 0bb4511..0000000 --- a/wave/src/main/java/org/waveprotocol/wave/client/OptimalGroupingScheduler.java +++ /dev/null @@ -1,245 +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.wave.client; - -import org.waveprotocol.wave.client.scheduler.Scheduler.Task; -import org.waveprotocol.wave.client.scheduler.TimerService; -import org.waveprotocol.wave.model.util.FuzzingBackOffScheduler.Cancellable; -import org.waveprotocol.wave.model.util.FuzzingBackOffScheduler.CollectiveScheduler; -import org.waveprotocol.wave.model.util.Scheduler.Command; - -import java.util.Comparator; -import java.util.PriorityQueue; - -/** - * A fuzzy scheduler that attempts to executed as many of it's schedule task as - * possible. This scheduler is being given a list of tasks which should be - * executed between [minTime, targetTime], the aim of this task is to process - * all of them at the same time. - * - * Conceptually problem this class solves is: Given a list of ranges R = {[min, max]}, - * find a set of points P such that - * for_all([min, max] in R, exist(p in P, min <= p && p <= max)) and |P| is minimum. - * Or informally, we want the minimum number of points such that all ranges in R are covered. - * - * However, since we only need to schedule 1 task at a time, we only need the - * first point in P. - * - * The algorithm to solve this problem is straight forward, if we sort all the - * ranges by their max value, then the smallest max value is guaranteed to be in - * a optimal set of points P. - * - */ -public final class OptimalGroupingScheduler implements CollectiveScheduler { - /** - * A task that should be executed in at a time minTime <= t <= maxTime - * - */ - private class FuzzyTask implements Cancellable, Comparable<FuzzyTask> { - /** - * The command to be executed - */ - private Command command; - - /** - * The minimum time we are willing to execute this task - */ - final int minTime; - - /** - * The maximum time we are willing to execute this task - */ - final int maxTime; - - /** - * Each task is given a unique entry number, this is used as the final tie breaker - * when comparing tasks. - */ - final int entryNum; - - FuzzyTask(Command command, int minTime, int maxTime) { - this.command = command; - this.minTime = minTime; - this.maxTime = maxTime; - entryNum = numFuzzyTaskCreated++; - } - - @Override - public void cancel() { - if (command != null) { - command = null; - - allTasksOrderedByMinTime.remove(this); - scheduleTaskRunner(); - } - } - - @Override - public int compareTo(FuzzyTask o) { - // order by min time, tight break by min time - if (minTime != o.minTime) { - return minTime - o.minTime; - } - if (maxTime != o.maxTime) { - return maxTime - o.maxTime; - } - // all else failed, use entry number to tie break - return entryNum - o.entryNum; - } - - /** - * Execute the current task. - * - * @return true if the task has been executed, false otherwise. - */ - public boolean execute() { - assert command != null; - command.execute(); - command = null; - return true; - } - - /** - * @return is this task needed to be executed - */ - public boolean needToBeExecuted() { - return command != null; - } - - @Override - public String toString() { - return Integer.toString(entryNum); - } - } - - /** - * A comparator that order FuzzyTask by their max time. - */ - private static Comparator<FuzzyTask> MAX_TIME_COMPARATOR = new Comparator<FuzzyTask>() { - @Override - public int compare(FuzzyTask o1, FuzzyTask o2) { - // order by max time, tie break by min time - if (o1.maxTime != o2.maxTime) { - return o1.maxTime - o2.maxTime; - } - if (o1.minTime != o2.minTime) { - return o1.minTime - o2.minTime; - } - // all else failed, use entry number to tie break - return o1.entryNum - o2.entryNum; - } - }; - - /** - * The number of fuzzy task created. - */ - private static int numFuzzyTaskCreated = 0; - - /** - * A priority queue store all the tasks order max time. This queue is a - * superset of allTasksOrderedByMinTime. This list contains some - * cancelled/executed tasks because we want to avoid random access remove - * because it is an O(N) operation to remove anything that not at the head. - * Instead, we keep the task in the queue until it reaches the head, then we - * remove them. - */ - private final PriorityQueue<FuzzyTask> listByMaxTimes = - new PriorityQueue<FuzzyTask>(11, MAX_TIME_COMPARATOR); - - /** - * A priority queue of all the task ordered by start time. - */ - private final PriorityQueue<FuzzyTask> allTasksOrderedByMinTime = - new PriorityQueue<FuzzyTask>(); - - private final TimerService timerService; - private final Task commandRunner = new Task() { - @Override - public void execute() { - if (allTasksOrderedByMinTime.isEmpty()) { - return; - } - - isExecuting = true; - // set next scheduled time to 0 to disable scheduling - nextScheduledTime = 0; - int now = timerService.elapsedMillis(); - - while (!allTasksOrderedByMinTime.isEmpty() && - allTasksOrderedByMinTime.peek().minTime <= now) { - FuzzyTask task = allTasksOrderedByMinTime.poll(); - task.execute(); - } - isExecuting = false; - scheduleTaskRunner(); - } - }; - - /** - * A flag to indicate if we are in the middle of executing scheduled task. - */ - private boolean isExecuting = false; - - /** - * The time we are scheduled to run again. - */ - private int nextScheduledTime = Integer.MAX_VALUE; - - public OptimalGroupingScheduler(TimerService timerService) { - this.timerService = timerService; - } - - @Override - public Cancellable schedule(final Command command, int minAllowedTime, int targetTimeMs) { - targetTimeMs = Math.max(1, targetTimeMs); - minAllowedTime = Math.min(targetTimeMs, minAllowedTime); - int now = timerService.elapsedMillis(); - int minTime = minAllowedTime + now; - int maxTime = targetTimeMs + now; - - FuzzyTask task = new FuzzyTask(command, minTime, maxTime); - listByMaxTimes.offer(task); - allTasksOrderedByMinTime.offer(task); - scheduleTaskRunner(); - - return task; - } - - private void scheduleTaskRunner() { - cleanUpOrderByMaxTime(); - if (!isExecuting && !listByMaxTimes.isEmpty() && - nextScheduledTime != listByMaxTimes.peek().maxTime) { - nextScheduledTime = listByMaxTimes.peek().maxTime; - int delayTime = Math.max(1, - Math.round(nextScheduledTime - timerService.elapsedMillis())); - timerService.scheduleDelayed(commandRunner, delayTime); - } - } - - private void cleanUpOrderByMaxTime() { - // remove all executed/cancelled entry from the head of the queue - while (!listByMaxTimes.isEmpty() && - !listByMaxTimes.peek().needToBeExecuted()) { - listByMaxTimes.poll(); - } - assert allTasksOrderedByMinTime.size() <= listByMaxTimes.size(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/wave/client/StageOne.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/wave/client/StageOne.java b/wave/src/main/java/org/waveprotocol/wave/client/StageOne.java deleted file mode 100644 index 3cabf7d..0000000 --- a/wave/src/main/java/org/waveprotocol/wave/client/StageOne.java +++ /dev/null @@ -1,180 +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.wave.client; - -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; - -import org.waveprotocol.wave.client.common.util.AsyncHolder; -import org.waveprotocol.wave.client.common.util.LogicalPanel; -import org.waveprotocol.wave.client.scroll.ScrollBuilder; -import org.waveprotocol.wave.client.scroll.SmartScroller; -import org.waveprotocol.wave.client.wavepanel.event.FocusManager; -import org.waveprotocol.wave.client.wavepanel.impl.WavePanelImpl; -import org.waveprotocol.wave.client.wavepanel.impl.collapse.CollapseBuilder; -import org.waveprotocol.wave.client.wavepanel.impl.collapse.CollapsePresenter; -import org.waveprotocol.wave.client.wavepanel.impl.focus.FocusFrameBuilder; -import org.waveprotocol.wave.client.wavepanel.impl.focus.FocusFramePresenter; -import org.waveprotocol.wave.client.wavepanel.view.BlipView; -import org.waveprotocol.wave.client.wavepanel.view.dom.CssProvider; -import org.waveprotocol.wave.client.wavepanel.view.dom.FullStructure; -import org.waveprotocol.wave.client.wavepanel.view.dom.UpgradeableDomAsViewProvider; -import org.waveprotocol.wave.client.wavepanel.view.dom.full.WavePanelResourceLoader; - -/** - * The first stage of Undercurrent code. - * <p> - * This exposes minimal features required for basic reading interactions. - * - * @see StageZero - */ -public interface StageOne { - - /** @return the wave panel. */ - WavePanelImpl getWavePanel(); - - /** @return the focus feature. */ - FocusFramePresenter getFocusFrame(); - - /** @return the collapse feature. */ - CollapsePresenter getCollapser(); - - /** @return the provider of view objects from DOM elements. */ - UpgradeableDomAsViewProvider getDomAsViewProvider(); - - /** - * Default implementation of the stage one configuration. Each component is - * defined by a factory method, any of which may be overridden in order to - * stub out some dependencies. Circular dependencies are not detected. - * - */ - public static class DefaultProvider extends AsyncHolder.Impl<StageOne> implements StageOne { - private WavePanelImpl wavePanel; - private FocusFramePresenter focus; - private CollapsePresenter collapser; - private UpgradeableDomAsViewProvider views; - - public DefaultProvider(StageZero previous) { - // Nothing in stage one depends on anything in stage zero currently, but - // the dependency is wired up so that it is simple to add such - // dependencies should they be necessary in the future. - } - - @Override - protected final void create(Accessor<StageOne> whenReady) { - onStageInit(); - install(); - onStageLoaded(); - whenReady.use(this); - } - - /** Notifies this provider that the stage is about to be loaded. */ - protected void onStageInit() { - } - - /** Notifies this provider that the stage has been loaded. */ - protected void onStageLoaded() { - } - - @Override - public final WavePanelImpl getWavePanel() { - return wavePanel == null ? wavePanel = createWavePanel() : wavePanel; - } - - @Override - public final FocusFramePresenter getFocusFrame() { - return focus == null ? focus = createFocusPresenter() : focus; - } - - @Override - public final CollapsePresenter getCollapser() { - return collapser == null ? collapser = createCollapsePresenter() : collapser; - } - - @Override - public UpgradeableDomAsViewProvider getDomAsViewProvider() { - return views == null ? views = createViewProvider() : views; - } - - /** @return the container of the wave panel. Subclasses may override. */ - protected Element createWaveHolder() { - Element panel = Document.get().getElementById("initialHtml"); - if (panel == null) { - throw new RuntimeException("Page is malformed: no wave frame."); - } - return panel; - } - - /** - * @return the wave panel's (optional) logical parent. Subclasses may - * override. - */ - protected LogicalPanel createWaveContainer() { - return null; - } - - /** @return the interpreter of DOM elements as semantic views. */ - protected UpgradeableDomAsViewProvider createViewProvider() { - return new FullStructure(createCssProvider()); - } - - /** @return the wave panel. Subclasses may override. */ - protected WavePanelImpl createWavePanel() { - return WavePanelImpl.create( - getDomAsViewProvider(), createWaveHolder(), createWaveContainer()); - } - - /** @return the focus feature. Subclasses may override. */ - protected FocusFramePresenter createFocusPresenter() { - SmartScroller<? super BlipView> scroller = ScrollBuilder.install(getWavePanel()); - return FocusFrameBuilder.createAndInstallIn(getWavePanel(), scroller); - } - - /** @return the collapse feature. Subclasses may override. */ - protected CollapsePresenter createCollapsePresenter() { - return CollapseBuilder.createAndInstallIn(getWavePanel()); - } - - /** @return the source of CSS rules to apply in views. */ - protected CssProvider createCssProvider() { - return WavePanelResourceLoader.createCssProvider(); - } - - /** - * Installs parts of stage one that have dependencies. - * <p> - * This method is only called once all asynchronously loaded components of - * stage one are ready. - * <p> - * Subclasses may override this to change the set of installed features. - */ - protected void install() { - // Eagerly install some features. - getFocusFrame(); - getCollapser(); - - // Install wave panel into focus framework. - FocusManager focus = FocusManager.getRoot(); - focus.add(getWavePanel()); - focus.select(getWavePanel()); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/wave/client/StageThree.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/wave/client/StageThree.java b/wave/src/main/java/org/waveprotocol/wave/client/StageThree.java deleted file mode 100644 index 3cf79b4..0000000 --- a/wave/src/main/java/org/waveprotocol/wave/client/StageThree.java +++ /dev/null @@ -1,220 +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.wave.client; - -import com.google.gwt.core.client.GWT; -import org.waveprotocol.wave.client.account.ProfileManager; -import org.waveprotocol.wave.client.common.util.AsyncHolder; -import org.waveprotocol.wave.client.doodad.selection.SelectionExtractor; -import org.waveprotocol.wave.client.editor.EditorStaticDeps; -import org.waveprotocol.wave.client.scheduler.SchedulerInstance; -import org.waveprotocol.wave.client.scheduler.TimerService; -import org.waveprotocol.wave.client.util.ClientFlags; -import org.waveprotocol.wave.client.wave.DocumentRegistry; -import org.waveprotocol.wave.client.wave.InteractiveDocument; -import org.waveprotocol.wave.client.wave.WaveDocuments; -import org.waveprotocol.wave.client.wavepanel.impl.WavePanelImpl; -import org.waveprotocol.wave.client.wavepanel.impl.edit.Actions; -import org.waveprotocol.wave.client.wavepanel.impl.edit.ActionsImpl; -import org.waveprotocol.wave.client.wavepanel.impl.edit.EditController; -import org.waveprotocol.wave.client.wavepanel.impl.edit.EditSession; -import org.waveprotocol.wave.client.wavepanel.impl.edit.KeepFocusInView; -import org.waveprotocol.wave.client.wavepanel.impl.edit.ParticipantController; -import org.waveprotocol.wave.client.wavepanel.impl.edit.i18n.ParticipantMessages; -import org.waveprotocol.wave.client.wavepanel.impl.focus.FocusFramePresenter; -import org.waveprotocol.wave.client.wavepanel.impl.indicator.ReplyIndicatorController; -import org.waveprotocol.wave.client.wavepanel.impl.menu.MenuController; -import org.waveprotocol.wave.client.wavepanel.impl.menu.i18n.MenuMessages; -import org.waveprotocol.wave.client.wavepanel.impl.title.WaveTitleHandler; -import org.waveprotocol.wave.client.wavepanel.impl.toolbar.EditToolbar; -import org.waveprotocol.wave.client.wavepanel.impl.toolbar.ToolbarSwitcher; -import org.waveprotocol.wave.client.wavepanel.impl.toolbar.ViewToolbar; -import org.waveprotocol.wave.client.wavepanel.view.dom.ModelAsViewProvider; -import org.waveprotocol.wave.client.wavepanel.view.dom.full.BlipQueueRenderer; -import org.waveprotocol.wave.client.widget.popup.PopupChromeFactory; -import org.waveprotocol.wave.client.widget.popup.PopupFactory; -import org.waveprotocol.wave.model.conversation.ConversationView; -import org.waveprotocol.wave.model.wave.ParticipantId; - -/** - * The third stage of client code. - * <p> - * This stage includes editing capabilities. - * - */ -public interface StageThree { - - StageTwo getStageTwo(); - - Actions getEditActions(); - - EditToolbar getEditToolbar(); - - EditSession getEditSession(); - - ViewToolbar getViewToolbar(); - - /** - * Default implementation of the stage three configuration. Each component is - * defined by a factory method, any of which may be overridden in order to - * stub out some dependencies. Circular dependencies are not detected. - * - */ - public class DefaultProvider extends AsyncHolder.Impl<StageThree> implements StageThree { - // External dependencies - protected final StageTwo stageTwo; - - // - // Synchronously constructed dependencies. - // - - private Actions actions; - private EditSession edit; - private EditToolbar editToolbar; - private ViewToolbar viewToolbar; - - public DefaultProvider(StageTwo stageTwo) { - this.stageTwo = stageTwo; - } - - /** - * Creates the second stage. - */ - @Override - protected void create(final Accessor<StageThree> whenReady) { - onStageInit(); - if (ClientFlags.get().enableUndercurrentEditing()) { - install(); - } - onStageLoaded(); - whenReady.use(this); - } - - /** Notifies this provider that the stage is about to be loaded. */ - protected void onStageInit() { - } - - /** Notifies this provider that the stage has been loaded. */ - protected void onStageLoaded() { - } - - @Override - public final StageTwo getStageTwo() { - return stageTwo; - } - - @Override - public final Actions getEditActions() { - return actions == null ? actions = createEditActions() : actions; - } - - @Override - public final EditSession getEditSession() { - return edit == null ? edit = createEditSession() : edit; - } - - @Override - public final EditToolbar getEditToolbar() { - return editToolbar == null ? editToolbar = createEditToolbar() : editToolbar; - } - - @Override - public final ViewToolbar getViewToolbar() { - return viewToolbar == null ? viewToolbar = createViewToolbar() : viewToolbar; - } - - protected Actions createEditActions() { - StageOne stageOne = stageTwo.getStageOne(); - WavePanelImpl panel = stageOne.getWavePanel(); - FocusFramePresenter focus = stageOne.getFocusFrame(); - ModelAsViewProvider views = stageTwo.getModelAsViewProvider(); - WaveDocuments<? extends InteractiveDocument> docs = stageTwo.getDocumentRegistry(); - BlipQueueRenderer blipQueue = stageTwo.getBlipQueue(); - EditSession edit = getEditSession(); - return ActionsImpl.create(views, docs, blipQueue, focus, edit); - } - - protected EditSession createEditSession() { - StageOne stageOne = stageTwo.getStageOne(); - WavePanelImpl panel = stageOne.getWavePanel(); - FocusFramePresenter focus = stageOne.getFocusFrame(); - ModelAsViewProvider views = stageTwo.getModelAsViewProvider(); - DocumentRegistry<? extends InteractiveDocument> documents = stageTwo.getDocumentRegistry(); - String address = stageTwo.getSignedInUser().getAddress(); - TimerService clock = SchedulerInstance.getLowPriorityTimer(); - String sessionId = stageTwo.getSessionId(); - - SelectionExtractor selectionExtractor = new SelectionExtractor(clock, address, sessionId); - return EditSession.install(views, documents, selectionExtractor, focus, panel); - } - - protected EditToolbar createEditToolbar() { - return EditToolbar.create(getStageTwo().getSignedInUser(), stageTwo.getIdGenerator(), - stageTwo.getWave().getWaveId()); - } - - protected ViewToolbar createViewToolbar() { - ModelAsViewProvider views = stageTwo.getModelAsViewProvider(); - ConversationView wave = stageTwo.getConversations(); - return ViewToolbar.create(stageTwo.getStageOne().getFocusFrame(), views, wave, - stageTwo.getReader()); - } - - protected String getLocalDomain() { - return null; - } - - /** - * Installs parts of stage three that have dependencies. - * <p> - * This method is only called once all asynchronously loaded components of - * stage three are ready. - * <p> - * Subclasses may override this to change the set of installed features. - */ - protected void install() { - EditorStaticDeps.setPopupProvider(PopupFactory.getProvider()); - EditorStaticDeps.setPopupChromeProvider(PopupChromeFactory.getProvider()); - - // Eagerly install some features. - WavePanelImpl panel = stageTwo.getStageOne().getWavePanel(); - FocusFramePresenter focus = stageTwo.getStageOne().getFocusFrame(); - ParticipantId user = stageTwo.getSignedInUser(); - ModelAsViewProvider models = stageTwo.getModelAsViewProvider(); - ProfileManager profiles = stageTwo.getProfileManager(); - - MenuMessages menuMessages = GWT.create(MenuMessages.class); - ParticipantMessages participantMessages = GWT.create(ParticipantMessages.class); - - Actions actions = getEditActions(); - EditSession edit = getEditSession(); - MenuController.install(actions, panel, menuMessages); - ToolbarSwitcher.install(stageTwo.getStageOne().getWavePanel(), getEditSession(), - getViewToolbar(), getEditToolbar()); - WaveTitleHandler.install(edit, models); - ReplyIndicatorController.install(actions, edit, panel); - EditController.install(focus, actions, panel); - ParticipantController.install(panel, models, profiles, getLocalDomain(), user, participantMessages); - KeepFocusInView.install(edit, panel); - stageTwo.getDiffController().upgrade(edit); - } - } -}
