@Override
 public boolean equals(final Object other) {
   if (other instanceof CodePair) {
     final CodePair that = (CodePair) other;
     return Utilities.equals(this.source, that.source)
         && Utilities.equals(this.target, that.target);
   }
   return false;
 }
 /**
  * Compare this reference system with the specified object for equality. If {@code
  * compareMetadata} is {@code true}, then all available properties are compared including
  * {@linkplain #getValidArea valid area} and {@linkplain #getScope scope}.
  *
  * @param object The object to compare to {@code this}.
  * @param compareMetadata {@code true} for performing a strict comparaison, or {@code false} for
  *     comparing only properties relevant to transformations.
  * @return {@code true} if both objects are equal.
  */
 @Override
 public boolean equals(final AbstractIdentifiedObject object, final boolean compareMetadata) {
   if (super.equals(object, compareMetadata)) {
     if (!compareMetadata) {
       return true;
     }
     final AbstractReferenceSystem that = (AbstractReferenceSystem) object;
     return Utilities.equals(domainOfValidity, that.domainOfValidity)
         && Utilities.equals(scope, that.scope);
   }
   return false;
 }
Пример #3
0
  /**
   * Compares this ExternalGraphi with another.
   *
   * <p>Two external graphics are equal if they have the same uri and format.
   *
   * @param oth The other External graphic.
   * @return True if this and the other external graphic are equal.
   */
  public boolean equals(Object oth) {
    if (this == oth) {
      return true;
    }

    if (oth instanceof ExternalGraphicImpl) {
      ExternalGraphicImpl other = (ExternalGraphicImpl) oth;

      return Utilities.equals(uri, other.uri) && Utilities.equals(format, other.format);
    }

    return false;
  }
  public void notifyChanged(Notification notification) {
    int featureId = notification.getFeatureID(target.getClass());
    if (featureId != XSDPackage.XSD_ELEMENT_DECLARATION__SUBSTITUTION_GROUP) {
      return;
    }

    if (notification.getEventType() != Notification.ADD) {
      return;
    }
    if (!(notification.getNewValue() instanceof XSDElementDeclaration)) {
      return;
    }

    XSDElementDeclaration el = (XSDElementDeclaration) notification.getNewValue();
    XSDElementDeclaration e = target;

    while (e != null) {
      synchronized (e) {
        ArrayList<Integer> toremove = new ArrayList();
        for (int i = 0; i < e.getSubstitutionGroup().size(); i++) {
          XSDElementDeclaration se = (XSDElementDeclaration) e.getSubstitutionGroup().get(i);
          if (se == null
              || (Utilities.equals(el.getTargetNamespace(), se.getTargetNamespace())
                  && Utilities.equals(el.getName(), se.getName()))) {
            toremove.add(i);
          }
        }

        // iterate back in reverse order and skip the last element as to keep the latest
        // version of the element
        ArrayList<XSDElementDeclaration> removed = new ArrayList();
        for (int i = toremove.size() - 2; i > -1; i--) {
          XSDElementDeclaration se =
              (XSDElementDeclaration) e.getSubstitutionGroup().remove(toremove.get(i).intValue());
          removed.add(e);
        }

        // set the removed elements sub affiliation to a clone of the actual element
        for (XSDElementDeclaration se : removed) {
          if (se != null && e.equals(se.getSubstitutionGroupAffiliation())) {
            XSDElementDeclaration clone =
                (XSDElementDeclaration) e.cloneConcreteComponent(false, false);
            clone.setTargetNamespace(GML.NAMESPACE);

            se.setSubstitutionGroupAffiliation(clone);
          }
        }
      }
      e = e.getSubstitutionGroupAffiliation();
    }
  }
Пример #5
0
 /**
  * Compares the specified object with this envelope for equality.
  *
  * @param object The object to compare with this envelope.
  * @return {@code true} if the given object is equals to this envelope.
  */
 @Override
 public boolean equals(final Object object) {
   if (super.equals(object)) {
     final CoordinateReferenceSystem otherCRS =
         (object instanceof Envelope2D) ? ((Envelope2D) object).crs : null;
     return Utilities.equals(crs, otherCRS);
   }
   return false;
 }
Пример #6
0
 /** Compares this reader/input pair with the specified object for equality. */
 @Override
 public boolean equals(final Object object) {
   if (object instanceof ReaderInputPair) {
     final ReaderInputPair that = (ReaderInputPair) object;
     return Utilities.equals(this.reader, that.reader)
         && Utilities.deepEquals(this.input, that.input);
   }
   return false;
 }
 /**
  * Returns {@code true} if the specified object is also a {@linkplain DirectPosition direct
  * position} with equals {@linkplain #getCoordinate coordinate} and {@linkplain
  * #getCoordinateReferenceSystem CRS}.
  *
  * @param object The object to compare with this position.
  * @return {@code true} if the given object is equals to this position.
  */
 @Override
 public boolean equals(final Object object) {
   if (object instanceof DirectPosition) {
     final DirectPosition that = (DirectPosition) object;
     final int dimension = getDimension();
     if (dimension == that.getDimension()) {
       for (int i = 0; i < dimension; i++) {
         if (!Utilities.equals(this.getOrdinate(i), that.getOrdinate(i))) {
           return false;
         }
       }
       if (Utilities.equals(
           this.getCoordinateReferenceSystem(), that.getCoordinateReferenceSystem())) {
         assert hashCode() == that.hashCode() : this;
         return true;
       }
     }
   }
   return false;
 }
Пример #8
0
 /**
  * Scans {@linkplain System#getProperties system properties} for any property keys defined in this
  * class, and add their values to the specified map of hints. For example if the {@value
  * #FORCE_LONGITUDE_FIRST_AXIS_ORDER} system property is defined, then the {@link
  * Hints#FORCE_LONGITUDE_FIRST_AXIS_ORDER FORCE_LONGITUDE_FIRST_AXIS_ORDER} hint will be added to
  * the set of hints.
  *
  * @return {@code true} if at least one hint changed as a result of this scan, or {@code false}
  *     otherwise.
  */
 static boolean scanForSystemHints(final Hints hints) {
   assert Thread.holdsLock(hints);
   boolean changed = false;
   synchronized (BINDINGS) {
     for (final Map.Entry<String, RenderingHints.Key> entry : BINDINGS.entrySet()) {
       final String propertyKey = entry.getKey();
       final String property;
       try {
         property = System.getProperty(propertyKey);
       } catch (SecurityException e) {
         unexpectedException(e);
         continue;
       }
       if (property != null) {
         /*
          * Converts the system property value from String to Object (java.lang.Boolean
          * or java.lang.Number). We perform this conversion only if the key is exactly
          * of kind Hints.Key,  not a subclass like ClassKey, in order to avoid useless
          * class loading on  'getValueClass()'  method invocation (ClassKey don't make
          * sense for Boolean and Number, which are the only types that we convert here).
          */
         Object value = property;
         final RenderingHints.Key hintKey = entry.getValue();
         if (hintKey.getClass().equals(Hints.Key.class)) {
           final Class<?> type = ((Hints.Key) hintKey).getValueClass();
           if (type.equals(Boolean.class)) {
             value = Boolean.valueOf(property);
           } else if (Number.class.isAssignableFrom(type))
             try {
               value = Classes.valueOf(type, property);
             } catch (NumberFormatException e) {
               unexpectedException(e);
               continue;
             }
         }
         final Object old;
         try {
           old = hints.put(hintKey, value);
         } catch (IllegalArgumentException e) {
           // The property value is illegal for this hint.
           unexpectedException(e);
           continue;
         }
         if (!changed && !Utilities.equals(old, value)) {
           changed = true;
         }
       }
     }
   }
   return changed;
 }
Пример #9
0
  public static SimpleFeatureType createSubType(
      SimpleFeatureType featureType,
      String[] properties,
      CoordinateReferenceSystem override,
      String typeName,
      URI namespace)
      throws SchemaException {

    if ((properties == null) && (override == null)) {
      return featureType;
    }

    if (properties == null) {
      properties = new String[featureType.getAttributeCount()];
      for (int i = 0; i < properties.length; i++) {
        properties[i] = featureType.getDescriptor(i).getLocalName();
      }
    }

    String namespaceURI = namespace != null ? namespace.toString() : null;
    boolean same =
        featureType.getAttributeCount() == properties.length
            && featureType.getTypeName().equals(typeName)
            && Utilities.equals(featureType.getName().getNamespaceURI(), namespaceURI);

    for (int i = 0; (i < featureType.getAttributeCount()) && same; i++) {
      AttributeDescriptor type = featureType.getDescriptor(i);
      same =
          type.getLocalName().equals(properties[i])
              && (((override != null) && type instanceof GeometryDescriptor)
                  ? assertEquals(
                      override, ((GeometryDescriptor) type).getCoordinateReferenceSystem())
                  : true);
    }

    if (same) {
      return featureType;
    }

    AttributeDescriptor[] types = new AttributeDescriptor[properties.length];

    for (int i = 0; i < properties.length; i++) {
      types[i] = featureType.getDescriptor(properties[i]);

      if ((override != null) && types[i] instanceof GeometryDescriptor) {
        AttributeTypeBuilder ab = new AttributeTypeBuilder();
        ab.init(types[i]);
        ab.setCRS(override);
        types[i] = ab.buildDescriptor(types[i].getLocalName(), ab.buildGeometryType());
      }
    }

    if (typeName == null) typeName = featureType.getTypeName();
    if (namespace == null && featureType.getName().getNamespaceURI() != null)
      try {
        namespace = new URI(featureType.getName().getNamespaceURI());
      } catch (URISyntaxException e) {
        throw new RuntimeException(e);
      }

    SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
    tb.setName(typeName);
    tb.setNamespaceURI(namespace);
    tb.addAll(types);

    return tb.buildFeatureType();
  }