Package org.evolizer.ontology.annotations

Examples of org.evolizer.ontology.annotations.rdf


   * partial statement accordingly.
   *
   * @see IReflectionProvider.IVisitor#visit(Class, Object)
   */
  public void visit(Class<?> type, Object instance) {
    rdf annotation = type.getAnnotation(rdf.class);

    if(annotation == null) {
      mode = Mode.IGNORE;
      return;
    }
   
    if(RDFReflectionUtil.isPredicate(type)) {
      mode = Mode.PREDICATE;
     
      try {
        tmpStatement = new Statement<Object, Object>(null, annotation.value(), null);
      } catch (URISyntaxException e) {
        logger.error("Encountered an invalid uri for a property.", e);
      }
      // Do nothing else, but while visiting methods, we will look for @subject and @object tags.
    } else {
View Full Code Here


   * @see IReflectionProvider.IVisitor#visit(Method, Class, Object)
   */
  public void visit(Method method, Class<?> definedIn, Object instance) {
    switch(mode) {
    case NORMAL:
      rdf annotation = method.getAnnotation(rdf.class);
      if(annotation != null) {
        Class<?> returnType = method.getReturnType();
        Object value = DefaultReflectionProvider.invoke(method, instance);
       
        IRDFPropertyConverter converter = ConverterRegistry.getConverterFor(returnType);
View Full Code Here

  public static Resource rdfClassOf(Model model, Method method) {
    return model.createResource(uriReferenceOf(method));
  }
 
  public static String uriReferenceOf(Class<?> clazz) {
    rdf annotation = clazz.getAnnotation(rdf.class);
   
    return annotation.value();
  }
View Full Code Here

   
    return annotation.value();
  }
 
  public static String uriReferenceOf(Method method) {
    rdf annotation = method.getAnnotation(rdf.class);
   
    return annotation.value();
  }
View Full Code Here

  public static Resource rdfInstanceOf(Model model, Object object) {
    return OntologyProvider.rdfInstanceOf(model, fragmentIdentifier(object), rdfClassOf(model, object));
  }
 
  public static boolean isPredicate(Class<?> clazz) {
    rdf annotation = clazz.getAnnotation(rdf.class);
    return annotation.isPredicate();
  }
View Full Code Here

    List<Method> result = new ArrayList<Method>();
   
    Iterator<Method> iter = ClassRegistry.methodsFor(type);
    while(iter.hasNext()) {
      Method method = iter.next();
      rdf annotation = method.getAnnotation(rdf.class);
      if(annotation != null) {
        String uriReference = annotation.value();
        boolean isContainment = OntologyProvider.hasSuperProperty(uriReference, "http://www.evolizer.org.com/ontology/relations.owl#contains");
        if(isContainment) {
          result.add(method);
        }
      }
View Full Code Here

  @Test
  public void testIfAnnotationPresent() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    FoafPerson michael = new FoafPerson("Michael", "Wuersch");
   
    Class<? extends FoafPerson> pClass = michael.getClass();
    rdf annoPerson = pClass.getAnnotation(rdf.class);
    assertEquals("value of @rdf for Person is unexpected", FoafPerson.foaf + "Person", annoPerson.value());
   
    Method methodGetFirstName = pClass.getMethod("getFirstName");
    Method methodGetFamilyName = pClass.getMethod("getFamilyName");
   
    assertEquals("value of first name is unexpected", "Michael", methodGetFirstName.invoke(michael));
    assertEquals("value of family name is unexpected", "Wuersch", methodGetFamilyName.invoke(michael));
   
    rdf annoName = methodGetFirstName.getAnnotation(rdf.class);
    assertEquals("value of @rdf for getFirstName is unexpected", FoafPerson.foaf + "firstName", annoName.value());
   
    rdf annoFamilyName = methodGetFamilyName.getAnnotation(rdf.class);
    assertEquals("value of @rdf for getFamilyName is unexpected", FoafPerson.foaf + "family_name", annoFamilyName.value());
   
    FoafPerson gigs = new FoafPerson("Emanuel", "Giger");
   
    PersonToPersonRelationship coworking = new PersonToPersonRelationship(michael, gigs);
   
    Class<? extends PersonToPersonRelationship> ptpClass = coworking.getClass();
    rdf annoPtP = ptpClass.getAnnotation(rdf.class);
    assertEquals("isPredicate of @rdf for PersonToPersonRelationship is unexpected", true, annoPtP.isPredicate());
  }
View Full Code Here

TOP

Related Classes of org.evolizer.ontology.annotations.rdf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.