Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Language


    @Test
    public void testUseLanguageLiterals() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        Language language = new Language("it");
        Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
        graph.add(triple1);
        Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
        Assert.assertTrue(tripleIter.hasNext());
View Full Code Here


    }
    if (iso1Literal == null) {
      throw new RuntimeException("No iso1 code for " +resource.getNode());
    }
    String iso1 = iso1Literal.getLexicalForm();
    this.language = new Language(iso1);
  }
View Full Code Here

  @Test
  public void testUseLanguageLiterals() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    Language language = new Language("it");
    Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
View Full Code Here

    Assert.assertFalse(literal1.equals(literal3));
  }
 
  @Test public void languageLiteralEquality() {
    String stringValue = "some text";
    Language lang = new Language("en-ca");
    PlainLiteral literal1 = new PlainLiteralImpl(stringValue, lang);
    PlainLiteral literal2 = new PlainLiteralImpl(stringValue, lang);   
    Assert.assertEquals(literal1, literal2);
    Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
    Language lang2 = new Language("de");
    PlainLiteral literal3 = new PlainLiteralImpl(stringValue, lang2);
    Assert.assertFalse(literal1.equals(literal3));
    PlainLiteral literal4 = new PlainLiteralImpl(stringValue, null);
    Assert.assertFalse(literal3.equals(literal4));
    Assert.assertFalse(literal4.equals(literal3));
View Full Code Here

  /**
   * hashCode of the lexical form plus the hashCode of the locale
   */
  @Test public void checkHashCode() {
    String stringValue = "some text";
    Language language = new Language("en");
    PlainLiteral literal = new PlainLiteralImpl(stringValue, language);
    Assert.assertEquals(stringValue.hashCode() + language.hashCode(), literal.hashCode());
  }
View Full Code Here

          .entity("A concept must have a label!")
          .build();
    }
    MGraph contentGraph = cgProvider.getContentGraph();
    PlainLiteral preferredLabel = new PlainLiteralImpl(prefLabel,
        new Language(lang));

    if (contentGraph.filter(null, SKOS.prefLabel, preferredLabel).hasNext()) {
      return Response.status(Status.CONFLICT)
          .entity("A concept with the same label and language already exists!")
          .build();
    }
   
    UriRef concept = getConceptUriRef(platformConfig, prefLabel);
    contentGraph.add(new TripleImpl(concept, RDF.type,
        SKOS.Concept));
    String baseUri = platformConfig.getDefaultBaseUri().getUnicodeString();
    contentGraph.add(new TripleImpl(concept, SKOS.inScheme,
        new UriRef(baseUri + FREE_CONCEPT_SCHEME)));
    contentGraph.add(new TripleImpl(concept, SKOS.prefLabel, preferredLabel));
    if (!comment.isEmpty()) {
      contentGraph.add(new TripleImpl(concept, RDFS.comment,
          new PlainLiteralImpl(comment, new Language(lang))));
    }
    return Response.status(Status.CREATED).entity(concept.getUnicodeString())
        .build();
  }
View Full Code Here

      UriRef dtUriRef = new UriRef(datatypeString);
      return new TypedLiteralImpl(lexicalForm, dtUriRef);
    } else {
      String language = node.getLiteralLanguage();
      if ((language != null) && !language.equals("")) {
        return new PlainLiteralImpl(lexicalForm, new Language(language));
      } else {
        return new PlainLiteralImpl(lexicalForm);
      }
    }
  }
View Full Code Here

        new Variable("a"), new Variable("x"),
        new PlainLiteralImpl("tiger"))));

    Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(
        new Variable("a"), new Variable("x"),
        new PlainLiteralImpl("lion", new Language("en")))));
  }
View Full Code Here

          .getDataType().getUnicodeString()));
    } else if (resource instanceof PlainLiteral) {
      value = doc.createElement("literal");
      value.appendChild(doc.createTextNode(((PlainLiteral) resource)
          .getLexicalForm()));
      Language lang = ((PlainLiteral) resource).getLanguage();
      if (lang != null) {
        value.setAttribute("xml:lang", (lang.toString()));
      }
    } else {
      value = doc.createElement("bnode");
      value.appendChild(doc.createTextNode(((BNode) resource).toString()));
    }
View Full Code Here

          .getDataType().getUnicodeString()));
    } else if (resource instanceof PlainLiteral) {
      value = doc.createElement("literal");
      value.appendChild(doc.createTextNode(((PlainLiteral) resource)
          .getLexicalForm()));
      Language lang = ((PlainLiteral) resource).getLanguage();
      if (lang != null) {
        value.setAttribute("xml:lang", (lang.toString()));
      }
    } else {
      value = doc.createElement("bnode");
      value.appendChild(doc.createTextNode(((BNode) resource).toString()));
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Language

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.