Package org.apache.clerezza.rdf.core

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


public class WebRenderingFunctionsTest {
  @Test
  public void dateTest() throws IOException {

    Date date = new Date();
    TypedLiteral dateLiteral = LiteralFactory.getInstance()
        .createTypedLiteral(date);

    WebRenderingFunctions webRenderingFunctions = new WebRenderingFunctions(
        null, null, null, null);
    RenderingFunction<Object, String> dateFunction = webRenderingFunctions
View Full Code Here


@Service(MetaDataGenerator.class)
public class GenericMetaDataGenerator implements MetaDataGenerator {

  @Override
  public void generate(GraphNode node, byte[] data, MediaType mediaType) {
    TypedLiteral dateLiteral = LiteralFactory.getInstance()
          .createTypedLiteral(new Date());
    if(node.getObjects(DCTERMS.dateSubmitted).hasNext()) {
      if(node.getObjects(DCTERMS.modified).hasNext()) {
        node.deleteProperties(DCTERMS.modified);
      }
View Full Code Here

          return (String) value;
        }
        String stringValue;
        if (value instanceof Literal) {
          if (value instanceof TypedLiteral) {
            TypedLiteral typedLiteral = (TypedLiteral) value;
            if (typedLiteral.getDataType().equals(RDF_XML_LITERAL)) {
              return typedLiteral.getLexicalForm();
            }
          }
          stringValue = ((Literal) value).getLexicalForm();
        } else {
          if (value instanceof UriRef) {
View Full Code Here

    collectionCreator.createContainingCollections(infoDiscoBitUri);
    Lock writeLock = mGraph.getLock().writeLock();
    writeLock.lock();
    try {
      infoDiscoBitNode.addProperty(RDF.type, DISCOBITS.InfoDiscoBit);
      TypedLiteral dataLiteral = LiteralFactory.getInstance().createTypedLiteral(data);
      infoDiscoBitNode.deleteProperties(DISCOBITS.infoBit);
      infoDiscoBitNode.addProperty(DISCOBITS.infoBit, dataLiteral);
      TypedLiteral mediaTypeLiteral = LiteralFactory.getInstance().createTypedLiteral(mediaType.toString());
      infoDiscoBitNode.deleteProperties(DISCOBITS.mediaType);
      infoDiscoBitNode.addProperty(DISCOBITS.mediaType,mediaTypeLiteral);
    } finally {
      writeLock.unlock();
    }
View Full Code Here

  public void replaceLiteral() throws Exception {
    File dataDir = File.createTempFile("test", "externalizer");
    dataDir.delete();
    dataDir.mkdir();
    ExternalizingMGraph graph = new ExternalizingMGraph(new SimpleMGraph(), dataDir);
    TypedLiteral lit = new TypedLiteralImpl("jkjkj", ExternalizingMGraph.base64Uri);
    UriRef replacement = graph.replace(lit);
    TypedLiteral reconstructed = graph.getLiteralForUri(replacement.getUnicodeString());
    Assert.assertEquals(replacement, graph.replace(reconstructed));
  }
View Full Code Here

    Resource object = triple.getObject();
    if (object instanceof UriRef) {
      object = replacePlaceHolder((UriRef) object);
    } else if (object instanceof TypedLiteral) {
      TypedLiteral literal = (TypedLiteral) object;
      if (literal.getDataType().equals(XML_LITERAL)) {
        object = replacePlaceHolderInUrl(literal);
      }
    }
    return new TripleImpl(subject, predicate, object);
  }
View Full Code Here

    }
    Triple restTriple = permissionMGraph.filter(list, rest, null).next();
    NonLiteral restList = (NonLiteral) restTriple.getObject();
    readList(restList, permissionMGraph, target);
    Triple firstTriple = permissionMGraph.filter(list, first, null).next();
    TypedLiteral firstValue = (TypedLiteral) firstTriple.getObject();
    String value = LiteralFactory.getInstance().createObject(String.class, firstValue);
    target.addFirst(value);
  }
View Full Code Here

      if (obj instanceof ReplacementLiteral) {
        ReplacementLiteral other = (ReplacementLiteral)obj;
        return base16Hash.equals(other.base16Hash);
      }
      if (obj instanceof TypedLiteral) {
        TypedLiteral other = (TypedLiteral)obj;
        return getLexicalForm().equals(other.getLexicalForm()) &&
            getDataType().equals(other.getDataType());
      }
      return false;
    }
View Full Code Here

  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj instanceof TypedLiteral) {
      TypedLiteral other = (TypedLiteral) obj;
      boolean res = getDataType().equals(other.getDataType())
          && getLexicalForm().equals(other.getLexicalForm());
      return res;
    } else {
      return false;
    }
  }
View Full Code Here

  SimpleLiteralFactory simpleLiteralFactory = new SimpleLiteralFactory();

  @Test
  public void longToXsdIntegerAndBackToMany() {
    long value = 14l;
    TypedLiteral tl = simpleLiteralFactory.createTypedLiteral(value);
    Assert.assertEquals(xsdLong, tl.getDataType());
    long longValue = simpleLiteralFactory.createObject(Long.class, tl);
    Assert.assertEquals(value, longValue);
    int intValue = simpleLiteralFactory.createObject(Integer.class, tl);
    Assert.assertEquals(value, intValue);
  }
View Full Code Here

TOP

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

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.