Пример #1
0
 @SuppressWarnings("unchecked")
 private Object createDefaultValue(RDFProperty property) {
   for (Iterator<AnnotationsWidgetPlugin> it = TriplesComponent.plugins(); it.hasNext(); ) {
     AnnotationsWidgetPlugin plugin = it.next();
     if (plugin.canEdit(subject, property, null)) {
       Object defaultValue = plugin.createDefaultValue(subject, property);
       if (defaultValue != null) {
         return defaultValue;
       }
     }
   }
   RDFResource range = property.getRange();
   if (range instanceof RDFSDatatype) {
     return ((RDFSDatatype) range).getDefaultValue();
   } else if (range instanceof OWLDataRange) {
     OWLDataRange dataRange = (OWLDataRange) range;
     RDFList oneOf = dataRange.getOneOf();
     Object firstValue = null;
     if (oneOf != null) {
       Collection values = oneOf.getValues();
       if (!values.isEmpty()) {
         firstValue = values.iterator().next();
       }
     }
     return firstValue;
   } else if (property instanceof OWLObjectProperty) {
     return null;
   } else {
     return "";
   }
 }
Пример #2
0
 public boolean equalsStructurally(RDFObject object) {
   if (object instanceof RDFList) {
     RDFList list = (RDFList) object;
     if (getValues().size() == list.getValues().size()) {
       Iterator it = getValues().iterator();
       for (Iterator listIt = list.getValues().iterator(); listIt.hasNext(); ) {
         OWLModel model = getOWLModel();
         RDFObject curListObj = model.asRDFObject(listIt.next());
         RDFObject curThisObj = model.asRDFObject(it.next());
         if (curListObj != null && curThisObj != null) {
           if (curListObj.equalsStructurally(curThisObj) == false) {
             return false;
           }
         } else {
           if (curListObj != curThisObj) {
             return false;
           }
         }
       }
       return true;
     }
   }
   return false;
 }
Пример #3
0
 public static void removeListValue(RDFResource resource, RDFProperty property, Object value) {
   RDFList list = (RDFList) resource.getPropertyValue(property);
   List values = list.getValues();
   int index = values.indexOf(value);
   removeListValue(resource, property, list, index);
 }