Esempio n. 1
0
 /**
  * Retrieve or create a bNode representing an inferred property value.
  *
  * @param instance the base instance node to which the property applies
  * @param prop the property node whose value is being inferred
  * @param pclass the (optional, can be null) class for the inferred value.
  * @return the bNode representing the property value
  */
 public synchronized Node getTemp(Node instance, Node prop, Node pclass) {
   NodePair ip = new NodePair(instance, prop);
   Node result = null;
   for (Iterator<Node> i = ipMap.getAll(ip); i.hasNext(); ) {
     Node t = i.next();
     if (pclass != null) {
       Object tClass = classMap.get(t);
       if (tClass != null && tClass.equals(pclass)) {
         result = t;
         break;
       }
     } else {
       result = t;
       break;
     }
   }
   if (result == null) {
     // No value yet, so create one
     result = NodeFactory.createBlankNode();
     ipMap.put(ip, result);
     if (pclass != null) {
       classMap.put(result, pclass);
     }
   }
   return result;
 }
Esempio n. 2
0
 /** Prepare the local alias map by reading the alias table from the concrete sub-class. */
 protected OneToManyMap<Resource, Resource> aliasMap() {
   if (m_aliasesMap == null) {
     // aliases map not prepared yet, so initialise using the data from
     // the concrete profile class
     m_aliasesMap = new OneToManyMap<>();
     Resource[][] aliases = aliasTable();
     for (Resource[] aliase : aliases) {
       // since alias relationship is symmetric, we record both directions
       m_aliasesMap.put(aliase[0], aliase[1]);
       m_aliasesMap.put(aliase[1], aliase[0]);
     }
   }
   return m_aliasesMap;
 }