Ejemplo n.º 1
0
 /** @return true iff this access-path ends with the given suffix */
 public boolean hasSuffix(AccessPath suffixPath) {
   if (length() < suffixPath.length()) {
     return false;
   } else {
     for (int i = 0; i < suffixPath.length(); i++) {
       if (!getElementAt(length() - i).equals(suffixPath.getElementAt(length() - i))) {
         return false;
       }
     }
     return true;
   }
 }
Ejemplo n.º 2
0
 /**
  * @param prefixPath
  * @return true iff this access-path starts with the given prefix
  */
 public boolean hasPrefix(AccessPath prefixPath) {
   if (length() < prefixPath.length()) {
     return false;
   } else {
     for (int i = 0; i < prefixPath.length(); i++) {
       if (!getElementAt(i).equals(prefixPath.getElementAt(i))) {
         return false;
       }
     }
     return true;
   }
 }
Ejemplo n.º 3
0
 /**
  * @param elements List<PathElement>
  * @return canonical AccessPath object
  */
 public AccessPath findOrCreate(List<PathElement> elements) {
   if (PARANOID) {
     for (Iterator<PathElement> it = elements.iterator(); it.hasNext(); ) {
       if (!(it.next() instanceof PathElement)) {
         Assertions.UNREACHABLE();
       }
     }
   }
   APKey k = new APKey(elements);
   AccessPath result = map.get(k);
   if (result == null) {
     int id = vector.getMaxIndex() + 1;
     result = new AccessPath(k, id);
     map.put(k, result);
     vector.set(id, result);
     findOrCreateStartsWith(result.getHead()).add(id);
   }
   return result;
 }