You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/04/10 11:54:42 UTC
[2/9] polygene-java git commit: Tighten o.a.p.core.api.util by moving
some types to where they belong
Tighten o.a.p.core.api.util by moving some types to where they belong
Move ArrayIterable to o.a.p.core.spi.util
And ListMap to o.a.p.extensions.migration.util
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/76b5be20
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/76b5be20
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/76b5be20
Branch: refs/heads/develop
Commit: 76b5be209e52a004f7acc94ed1d50ca002860f26
Parents: bf66ab2
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Apr 10 12:09:40 2017 +0200
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Apr 10 12:09:40 2017 +0200
----------------------------------------------------------------------
.../apache/polygene/api/util/ArrayIterable.java | 75 --------------------
.../org/apache/polygene/api/util/ListMap.java | 48 -------------
.../javaxjson/JavaxJsonSerializer.java | 2 +-
.../apache/polygene/spi/util/ArrayIterable.java | 75 ++++++++++++++++++++
.../org/apache/polygene/spi/util/package.html | 24 +++++++
.../migration/assembly/MigrationRules.java | 2 +-
.../apache/polygene/migration/util/ListMap.java | 48 +++++++++++++
.../apache/polygene/migration/util/package.html | 24 +++++++
.../javaxxml/JavaxXmlSerializer.java | 2 +-
.../messagepack/MessagePackSerializer.java | 2 +-
10 files changed, 175 insertions(+), 127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/core/api/src/main/java/org/apache/polygene/api/util/ArrayIterable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/util/ArrayIterable.java b/core/api/src/main/java/org/apache/polygene/api/util/ArrayIterable.java
deleted file mode 100644
index 707eaca..0000000
--- a/core/api/src/main/java/org/apache/polygene/api/util/ArrayIterable.java
+++ /dev/null
@@ -1,75 +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.polygene.api.util;
-
-import java.lang.reflect.Array;
-import java.util.Iterator;
-
-/**
- * Iterate over arrays, both primitive arrays and Object[].
- */
-public class ArrayIterable implements Iterable<Object>
-{
- private final Object array;
-
- public ArrayIterable( final Object array )
- {
- if( !array.getClass().isArray() )
- {
- throw new IllegalArgumentException( array + " is not an array" );
- }
- this.array = array;
- }
-
- @Override
- public Iterator<Object> iterator()
- {
- return new ArrayIterator( array );
- }
-
- private class ArrayIterator implements Iterator<Object>
- {
- private final Object array;
- private int currentIndex = 0;
-
- private ArrayIterator( Object array )
- {
- this.array = array;
- }
-
- @Override
- public boolean hasNext()
- {
- return currentIndex < Array.getLength( array );
- }
-
- @Override
- public Object next()
- {
- return Array.get( array, currentIndex++ );
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException( "cannot remove items from an array" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/core/api/src/main/java/org/apache/polygene/api/util/ListMap.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/util/ListMap.java b/core/api/src/main/java/org/apache/polygene/api/util/ListMap.java
deleted file mode 100644
index 4cba48e..0000000
--- a/core/api/src/main/java/org/apache/polygene/api/util/ListMap.java
+++ /dev/null
@@ -1,48 +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.polygene.api.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Map whose values are Lists of things. Create
- * one ArrayList for each key that is added. The list does not allow
- * duplicates.
- */
-public final class ListMap<K, V>
- extends HashMap<K, List<V>>
-{
- public void add( K key, V value )
- {
- List<V> list = get( key );
- if( list == null )
- {
- list = new ArrayList<V>();
- put( key, list );
- }
- if( !list.contains( value ) )
- {
- list.add( value );
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializer.java b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializer.java
index 8e34d0d..48aa511 100644
--- a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializer.java
+++ b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializer.java
@@ -50,11 +50,11 @@ import org.apache.polygene.api.type.MapType;
import org.apache.polygene.api.type.ValueCompositeType;
import org.apache.polygene.api.type.ValueType;
import org.apache.polygene.api.util.Annotations;
-import org.apache.polygene.api.util.ArrayIterable;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.api.value.ValueDescriptor;
import org.apache.polygene.spi.serialization.AbstractTextSerializer;
import org.apache.polygene.spi.serialization.JsonSerializer;
+import org.apache.polygene.spi.util.ArrayIterable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/core/spi/src/main/java/org/apache/polygene/spi/util/ArrayIterable.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/util/ArrayIterable.java b/core/spi/src/main/java/org/apache/polygene/spi/util/ArrayIterable.java
new file mode 100644
index 0000000..71f8748
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/polygene/spi/util/ArrayIterable.java
@@ -0,0 +1,75 @@
+/*
+ * 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.polygene.spi.util;
+
+import java.lang.reflect.Array;
+import java.util.Iterator;
+
+/**
+ * Iterate over arrays, both primitive arrays and Object[].
+ */
+public class ArrayIterable implements Iterable<Object>
+{
+ private final Object array;
+
+ public ArrayIterable( final Object array )
+ {
+ if( !array.getClass().isArray() )
+ {
+ throw new IllegalArgumentException( array + " is not an array" );
+ }
+ this.array = array;
+ }
+
+ @Override
+ public Iterator<Object> iterator()
+ {
+ return new ArrayIterator( array );
+ }
+
+ private class ArrayIterator implements Iterator<Object>
+ {
+ private final Object array;
+ private int currentIndex = 0;
+
+ private ArrayIterator( Object array )
+ {
+ this.array = array;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return currentIndex < Array.getLength( array );
+ }
+
+ @Override
+ public Object next()
+ {
+ return Array.get( array, currentIndex++ );
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException( "cannot remove items from an array" );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/core/spi/src/main/java/org/apache/polygene/spi/util/package.html
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/util/package.html b/core/spi/src/main/java/org/apache/polygene/spi/util/package.html
new file mode 100644
index 0000000..a6ad50b
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/polygene/spi/util/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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.
+ ~
+ ~
+ -->
+<html>
+ <body>
+ <h2>SPI Utilities.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/extensions/migration/src/main/java/org/apache/polygene/migration/assembly/MigrationRules.java
----------------------------------------------------------------------
diff --git a/extensions/migration/src/main/java/org/apache/polygene/migration/assembly/MigrationRules.java b/extensions/migration/src/main/java/org/apache/polygene/migration/assembly/MigrationRules.java
index 920e3de..0109388 100644
--- a/extensions/migration/src/main/java/org/apache/polygene/migration/assembly/MigrationRules.java
+++ b/extensions/migration/src/main/java/org/apache/polygene/migration/assembly/MigrationRules.java
@@ -23,7 +23,7 @@ package org.apache.polygene.migration.assembly;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.polygene.api.util.ListMap;
+import org.apache.polygene.migration.util.ListMap;
/**
* Set of migration rules.
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/extensions/migration/src/main/java/org/apache/polygene/migration/util/ListMap.java
----------------------------------------------------------------------
diff --git a/extensions/migration/src/main/java/org/apache/polygene/migration/util/ListMap.java b/extensions/migration/src/main/java/org/apache/polygene/migration/util/ListMap.java
new file mode 100644
index 0000000..aafc8ce
--- /dev/null
+++ b/extensions/migration/src/main/java/org/apache/polygene/migration/util/ListMap.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.polygene.migration.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Map whose values are Lists of things. Create
+ * one ArrayList for each key that is added. The list does not allow
+ * duplicates.
+ */
+public final class ListMap<K, V>
+ extends HashMap<K, List<V>>
+{
+ public void add( K key, V value )
+ {
+ List<V> list = get( key );
+ if( list == null )
+ {
+ list = new ArrayList<V>();
+ put( key, list );
+ }
+ if( !list.contains( value ) )
+ {
+ list.add( value );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/extensions/migration/src/main/java/org/apache/polygene/migration/util/package.html
----------------------------------------------------------------------
diff --git a/extensions/migration/src/main/java/org/apache/polygene/migration/util/package.html b/extensions/migration/src/main/java/org/apache/polygene/migration/util/package.html
new file mode 100644
index 0000000..65edf4f
--- /dev/null
+++ b/extensions/migration/src/main/java/org/apache/polygene/migration/util/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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.
+ ~
+ ~
+ -->
+<html>
+ <body>
+ <h2>Entities Migration Utilities.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializer.java b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializer.java
index fa3895d..fa50019 100644
--- a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializer.java
+++ b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializer.java
@@ -48,11 +48,11 @@ import org.apache.polygene.api.type.EnumType;
import org.apache.polygene.api.type.MapType;
import org.apache.polygene.api.type.ValueCompositeType;
import org.apache.polygene.api.util.Annotations;
-import org.apache.polygene.api.util.ArrayIterable;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.api.value.ValueDescriptor;
import org.apache.polygene.spi.serialization.AbstractTextSerializer;
import org.apache.polygene.spi.serialization.XmlSerializer;
+import org.apache.polygene.spi.util.ArrayIterable;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/76b5be20/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackSerializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackSerializer.java b/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackSerializer.java
index c48b7f7..dea03e1 100644
--- a/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackSerializer.java
+++ b/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackSerializer.java
@@ -40,10 +40,10 @@ import org.apache.polygene.api.type.EnumType;
import org.apache.polygene.api.type.MapType;
import org.apache.polygene.api.type.ValueCompositeType;
import org.apache.polygene.api.util.Annotations;
-import org.apache.polygene.api.util.ArrayIterable;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.api.value.ValueDescriptor;
import org.apache.polygene.spi.serialization.AbstractBinarySerializer;
+import org.apache.polygene.spi.util.ArrayIterable;
import org.msgpack.core.MessagePack;
import org.msgpack.core.MessagePacker;
import org.msgpack.value.ArrayValue;