PropertyWrapper.java :  » UnTagged » stevie » de » unikoblenz » west » csxpoi » Android Open Source

Android Open Source » UnTagged » stevie 
stevie » de » unikoblenz » west » csxpoi » PropertyWrapper.java
package de.unikoblenz.west.csxpoi;

/**
 * Encapsulates properties, which are specified by their URI (possibly inverse)
 * and have a name.
 */
public class PropertyWrapper {

  /**
   * the URI of the property
   */
  private String mUri = null;

  /**
   * the name of the property
   */
  private String mName = null;

  /**
   * whether the URI represents the inverse of the property
   */
  private boolean mInverse = false;

  /**
   * the subclass property
   */
  public static final PropertyWrapper SUBCLASS_OF = new PropertyWrapper(
      Constants.URI_RDFS_SUB_CLASS_OF, "subtype of");//"subclass of");

  /**
   * the superclass property
   */
  public static final PropertyWrapper SUPERCLASS_OF = new PropertyWrapper(
      Constants.URI_RDFS_SUB_CLASS_OF, "supertype of", true);//"superclass of", true);

  /**
   * the equivalent property
   */
  public static final PropertyWrapper EQUIVALENT_TO = new PropertyWrapper(
      Constants.URI_OWL_SAME_AS, "equivalent to");

  /**
   * the list of contingent properties
   */
  public static final PropertyWrapper[] CONTINGENT_PROPERTIES = {
      SUBCLASS_OF, SUPERCLASS_OF, EQUIVALENT_TO };

  /**
   * Creates a property with the specified (possibly inverse) URI and name.
   * 
   * @param uri
   *            the URI of the property
   * @param name
   *            the name of the property
   * @param inverse
   *            whether the URI represents the inverse of the property
   */
  public PropertyWrapper(String uri, String name, boolean inverse) {
    mUri = uri;
    mName = name;
    mInverse = inverse;
  }

  /**
   * Creates a property with the specified (not inverse) URI and name,
   * 
   * @param uri
   *            the URI of the property
   * @param name
   *            the name of the property
   */
  public PropertyWrapper(String uri, String name) {
    this(uri, name, false);
  }

  /**
   * Gets the URI of the property.
   * 
   * @return the URI of the property
   */
  public String getUri() {
    return mUri;
  }

  /**
   * Gets the name of the property
   * 
   * @return the name of the property
   */
  public String getName() {
    return mName;
  }

  /**
   * Tests whether the URI represents the inverse of the property.
   * 
   * @return whether the URI represents the inverse of the property
   */
  public boolean isInverse() {
    return mInverse;
  }

  /**
   * The property's name is its string representation.
   */
  @Override
  public String toString() {
    return mName;
  }

  /**
   * POIs are equal if their URIs match.
   */
  @Override
  public boolean equals(Object object) {
    try {
      PropertyWrapper property = (PropertyWrapper) object;
      return mUri.equals(property.getUri())
          && mInverse == property.isInverse();
    } catch (ClassCastException e) {
      return false;
    } catch (NullPointerException e) {
      return false;
    }
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.