You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/09/27 09:41:26 UTC
svn commit: r1762429 - in
/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature:
DefaultFeatureType.java FeatureFormat.java StringJoinOperation.java
Author: desruisseaux
Date: Tue Sep 27 09:41:25 2016
New Revision: 1762429
URL: http://svn.apache.org/viewvc?rev=1762429&view=rev
Log:
Fix a NullPointerException and a PropertyNotFoundException in FeatureFormat.format(...).
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java?rev=1762429&r1=1762428&r2=1762429&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] Tue Sep 27 09:41:25 2016
@@ -584,7 +584,7 @@ public class DefaultFeatureType extends
*
* @see #OPERATION_INDEX
*/
- private static boolean isParameterlessOperation(final PropertyType type) {
+ static boolean isParameterlessOperation(final PropertyType type) {
if (type instanceof Operation) {
final ParameterDescriptorGroup parameters = ((Operation) type).getParameters();
return ((parameters == null) || parameters.descriptors().isEmpty())
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1762429&r1=1762428&r2=1762429&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] Tue Sep 27 09:41:25 2016
@@ -253,6 +253,12 @@ header: for (int i=0; ; i++) {
for (final PropertyType propertyType : featureType.getProperties(true)) {
Object value = null;
if (feature != null) {
+ if (!(propertyType instanceof AttributeType<?>) &&
+ !(propertyType instanceof FeatureAssociationRole) &&
+ !DefaultFeatureType.isParameterlessOperation(propertyType))
+ {
+ continue;
+ }
value = feature.getPropertyValue(propertyType.getName().toString());
if (value == null) {
if (propertyType instanceof AttributeType &&
@@ -295,7 +301,7 @@ header: for (int i=0; ; i++) {
final int minimumOccurs, maximumOccurs; // Negative values mean no cardinality.
final IdentifiedType resultType; // Result of operation if applicable.
if (propertyType instanceof Operation) {
- resultType = ((Operation) propertyType).getResult();
+ resultType = ((Operation) propertyType).getResult(); // May be null
} else {
resultType = propertyType;
}
@@ -313,7 +319,7 @@ header: for (int i=0; ; i++) {
valueType = toString(DefaultAssociationRole.getValueTypeName(pt));
valueClass = Feature.class;
} else {
- valueType = toString(resultType.getName());
+ valueType = (resultType != null) ? toString(resultType.getName()) : "";
valueClass = null;
minimumOccurs = -1;
maximumOccurs = -1;
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java?rev=1762429&r1=1762428&r2=1762429&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java [UTF-8] Tue Sep 27 09:41:25 2016
@@ -146,9 +146,9 @@ final class StringJoinOperation extends
attributeType = ((Operation) attributeType).getResult();
}
if (!(attributeType instanceof AttributeType)) {
+ final Class<?>[] inf = Classes.getLeafInterfaces(Classes.getClass(attributeType), PropertyType.class);
throw new IllegalArgumentException(Errors.getResources(identification)
- .getString(Errors.Keys.IllegalPropertyType_2, name,
- Classes.getLeafInterfaces(attributeType.getClass(), PropertyType.class)[0]));
+ .getString(Errors.Keys.IllegalPropertyType_2, name, (inf.length != 0) ? inf[0] : null));
}
if (((AttributeType<?>) attributeType).getMaximumOccurs() > 1) {
throw new IllegalArgumentException(Errors.getResources(identification)