Package org.apache.clerezza.rdf.core

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


    @Test
    public void testUseTypedLiterals() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
        graph.add(triple1);
        Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
        Assert.assertTrue(tripleIter.hasNext());
        Resource gotValue = tripleIter.next().getObject();
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());
        Resource gotValue = tripleIter.next().getObject();
View Full Code Here

      Lock lock = systemGraph.getLock().readLock();
      lock.lock();
      try {
        Iterator<Triple> triples = systemGraph.filter(permission, PERMISSION.javaPermissionEntry, null);
        if(triples.hasNext()) {
          Literal entry = (Literal) triples.next().getObject();
          permissionEntries.add(entry.getLexicalForm());
        }
      } finally {
        lock.unlock();
      }
    }
View Full Code Here

    Lock readLock = infoBit.readLock();
    readLock.lock();
    try {
      Iterator<Literal> mediaTypeLits = infoBit.getLiterals(DISCOBITS.infoBit);
      if (mediaTypeLits.hasNext()) {
        final Literal literalValue = mediaTypeLits.next();
        if (literalValue instanceof TypedLiteral) {
          result = LiteralFactory.getInstance().createObject(
              (new byte[0]).getClass(), (TypedLiteral) literalValue);
        }
      }
View Full Code Here

  @Test
  public void testUseTypedLiterals() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    Resource gotValue = tripleIter.next().getObject();
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());
    Resource gotValue = tripleIter.next().getObject();
View Full Code Here

  private GraphNode resource;
  private Language language;

  LanguageDescription(GraphNode resource) {
    this.resource = resource;
    Literal iso1Literal = null;
    TripleCollection configGraph = resource.getGraph();
    if (configGraph instanceof LockableMGraph) {
      LockableMGraph lockableConfigGraph = (LockableMGraph)configGraph;
      Lock readLock = lockableConfigGraph.getLock().readLock();
      readLock.lock();
      try {
        iso1Literal = (Literal) resource.getObjects(LINGVOJ.iso1).next();
      } finally {
        readLock.unlock();
      }
    } else {
      iso1Literal = (Literal) resource.getObjects(LINGVOJ.iso1).next();
    }
    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

    NonLiteral result = new BNode();
    RdfList list = new RdfList(result, mGraph);
    for (Menu menu : menus) {
      BNode node = new BNode();
      final String label = menu.root.getLabel();
      Literal labelLiteral = new PlainLiteralImpl(label);
      mGraph.add(new TripleImpl(node, RDFS.label,labelLiteral));
      final String description = menu.root.getDescription();
      if (description != null) {
        Literal descLiteral = new PlainLiteralImpl(description);
        mGraph.add(new TripleImpl(node, DCTERMS.description, descLiteral));
      }
      final String path = menu.root.getPath();
      if (path != null) {
        Literal pathLiteral = LiteralFactory.getInstance().
            createTypedLiteral(path);
        mGraph.add(new TripleImpl(node, GLOBALMENU.path, pathLiteral));
      }
      if (menu.children.size() > 0) {
        mGraph.add(new TripleImpl(node, GLOBALMENU.children,
View Full Code Here

    NonLiteral result = new BNode();
    RdfList list = new RdfList(result, mGraph);
    for (GlobalMenuItem item : menus) {
      BNode node = new BNode();
      final String label = item.getLabel();
      Literal labelLiteral = new PlainLiteralImpl(label);
      mGraph.add(new TripleImpl(node, RDFS.label,labelLiteral));
      final String description = item.getDescription();
      if (description != null) {
        Literal descLiteral = new PlainLiteralImpl(description);
        mGraph.add(new TripleImpl(node, DCTERMS.description, descLiteral));
      }
      final String path = item.getPath();
      if (path != null) {
        Literal pathLiteral = LiteralFactory.getInstance().
            createTypedLiteral(path);
        mGraph.add(new TripleImpl(node, GLOBALMENU.path, pathLiteral));
      }
      mGraph.add(new TripleImpl(node, RDF.type, GLOBALMENU.MenuItem));
      list.add(node);
View Full Code Here

  @Test
  public void baseUriTransformation() {
    MGraph mGraph = new SimpleMGraph();
    String xml = "<a href=\"" + UriMutatorIterator.BASE_URI_PLACEHOLDER +
      REFERENCED_BUNDLE_NAME + "/bla\"/>";
    Literal literal = new TypedLiteralImpl(xml,
          UriMutatorIterator.XML_LITERAL);
    String expectedXml = "<a href=\"" + HOST +
      "bundle-doc/"+ REFERENCED_BUNDLE_NAME +"/bla\"/>";
    Literal expectedLiteral = new TypedLiteralImpl(expectedXml,
          UriMutatorIterator.XML_LITERAL);
    UriRef uriRef = new UriRef("bla");
      mGraph.add(new TripleImpl(uriRef, uriRef, literal));
    Iterator<Triple> it = new UriMutatorIterator(mGraph.iterator(), HOST,
        ORIGIN_BUNDLE_NAME);
View Full Code Here

TOP

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

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.