示例#1
0
 @Override
 public String getValue(Object instance, String property) {
   Value value = graph.first(getValue(instance), Values.iri(property));
   if (value == null) return null;
   if (value.getString() != null) return value.getString();
   return value.toIri();
 }
示例#2
0
 @Override
 public Iterable<String> getValues(Object instance, String property) {
   List<String> result = new ArrayList<String>();
   for (Value value : graph.values(getValue(instance), Values.iri(property))) {
     if (value.getString() != null) result.add(value.getString());
     else result.add(value.toIri());
   }
   return result;
 }
示例#3
0
 private Object getInstance(Value entity) {
   Object instance = instances.get(entity);
   if (instance != null) return instance;
   Value implementation = null;
   for (Value impl :
       graph.values(entity, Values.iri("http://purl.org/openapp/server/implementation")))
     if ("http://purl.org/openapp/server/javaFQName".equals(impl.getType())) implementation = impl;
   try {
     if (implementation == null) {
       instance = new Object();
     } else {
       logger.info("Instantiating " + implementation.getString());
       instance = Class.forName(implementation.getString()).newInstance();
     }
     instances.put(entity, instance);
     entities.put(instance, entity);
     if (entity == applicationEntity) applicationInstance = instance;
     if (instance instanceof Bindable) ((Bindable) instance).bind(this);
     return instance;
   } catch (Exception e) {
     throw new Error("Error instantiating " + implementation.getString(), e);
   }
 }
示例#4
0
 @Override
 public Iterable<String> getProperties(Object instance) {
   List<String> result = new ArrayList<String>();
   for (Value property : graph.properties(getValue(instance))) result.add(property.toIri());
   return result;
 }