http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/entitystore-redis/src/docs/es-redis.txt ---------------------------------------------------------------------- diff --git a/extensions/entitystore-redis/src/docs/es-redis.txt b/extensions/entitystore-redis/src/docs/es-redis.txt index dae3644..11d1def 100644 --- a/extensions/entitystore-redis/src/docs/es-redis.txt +++ b/extensions/entitystore-redis/src/docs/es-redis.txt @@ -35,7 +35,7 @@ Assembly is done using the provided Assembler. [snippet,java] ---- -source=extensions/entitystore-redis/src/test/java/org/qi4j/entitystore/redis/RedisMapEntityStoreTest.java +source=extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java tag=assembly ---- @@ -46,6 +46,6 @@ Here are the configuration properties for the Redis client: [snippet,java] ---- -source=extensions/entitystore-redis/src/main/java/org/qi4j/entitystore/redis/RedisEntityStoreConfiguration.java +source=extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisEntityStoreConfiguration.java tag=config ----
http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/entitystore-riak/src/docs/es-riak.txt ---------------------------------------------------------------------- diff --git a/extensions/entitystore-riak/src/docs/es-riak.txt b/extensions/entitystore-riak/src/docs/es-riak.txt index 62e3cca..6ea2dc9 100644 --- a/extensions/entitystore-riak/src/docs/es-riak.txt +++ b/extensions/entitystore-riak/src/docs/es-riak.txt @@ -39,7 +39,7 @@ For HTTP based Riak client: [snippet,java] ---- -source=extensions/entitystore-riak/src/test/java/org/qi4j/entitystore/riak/RiakHttpMapEntityStoreTest.java +source=extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java tag=assembly ---- @@ -47,7 +47,7 @@ For ProtocolBuffer based Riak client: [snippet,java] ---- -source=extensions/entitystore-riak/src/test/java/org/qi4j/entitystore/riak/RiakProtobufMapEntityStoreTest.java +source=extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java tag=assembly ---- @@ -57,7 +57,7 @@ Here are the configuration properties for the HTTP based Riak client: [snippet,java] ---- -source=extensions/entitystore-riak/src/main/java/org/qi4j/entitystore/riak/RiakHttpEntityStoreConfiguration.java +source=extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakHttpEntityStoreConfiguration.java tag=config ---- @@ -65,6 +65,6 @@ Here are the configuration properties for the ProtocolBuffer based Riak client: [snippet,java] ---- -source=extensions/entitystore-riak/src/main/java/org/qi4j/entitystore/riak/RiakProtobufEntityStoreConfiguration.java +source=extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakProtobufEntityStoreConfiguration.java tag=config ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/entitystore-sql/src/docs/es-sql.txt ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/docs/es-sql.txt b/extensions/entitystore-sql/src/docs/es-sql.txt index caa2659..97807c0 100644 --- a/extensions/entitystore-sql/src/docs/es-sql.txt +++ b/extensions/entitystore-sql/src/docs/es-sql.txt @@ -66,7 +66,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/entitystore-sql/src/test/java/org/qi4j/entitystore/sql/PostgreSQLEntityStoreTest.java +source=extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java tag=assembly ---- @@ -86,7 +86,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/entitystore-sql/src/test/java/org/qi4j/entitystore/sql/MySQLEntityStoreTest.java +source=extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java tag=assembly ---- @@ -109,7 +109,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/entitystore-sql/src/test/java/org/qi4j/entitystore/sql/SQLiteEntityStoreTest.java +source=extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/SQLiteEntityStoreTest.java tag=assembly ---- @@ -129,7 +129,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/entitystore-sql/src/test/java/org/qi4j/entitystore/sql/H2SQLEntityStoreTest.java +source=extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/H2SQLEntityStoreTest.java tag=assembly ---- @@ -150,7 +150,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/entitystore-sql/src/test/java/org/qi4j/entitystore/sql/DerbySQLEntityStoreTest.java +source=extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt b/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt index bced084..8c2ccb1 100644 --- a/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt +++ b/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt @@ -53,7 +53,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/DocumentationSupport.java +source=extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java tag=memory ---- @@ -67,7 +67,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/DocumentationSupport.java +source=extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java tag=filesystem ---- @@ -80,7 +80,7 @@ Here are the configuration properties for both the in-memory and on-filesystem E [snippet,java] ---- -source=extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchConfiguration.java +source=extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchConfiguration.java tag=config ---- @@ -95,7 +95,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/DocumentationSupport.java +source=extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java tag=cluster ---- @@ -107,7 +107,7 @@ properties defined in the in-memory or on-filesystem configuration, see above. [snippet,java] ---- -source=extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchClusterConfiguration.java +source=extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchClusterConfiguration.java tag=config ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/indexing-rdf/src/docs/index-rdf.txt ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/docs/index-rdf.txt b/extensions/indexing-rdf/src/docs/index-rdf.txt index 620a071..7ef5f7e 100644 --- a/extensions/indexing-rdf/src/docs/index-rdf.txt +++ b/extensions/indexing-rdf/src/docs/index-rdf.txt @@ -35,7 +35,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-rdf/src/test/java/org/qi4j/index/rdf/DocumentationSupport.java +source=extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/DocumentationSupport.java tag=memory ---- @@ -49,7 +49,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-rdf/src/test/java/org/qi4j/index/rdf/DocumentationSupport.java +source=extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/DocumentationSupport.java tag=native ---- @@ -59,7 +59,7 @@ Here are the configuration properties for the Native RDF Index/Query: [snippet,java] ---- -source=libraries/rdf/src/main/java/org/qi4j/library/rdf/repository/NativeConfiguration.java +source=libraries/rdf/src/main/java/org/apache/zest/library/rdf/repository/NativeConfiguration.java tag=config ---- @@ -72,7 +72,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-rdf/src/test/java/org/qi4j/index/rdf/DocumentationSupport.java +source=extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/DocumentationSupport.java tag=rdbms ---- @@ -82,6 +82,6 @@ Here are the configuration properties for the RDBMS based RDF Index/Query: [snippet,java] ---- -source=libraries/rdf/src/main/java/org/qi4j/library/rdf/repository/RdbmsRepositoryConfiguration.java +source=libraries/rdf/src/main/java/org/apache/zest/library/rdf/repository/RdbmsRepositoryConfiguration.java tag=config ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/indexing-solr/src/docs/index-solr.txt ---------------------------------------------------------------------- diff --git a/extensions/indexing-solr/src/docs/index-solr.txt b/extensions/indexing-solr/src/docs/index-solr.txt index e964831..f2183ac 100644 --- a/extensions/indexing-solr/src/docs/index-solr.txt +++ b/extensions/indexing-solr/src/docs/index-solr.txt @@ -37,7 +37,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-solr/src/test/java/org/qi4j/index/solr/SolrQueryServiceTest.java +source=extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/indexing-sql/src/docs/index-sql.txt ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/docs/index-sql.txt b/extensions/indexing-sql/src/docs/index-sql.txt index 5d6fc57..81980c1 100644 --- a/extensions/indexing-sql/src/docs/index-sql.txt +++ b/extensions/indexing-sql/src/docs/index-sql.txt @@ -55,7 +55,7 @@ Assembly is done using the provided Assembler: [snippet,java] ---- -source=extensions/indexing-sql/src/test/java/org/qi4j/index/sql/postgresql/SQLTestHelper.java +source=extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/valueserialization-jackson/src/docs/vs-jackson.txt ---------------------------------------------------------------------- diff --git a/extensions/valueserialization-jackson/src/docs/vs-jackson.txt b/extensions/valueserialization-jackson/src/docs/vs-jackson.txt index 898a8d7..ee7b4f2 100644 --- a/extensions/valueserialization-jackson/src/docs/vs-jackson.txt +++ b/extensions/valueserialization-jackson/src/docs/vs-jackson.txt @@ -35,7 +35,7 @@ Assembly is done as follows: [snippet,java] ---- -source=extensions/valueserialization-jackson/src/test/java/org/qi4j/valueserialization/jackson/JacksonPlainValueSerializationTest.java +source=extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonPlainValueSerializationTest.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/valueserialization-orgjson/src/docs/vs-orgjson.txt ---------------------------------------------------------------------- diff --git a/extensions/valueserialization-orgjson/src/docs/vs-orgjson.txt b/extensions/valueserialization-orgjson/src/docs/vs-orgjson.txt index a893ac0..b307f15 100644 --- a/extensions/valueserialization-orgjson/src/docs/vs-orgjson.txt +++ b/extensions/valueserialization-orgjson/src/docs/vs-orgjson.txt @@ -35,7 +35,7 @@ Assembly is done as follows: [snippet,java] ---- -source=extensions/valueserialization-orgjson/src/test/java/org/qi4j/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java +source=extensions/valueserialization-orgjson/src/test/java/org/apache/zest/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/extensions/valueserialization-stax/src/docs/vs-stax.txt ---------------------------------------------------------------------- diff --git a/extensions/valueserialization-stax/src/docs/vs-stax.txt b/extensions/valueserialization-stax/src/docs/vs-stax.txt index 7302a47..b65df68 100644 --- a/extensions/valueserialization-stax/src/docs/vs-stax.txt +++ b/extensions/valueserialization-stax/src/docs/vs-stax.txt @@ -35,7 +35,7 @@ Assembly is done as follows: [snippet,java] ---- -source=extensions/valueserialization-stax/src/test/java/org/qi4j/valueserialization/stax/StaxPlainValueSerializationTest.java +source=extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxPlainValueSerializationTest.java tag=assembly ---- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/alarm/src/docs/alarm.txt ---------------------------------------------------------------------- diff --git a/libraries/alarm/src/docs/alarm.txt b/libraries/alarm/src/docs/alarm.txt index c0c7a59..0147289 100644 --- a/libraries/alarm/src/docs/alarm.txt +++ b/libraries/alarm/src/docs/alarm.txt @@ -73,7 +73,7 @@ provide an _Identity_ of the Alarm, which must survive restarts. The code could [snippet,java] -------------- -source=libraries/alarm/src/test/java/org/qi4j/library/alarm/AlarmProxyTest.java +source=libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java tag=documentation -------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java new file mode 100644 index 0000000..de290c8 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java @@ -0,0 +1,109 @@ +/* + * 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.apache.zest.library.appbrowser; + +import java.util.Stack; +import org.json.JSONException; +import org.apache.zest.api.structure.ApplicationDescriptor; +import org.apache.zest.functional.HierarchicalVisitor; + +public class Browser +{ + private final ApplicationDescriptor application; + private final FormatterFactory factory; + private final Stack<Formatter> stack = new Stack<>(); + + public Browser( ApplicationDescriptor application, FormatterFactory factory ) + { + this.application = application; + this.factory = factory; + } + + public void toJson() + throws BrowserException + { + application.accept( new HierarchicalVisitor<Object, Object, BrowserException>() + { + @Override + public boolean visitEnter( Object visited ) + throws BrowserException + { + String simpleName = visited.getClass().getSimpleName(); + Formatter formatter = factory.create( simpleName ); + stack.push(formatter); + if( formatter == null ) + { + System.err.println( "Unknown application component: " + visited.getClass() ); + return false; + } + try + { + formatter.enter( visited ); + } + catch( JSONException e ) + { + throw new BrowserException( "Formatting failed.", e ); + } + return true; + } + + @Override + public boolean visitLeave( Object visited ) + throws BrowserException + { + Formatter formatter = stack.pop(); + if( formatter == null ) + { + System.err.println( "Unknown application component: " + visited.getClass() ); + return false; + } + try + { + formatter.leave( visited ); + } + catch( JSONException e ) + { + throw new BrowserException( "Formatting failed.", e ); + } + return true; + } + + @Override + public boolean visit( Object visited ) + throws BrowserException + { + Formatter formatter = stack.peek(); + if( formatter == null ) + { + System.err.println( "Unknown application component: " + visited.getClass() ); + return false; + } + try + { + formatter.visit( visited ); + } + catch( JSONException e ) + { + throw new BrowserException( "Formatting failed.", e ); + } + return true; + } + } ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/BrowserException.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/BrowserException.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/BrowserException.java new file mode 100644 index 0000000..52c4013 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/BrowserException.java @@ -0,0 +1,29 @@ +/* + * 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.apache.zest.library.appbrowser; + +import org.json.JSONException; + +public class BrowserException extends RuntimeException +{ + public BrowserException( String message, JSONException exception ) + { + super( message, exception); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Formatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Formatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Formatter.java new file mode 100644 index 0000000..efa5e33 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Formatter.java @@ -0,0 +1,34 @@ +/* + * 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.apache.zest.library.appbrowser; + +import org.json.JSONException; + +public interface Formatter<NODE, LEAF> +{ + + void enter( NODE visited ) + throws JSONException; + + void leave( NODE visited ) + throws JSONException; + + void visit( LEAF visited ) + throws JSONException; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/FormatterFactory.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/FormatterFactory.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/FormatterFactory.java new file mode 100644 index 0000000..923fc9c --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/FormatterFactory.java @@ -0,0 +1,25 @@ +/* + * 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.apache.zest.library.appbrowser; + +public interface FormatterFactory +{ + + Formatter create( String componentType ); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/AbstractJsonFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/AbstractJsonFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/AbstractJsonFormatter.java new file mode 100644 index 0000000..b9ebc80 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/AbstractJsonFormatter.java @@ -0,0 +1,85 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.library.appbrowser.Formatter; + +public abstract class AbstractJsonFormatter<NODE,LEAF> + implements Formatter<NODE, LEAF> +{ + private final JSONWriter writer; + + public AbstractJsonFormatter( JSONWriter writer ) + { + this.writer = writer; + } + + protected void field( String name, String value ) + throws JSONException + { + writer.key( name ).value(value); + } + + protected void field( String name, boolean value ) + throws JSONException + { + writer.key( name ).value(value); + } + + protected void array( String name ) + throws JSONException + { + writer.key(name); + writer.array(); + } + + protected void endArray() + throws JSONException + { + writer.endArray(); + } + + protected void object() + throws JSONException + { + writer.object(); + } + + protected void object(String name) + throws JSONException + { + writer.key(name); + writer.object(); + } + + protected void endObject() + throws JSONException + { + writer.endObject(); + } + + protected void value( Object value ) + throws JSONException + { + writer.value( value ); + } + +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ApplicationModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ApplicationModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ApplicationModelFormatter.java new file mode 100644 index 0000000..e38d845 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ApplicationModelFormatter.java @@ -0,0 +1,56 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.structure.ApplicationDescriptor; +import org.apache.zest.library.appbrowser.Formatter; + +public class ApplicationModelFormatter extends AbstractJsonFormatter<ApplicationDescriptor, Void> +{ + + public ApplicationModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( ApplicationDescriptor visited ) + throws JSONException + { + object(); + field( "name", visited.name() ); + array("layers"); + } + + @Override + public void leave( ApplicationDescriptor visited ) + throws JSONException + { + endArray(); + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ArrayFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ArrayFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ArrayFormatter.java new file mode 100644 index 0000000..aff860e --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ArrayFormatter.java @@ -0,0 +1,56 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.library.appbrowser.Formatter; + +public class ArrayFormatter extends AbstractJsonFormatter + implements Formatter +{ + private final String name; + + public ArrayFormatter( JSONWriter writer, String name ) + { + super(writer); + this.name = name; + } + + @Override + public void enter( Object visited ) + throws JSONException + { + array(name); + } + + @Override + public void leave( Object visited ) + throws JSONException + { + endArray(); + } + + @Override + public void visit( Object visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/CompositeMethodModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/CompositeMethodModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/CompositeMethodModelFormatter.java new file mode 100644 index 0000000..bdbc093 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/CompositeMethodModelFormatter.java @@ -0,0 +1,54 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.composite.MethodDescriptor; +import org.apache.zest.library.appbrowser.Formatter; + +public class CompositeMethodModelFormatter extends AbstractJsonFormatter<MethodDescriptor, Void> +{ + public CompositeMethodModelFormatter( JSONWriter writer ) + { + super(writer); + } + + @Override + public void enter( MethodDescriptor visited ) + throws JSONException + { + object(); + field("method", visited.method().getName() ); + } + + @Override + public void leave( MethodDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ConstructorModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ConstructorModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ConstructorModelFormatter.java new file mode 100644 index 0000000..4cdaa81 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ConstructorModelFormatter.java @@ -0,0 +1,53 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.composite.ConstructorDescriptor; + +public class ConstructorModelFormatter extends AbstractJsonFormatter<ConstructorDescriptor,Void> +{ + public ConstructorModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( ConstructorDescriptor visited ) + throws JSONException + { + object(); + field( "name", visited.constructor().getName() ); + } + + @Override + public void leave( ConstructorDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/EntityModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/EntityModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/EntityModelFormatter.java new file mode 100644 index 0000000..2cbfb3f --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/EntityModelFormatter.java @@ -0,0 +1,56 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.entity.EntityDescriptor; + +public class EntityModelFormatter extends AbstractJsonFormatter<EntityDescriptor, Void> +{ + + public EntityModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( EntityDescriptor visited ) + throws JSONException + { + object(); + field( "type", visited.primaryType().getName() ); + field( "visibility", visited.visibility().toString() ); + field( "queryable", visited.queryable() ); + } + + @Override + public void leave( EntityDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/InjectedFieldModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/InjectedFieldModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/InjectedFieldModelFormatter.java new file mode 100644 index 0000000..5f20163 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/InjectedFieldModelFormatter.java @@ -0,0 +1,60 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.composite.DependencyDescriptor; +import org.apache.zest.api.composite.InjectedFieldDescriptor; +import org.apache.zest.library.appbrowser.Formatter; + +public class InjectedFieldModelFormatter extends AbstractJsonFormatter<InjectedFieldDescriptor, DependencyDescriptor> +{ + public InjectedFieldModelFormatter( JSONWriter writer ) + { + super(writer); + } + + @Override + public void enter( InjectedFieldDescriptor visited ) + throws JSONException + { + object(); + field("name", visited.field().getName() ); +// field( "optional", visited.optional() ); +// field( "injectedclass", visited.injectedClass().getName() ); +// field( "injectedannotation", visited.injectionAnnotation().toString() ); +// field( "injectedtype", visited.injectionType().toString() ); +// field( "rawinjectectiontype", visited.rawInjectionType().getName() ); + } + + @Override + public void leave( InjectedFieldDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( DependencyDescriptor visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/JsonFormatterFactory.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/JsonFormatterFactory.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/JsonFormatterFactory.java new file mode 100644 index 0000000..b0d3e48 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/JsonFormatterFactory.java @@ -0,0 +1,107 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import java.io.Writer; +import org.json.JSONWriter; +import org.apache.zest.library.appbrowser.Formatter; +import org.apache.zest.library.appbrowser.FormatterFactory; + +public class JsonFormatterFactory + implements FormatterFactory +{ + private static final NullFormatter NULL_FORMATTER = new NullFormatter(); + private final JSONWriter writer; + + public JsonFormatterFactory(Writer destination) + { + writer = new JSONWriter( destination ); + } + + @Override + public Formatter create( String componentType ) + { + if( componentType.equalsIgnoreCase( "ApplicationModel" )) + return new ApplicationModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "LayerModel" )) + return new LayerModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "ModuleModel" )) + return new ModuleModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "TransientsModel" )) + return new ArrayFormatter(writer, "transients"); + if( componentType.equalsIgnoreCase( "EntitiesModel" )) + return new ArrayFormatter(writer, "entities"); + if( componentType.equalsIgnoreCase( "ServicesModel" )) + return new ArrayFormatter(writer, "services"); + if( componentType.equalsIgnoreCase( "ServiceModel" )) + return new ServiceModelFormatter + (writer); + if( componentType.equalsIgnoreCase( "ValuesModel" )) + return new ArrayFormatter(writer, "values"); + if( componentType.equalsIgnoreCase( "ValueModel" )) + return new ValueModelFormatter(writer); + if( componentType.equalsIgnoreCase( "ValueStateModel" )) + return NULL_FORMATTER; + if( componentType.equalsIgnoreCase( "EntityModel" )) + return new EntityModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "CompositeMethodsModel" )) + return new ArrayFormatter( writer, "methods" ); + if( componentType.equalsIgnoreCase( "CompositeMethodModel" )) + return new CompositeMethodModelFormatter(writer); + if( componentType.equalsIgnoreCase( "ObjectsModel" )) + return new ArrayFormatter( writer, "objects" ); + if( componentType.equalsIgnoreCase( "ConstraintsModel" )) + return new ArrayFormatter( writer, "constraints" ); + if( componentType.equalsIgnoreCase( "SideEffectsModel" )) + return new ArrayFormatter( writer, "sideeffects" ); + if( componentType.equalsIgnoreCase( "ConcernsModel" )) + return new ArrayFormatter( writer, "concerns" ); + if( componentType.equalsIgnoreCase( "PropertiesModel" )) + return new ArrayFormatter( writer, "properties" ); + if( componentType.equalsIgnoreCase( "ConstructorsModel" )) + return new ArrayFormatter( writer, "constructors" ); + if( componentType.equalsIgnoreCase( "ConstructorModel" )) + return new ConstructorModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "EntityMixinsModel" )) + return new ArrayFormatter( writer, "mixins" ); + if( componentType.equalsIgnoreCase( "MixinsModel" )) + return new ArrayFormatter( writer, "mixins" ); + if( componentType.equalsIgnoreCase( "MixinModel" )) + return new MixinModelFormatter( writer ); + if( componentType.equalsIgnoreCase( "AssociationsModel" )) + return new ArrayFormatter( writer, "associations" ); + if( componentType.equalsIgnoreCase( "ManyAssociationsModel" )) + return new ArrayFormatter( writer, "manyassociations" ); + if( componentType.equalsIgnoreCase( "InjectedFieldsModel" )) + return new ArrayFormatter( writer, "injectedfields" ); + if( componentType.equalsIgnoreCase( "InjectedFieldModel" )) + return new InjectedFieldModelFormatter(writer); + if( componentType.equalsIgnoreCase( "InjectedMethodsModel" )) + return new ArrayFormatter( writer, "injectedmethods" ); + if( componentType.equalsIgnoreCase( "InjectedParametersModel" )) + return new ArrayFormatter( writer, "injectedparameters" ); + if( componentType.equalsIgnoreCase( "EntityStateModel" )) + return NULL_FORMATTER; + if( componentType.equalsIgnoreCase( "ObjectModel" )) + return new ObjectModelFormatter(writer); + if( componentType.equalsIgnoreCase( "ImportedServicesModel" )) + return NULL_FORMATTER; + return null; + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/LayerModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/LayerModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/LayerModelFormatter.java new file mode 100644 index 0000000..c53f8dd --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/LayerModelFormatter.java @@ -0,0 +1,62 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.structure.LayerDescriptor; +import org.apache.zest.api.structure.UsedLayersDescriptor; + +public class LayerModelFormatter extends AbstractJsonFormatter<LayerDescriptor, Void> +{ + public LayerModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( LayerDescriptor visited ) + throws JSONException + { + object(); + field( "name", visited.name() ); + array( "uses" ); + UsedLayersDescriptor usedLayersDescriptor = visited.usedLayers(); + for( LayerDescriptor used : usedLayersDescriptor.layers() ) + { + value( used.name() ); + } + endArray(); + array( "modules" ); + } + + @Override + public void leave( LayerDescriptor visited ) + throws JSONException + { + endArray(); + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/MixinModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/MixinModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/MixinModelFormatter.java new file mode 100644 index 0000000..d9e1ce8 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/MixinModelFormatter.java @@ -0,0 +1,53 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.mixin.MixinDescriptor; + +public class MixinModelFormatter extends AbstractJsonFormatter<MixinDescriptor, Void> +{ + public MixinModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( MixinDescriptor visited ) + throws JSONException + { + object(); + field( "mixin", visited.mixinClass().getName() ); + } + + @Override + public void leave( MixinDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ModuleModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ModuleModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ModuleModelFormatter.java new file mode 100644 index 0000000..8adff0a --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ModuleModelFormatter.java @@ -0,0 +1,54 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.structure.ModuleDescriptor; +import org.apache.zest.library.appbrowser.Formatter; + +public class ModuleModelFormatter extends AbstractJsonFormatter<ModuleDescriptor, Void> +{ + + public ModuleModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( ModuleDescriptor visited ) + throws JSONException + { + object(); + field( "name", visited.name() ); + } + + @Override + public void leave( ModuleDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/NullFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/NullFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/NullFormatter.java new file mode 100644 index 0000000..3f851de --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/NullFormatter.java @@ -0,0 +1,48 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.library.appbrowser.Formatter; + +public class NullFormatter + implements Formatter<Object, Object> +{ + @Override + public void enter( Object visited ) + throws JSONException + { + + } + + @Override + public void leave( Object visited ) + throws JSONException + { + + } + + @Override + public void visit( Object visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ObjectModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ObjectModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ObjectModelFormatter.java new file mode 100644 index 0000000..e259c56 --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ObjectModelFormatter.java @@ -0,0 +1,53 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.object.ObjectDescriptor; + +public class ObjectModelFormatter extends AbstractJsonFormatter<ObjectDescriptor, Void> +{ + public ObjectModelFormatter( JSONWriter writer ) + { + super(writer); + } + + @Override + public void enter( ObjectDescriptor visited ) + throws JSONException + { + object(); + field( "visibility", visited.visibility().toString()); + } + + @Override + public void leave( ObjectDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ServiceModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ServiceModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ServiceModelFormatter.java new file mode 100644 index 0000000..7ac39ef --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ServiceModelFormatter.java @@ -0,0 +1,61 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.service.ServiceDescriptor; + +public class ServiceModelFormatter extends AbstractJsonFormatter<ServiceDescriptor, Void> +{ + public ServiceModelFormatter( JSONWriter writer ) + { + super( writer ); + } + + @Override + public void enter( ServiceDescriptor visited ) + throws JSONException + { + object(); + field( "identity", visited.identity() ); + field( "type", visited.primaryType().getName() ); + field( "visibility", visited.visibility().toString() ); + Class<Object> config = visited.configurationType(); + if( config != null ) + { + field( "configuration", config.getName() ); + } + field( "instantiateOnStartup", visited.isInstantiateOnStartup() ); + } + + @Override + public void leave( ServiceDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ValueModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ValueModelFormatter.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ValueModelFormatter.java new file mode 100644 index 0000000..411b82b --- /dev/null +++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/json/ValueModelFormatter.java @@ -0,0 +1,55 @@ +/* + * 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.apache.zest.library.appbrowser.json; + +import org.json.JSONException; +import org.json.JSONWriter; +import org.apache.zest.api.value.ValueDescriptor; +import org.apache.zest.library.appbrowser.Formatter; + +public class ValueModelFormatter extends AbstractJsonFormatter<ValueDescriptor,Void> +{ + public ValueModelFormatter( JSONWriter writer ) + { + super(writer); + } + + @Override + public void enter( ValueDescriptor visited ) + throws JSONException + { + object(); + field( "type", visited.valueType().mainType().getName() ); + field( "visibility", visited.visibility().toString() ); + } + + @Override + public void leave( ValueDescriptor visited ) + throws JSONException + { + endObject(); + } + + @Override + public void visit( Void visited ) + throws JSONException + { + + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Browser.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Browser.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Browser.java deleted file mode 100644 index de290c8..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Browser.java +++ /dev/null @@ -1,109 +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.apache.zest.library.appbrowser; - -import java.util.Stack; -import org.json.JSONException; -import org.apache.zest.api.structure.ApplicationDescriptor; -import org.apache.zest.functional.HierarchicalVisitor; - -public class Browser -{ - private final ApplicationDescriptor application; - private final FormatterFactory factory; - private final Stack<Formatter> stack = new Stack<>(); - - public Browser( ApplicationDescriptor application, FormatterFactory factory ) - { - this.application = application; - this.factory = factory; - } - - public void toJson() - throws BrowserException - { - application.accept( new HierarchicalVisitor<Object, Object, BrowserException>() - { - @Override - public boolean visitEnter( Object visited ) - throws BrowserException - { - String simpleName = visited.getClass().getSimpleName(); - Formatter formatter = factory.create( simpleName ); - stack.push(formatter); - if( formatter == null ) - { - System.err.println( "Unknown application component: " + visited.getClass() ); - return false; - } - try - { - formatter.enter( visited ); - } - catch( JSONException e ) - { - throw new BrowserException( "Formatting failed.", e ); - } - return true; - } - - @Override - public boolean visitLeave( Object visited ) - throws BrowserException - { - Formatter formatter = stack.pop(); - if( formatter == null ) - { - System.err.println( "Unknown application component: " + visited.getClass() ); - return false; - } - try - { - formatter.leave( visited ); - } - catch( JSONException e ) - { - throw new BrowserException( "Formatting failed.", e ); - } - return true; - } - - @Override - public boolean visit( Object visited ) - throws BrowserException - { - Formatter formatter = stack.peek(); - if( formatter == null ) - { - System.err.println( "Unknown application component: " + visited.getClass() ); - return false; - } - try - { - formatter.visit( visited ); - } - catch( JSONException e ) - { - throw new BrowserException( "Formatting failed.", e ); - } - return true; - } - } ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/BrowserException.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/BrowserException.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/BrowserException.java deleted file mode 100644 index 52c4013..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/BrowserException.java +++ /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. - */ -package org.apache.zest.library.appbrowser; - -import org.json.JSONException; - -public class BrowserException extends RuntimeException -{ - public BrowserException( String message, JSONException exception ) - { - super( message, exception); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Formatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Formatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Formatter.java deleted file mode 100644 index efa5e33..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/Formatter.java +++ /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. - */ -package org.apache.zest.library.appbrowser; - -import org.json.JSONException; - -public interface Formatter<NODE, LEAF> -{ - - void enter( NODE visited ) - throws JSONException; - - void leave( NODE visited ) - throws JSONException; - - void visit( LEAF visited ) - throws JSONException; -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/FormatterFactory.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/FormatterFactory.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/FormatterFactory.java deleted file mode 100644 index 923fc9c..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/FormatterFactory.java +++ /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. - */ -package org.apache.zest.library.appbrowser; - -public interface FormatterFactory -{ - - Formatter create( String componentType ); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/AbstractJsonFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/AbstractJsonFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/AbstractJsonFormatter.java deleted file mode 100644 index b9ebc80..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/AbstractJsonFormatter.java +++ /dev/null @@ -1,85 +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.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.library.appbrowser.Formatter; - -public abstract class AbstractJsonFormatter<NODE,LEAF> - implements Formatter<NODE, LEAF> -{ - private final JSONWriter writer; - - public AbstractJsonFormatter( JSONWriter writer ) - { - this.writer = writer; - } - - protected void field( String name, String value ) - throws JSONException - { - writer.key( name ).value(value); - } - - protected void field( String name, boolean value ) - throws JSONException - { - writer.key( name ).value(value); - } - - protected void array( String name ) - throws JSONException - { - writer.key(name); - writer.array(); - } - - protected void endArray() - throws JSONException - { - writer.endArray(); - } - - protected void object() - throws JSONException - { - writer.object(); - } - - protected void object(String name) - throws JSONException - { - writer.key(name); - writer.object(); - } - - protected void endObject() - throws JSONException - { - writer.endObject(); - } - - protected void value( Object value ) - throws JSONException - { - writer.value( value ); - } - -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ApplicationModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ApplicationModelFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ApplicationModelFormatter.java deleted file mode 100644 index e38d845..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ApplicationModelFormatter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.api.structure.ApplicationDescriptor; -import org.apache.zest.library.appbrowser.Formatter; - -public class ApplicationModelFormatter extends AbstractJsonFormatter<ApplicationDescriptor, Void> -{ - - public ApplicationModelFormatter( JSONWriter writer ) - { - super( writer ); - } - - @Override - public void enter( ApplicationDescriptor visited ) - throws JSONException - { - object(); - field( "name", visited.name() ); - array("layers"); - } - - @Override - public void leave( ApplicationDescriptor visited ) - throws JSONException - { - endArray(); - endObject(); - } - - @Override - public void visit( Void visited ) - throws JSONException - { - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ArrayFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ArrayFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ArrayFormatter.java deleted file mode 100644 index aff860e..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ArrayFormatter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.library.appbrowser.Formatter; - -public class ArrayFormatter extends AbstractJsonFormatter - implements Formatter -{ - private final String name; - - public ArrayFormatter( JSONWriter writer, String name ) - { - super(writer); - this.name = name; - } - - @Override - public void enter( Object visited ) - throws JSONException - { - array(name); - } - - @Override - public void leave( Object visited ) - throws JSONException - { - endArray(); - } - - @Override - public void visit( Object visited ) - throws JSONException - { - - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/CompositeMethodModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/CompositeMethodModelFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/CompositeMethodModelFormatter.java deleted file mode 100644 index bdbc093..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/CompositeMethodModelFormatter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.api.composite.MethodDescriptor; -import org.apache.zest.library.appbrowser.Formatter; - -public class CompositeMethodModelFormatter extends AbstractJsonFormatter<MethodDescriptor, Void> -{ - public CompositeMethodModelFormatter( JSONWriter writer ) - { - super(writer); - } - - @Override - public void enter( MethodDescriptor visited ) - throws JSONException - { - object(); - field("method", visited.method().getName() ); - } - - @Override - public void leave( MethodDescriptor visited ) - throws JSONException - { - endObject(); - } - - @Override - public void visit( Void visited ) - throws JSONException - { - - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ConstructorModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ConstructorModelFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ConstructorModelFormatter.java deleted file mode 100644 index 4cdaa81..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/ConstructorModelFormatter.java +++ /dev/null @@ -1,53 +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.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.api.composite.ConstructorDescriptor; - -public class ConstructorModelFormatter extends AbstractJsonFormatter<ConstructorDescriptor,Void> -{ - public ConstructorModelFormatter( JSONWriter writer ) - { - super( writer ); - } - - @Override - public void enter( ConstructorDescriptor visited ) - throws JSONException - { - object(); - field( "name", visited.constructor().getName() ); - } - - @Override - public void leave( ConstructorDescriptor visited ) - throws JSONException - { - endObject(); - } - - @Override - public void visit( Void visited ) - throws JSONException - { - - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/EntityModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/EntityModelFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/EntityModelFormatter.java deleted file mode 100644 index 2cbfb3f..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/EntityModelFormatter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.api.entity.EntityDescriptor; - -public class EntityModelFormatter extends AbstractJsonFormatter<EntityDescriptor, Void> -{ - - public EntityModelFormatter( JSONWriter writer ) - { - super( writer ); - } - - @Override - public void enter( EntityDescriptor visited ) - throws JSONException - { - object(); - field( "type", visited.primaryType().getName() ); - field( "visibility", visited.visibility().toString() ); - field( "queryable", visited.queryable() ); - } - - @Override - public void leave( EntityDescriptor visited ) - throws JSONException - { - endObject(); - } - - @Override - public void visit( Void visited ) - throws JSONException - { - - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/fc41bb18/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/InjectedFieldModelFormatter.java ---------------------------------------------------------------------- diff --git a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/InjectedFieldModelFormatter.java b/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/InjectedFieldModelFormatter.java deleted file mode 100644 index 5f20163..0000000 --- a/libraries/appbrowser/src/main/java/org/qi4j/library/appbrowser/json/InjectedFieldModelFormatter.java +++ /dev/null @@ -1,60 +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.apache.zest.library.appbrowser.json; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.apache.zest.api.composite.DependencyDescriptor; -import org.apache.zest.api.composite.InjectedFieldDescriptor; -import org.apache.zest.library.appbrowser.Formatter; - -public class InjectedFieldModelFormatter extends AbstractJsonFormatter<InjectedFieldDescriptor, DependencyDescriptor> -{ - public InjectedFieldModelFormatter( JSONWriter writer ) - { - super(writer); - } - - @Override - public void enter( InjectedFieldDescriptor visited ) - throws JSONException - { - object(); - field("name", visited.field().getName() ); -// field( "optional", visited.optional() ); -// field( "injectedclass", visited.injectedClass().getName() ); -// field( "injectedannotation", visited.injectionAnnotation().toString() ); -// field( "injectedtype", visited.injectionType().toString() ); -// field( "rawinjectectiontype", visited.rawInjectionType().getName() ); - } - - @Override - public void leave( InjectedFieldDescriptor visited ) - throws JSONException - { - endObject(); - } - - @Override - public void visit( DependencyDescriptor visited ) - throws JSONException - { - - } -}
