コード例 #1
0
  /**
   * This method takes a property URI and returns domains of that property. If @param recursive is
   * true, it also returns the children of the domains.
   *
   * @param propertyUri
   * @param recursive
   * @return
   */
  public HashSet<String> getDomainsOfProperty(String propertyUri, boolean recursive) {

    HashSet<String> results = new HashSet<String>();
    HashSet<String> direct = null;
    HashSet<String> indirect = null;

    direct = ontCache.getPropertyDirectDomains().get(propertyUri);
    if (direct != null) results.addAll(direct);
    if (recursive) indirect = ontCache.getPropertyIndirectDomains().get(propertyUri);
    if (indirect != null) results.addAll(indirect);

    return results;
  }
コード例 #2
0
  /**
   * This method takes @param domainUri and rangeClassUri and for returns all links/properties with
   * this domain & range If @param recursive is true, it also returns the children of the domains.
   *
   * @param domainUri
   * @param rangeUri
   * @param recursive
   * @return
   */
  public Map<String, Label> getObjectPropertiesByDomainRange(
      String domainUri, String rangeUri, boolean recursive) {

    if (domainUri == null || domainUri.length() == 0)
      return this.getObjectPropertiesByRange(rangeUri, recursive);

    if (rangeUri == null || rangeUri.length() == 0)
      return this.getObjectPropertiesByDomain(domainUri, recursive);

    HashSet<String> objectProperties = ontCache.getDirectInObjectProperties().get(rangeUri);
    if (recursive) {
      HashSet<String> propRecursive = ontCache.getIndirectInObjectProperties().get(rangeUri);
      if (propRecursive != null) objectProperties.addAll(propRecursive);
    }
    HashMap<String, Label> results = new HashMap<String, Label>();
    HashSet<String> direct = null;
    HashSet<String> indirect = null;

    if (objectProperties == null) return results;

    for (String op : objectProperties) {
      boolean propAdded = false;
      direct = ontCache.getPropertyDirectDomains().get(op);
      if (direct != null) {
        for (String directDomain : direct) {
          if (directDomain.equals(domainUri)) {
            results.put(op, ontCache.getPropertyLabel(op));
            propAdded = true;
            break;
          }
        }
        // results.addAll(direct);
      }
      if (propAdded) continue;
      if (recursive) indirect = ontCache.getPropertyIndirectDomains().get(op);
      if (indirect != null) {
        // results.addAll(indirect);
        for (String indirectDomain : indirect) {
          if (indirectDomain.equals(domainUri)) {
            results.put(op, ontCache.getPropertyLabel(op));
            propAdded = true;
            break;
          }
        }
      }
    }

    return results;
  }
コード例 #3
0
  /**
   * This method takes @param rangeClassUri and for object properties whose ranges includes this
   * parameter, returns all of their domains. If @param recursive is true, it also returns the
   * children of the domains.
   *
   * @param rangeUri
   * @param recursive
   * @return
   */
  public HashSet<String> getDomainsGivenRange(String rangeUri, boolean recursive) {

    HashSet<String> objectProperties = ontCache.getDirectInObjectProperties().get(rangeUri);
    HashSet<String> results = new HashSet<String>();
    HashSet<String> direct = null;
    HashSet<String> indirect = null;

    if (objectProperties == null) return results;

    for (String op : objectProperties) {
      direct = ontCache.getPropertyDirectDomains().get(op);
      if (direct != null) results.addAll(direct);
      if (recursive) indirect = ontCache.getPropertyIndirectDomains().get(op);
      if (indirect != null) results.addAll(indirect);
    }

    return results;
  }