예제 #1
0
 /**
  * Merges the information (i.e. compulsory and optional properties) in this anchor with the given
  * one
  *
  * @param a Anchor
  * @return Anchor
  */
 public Anchor merge(Anchor a) {
   if (a != null) {
     for (Iterator it = a.getCompulsoryProperties(); it.hasNext(); ) {
       OntProperty p = (OntProperty) it.next();
       if (!compulsory.contains(p)) compulsory.add(p);
       redAnchor = true;
     }
     for (Iterator it = a.getOptionalProperties(); it.hasNext(); ) {
       OntProperty o = (OntProperty) it.next();
       if (!optional.contains(o)) optional.add(o);
     }
   }
   sort(false); // DOES THIS EVER GET USED BY QUERY???
   return this;
 }
예제 #2
0
  /**
   * Constructs an anchor for the given node by copying all information from the given anchor
   *
   * @param a Another anchor
   * @param n The node to which the anchor must be attached
   * @throws BadAnchorException if the given anchor is null
   */
  public Anchor(Anchor a, SGNode n) throws BadAnchorException {
    if (a == null)
      throw new BadAnchorException("Failed attempt to make an anchor out of a null object");

    reader = a.getReader();
    node = n;
    query = a.isQuery();
    compulsory.addAll(a.getCompulsory());
    optional.addAll(a.getOptional());
    sort(query);
    redAnchor = a.isRed();
    reader = a.getReader();
    id = a.getID();
    uri = a.getURI();
    n.setAnchor(this);
  }
예제 #3
0
  /**
   * Constructs an anchor by copying all information from the given anchor
   *
   * @param a Another anchor
   * @throws BadAnchorException if the given anchor is null
   */
  public Anchor(Anchor a) throws BadAnchorException {
    if (a == null)
      throw new BadAnchorException("Failed attempt to make an anchor out of a null object");
    merge(a);
    query = a.isQuery();
    redAnchor = a.isRed();
    // datatype = a.isDataType();
    reader = a.getReader();
    id = a.getID();
    uri = a.getURI();

    if (a.getNode() != null) {
      node = a.getNode();
      node.setAnchor(this);
    }
  }