Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.URIImpl


        when(extractor.getDescription()).thenReturn(ed);

        final TripleHandler th = mock(TripleHandler.class);
        final ExtractionContext extractionContext = new ExtractionContext(
                extractor.getDescription().getExtractorName(),
                new URIImpl("http://fake.document.uri")
        );
        final ExtractionResult er = new ExtractionResultImpl(extractionContext, extractor, th);
        er.notifyIssue(IssueReport.IssueLevel.Fatal  , "Fake fatal error.", 1, 2);
        er.notifyIssue(IssueReport.IssueLevel.Error  , "Fake error."      , 3, 4);
        er.notifyIssue(IssueReport.IssueLevel.Warning, "Fake warning."    , 5, 6);
View Full Code Here


        URI[] result = new URI[header.length];
        int index = 0;
        for (String h : header) {
            String candidate = h.trim();
            if (RDFUtils.isAbsoluteURI(candidate)) {
                result[index] = new URIImpl(candidate);
            } else {
                result[index] = normalize(candidate, documentURI);
            }
            index++;
        }
View Full Code Here

            String current = tokenizer.nextToken();

            result.append(toUpperCase(current.charAt(0))).append(current.substring(1));
        }

        return new URIImpl(result.toString());
    }
View Full Code Here

    private Value getObjectFromCell(String cell) {
        Value object;
        cell = cell.trim();
        if (RDFUtils.isAbsoluteURI(cell)) {
            object = new URIImpl(cell);
        } else {
            URI datatype = XMLSchema.STRING;
            if (isInteger(cell)) {
                datatype = XMLSchema.INTEGER;
            } else if(isFloat(cell)) {
View Full Code Here

    @Test
    public void testWriting() throws TripleHandlerException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        jsonWriter = new JSONWriter(baos);
        final URI documentURI = new URIImpl("http://fake/uri");
        jsonWriter.startDocument(documentURI);
        jsonWriter.receiveTriple(
                new BNodeImpl("bn1"),
                new URIImpl("http://pred/1"),
                new URIImpl("http://value/1"),
                new URIImpl("http://graph/1"),
                null
        );
        jsonWriter.receiveTriple(
                new URIImpl("http://sub/2"),
                new URIImpl("http://pred/2"),
                new LiteralImpl("language literal", "en"),
                new URIImpl("http://graph/2"),
                null
        );
        jsonWriter.receiveTriple(
                new URIImpl("http://sub/3"),
                new URIImpl("http://pred/3"),
                new LiteralImpl("123", new URIImpl("http://datatype")),
                null,
                null
        );
        jsonWriter.endDocument(documentURI);
        jsonWriter.close();
View Full Code Here

    public void testExtractPageMeta() throws RepositoryException {
        assertExtract("html/html-head-meta-extractor.html");
        assertModelNotEmpty();
        assertStatementsSize(null, null, null, 7);
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl("http://purl.org/dc/elements/1.1/title"),
                "XHTML+RDFa example",
                "en"
        );
         assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl("http://purl.org/dc/elements/1.1/language"),
                "en",
                "en"
        );
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl("http://purl.org/dc/elements/1.1/subject"),
                "XHTML+RDFa, semantic web",
                "en"
        );
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl("http://purl.org/dc/elements/1.1/format"),
                "application/xhtml+xml",
                "en"
        );
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl("http://purl.org/dc/elements/1.1/description"),
                "Example for Extensible Hypertext Markup Language + Resource Description Framework – in – attributes.",
                "en"
        );
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl(vSINDICE.NAMESPACE.toString() + "robots"),
                "index, follow",
                "en"
        );
        assertContains(
                new URIImpl("http://bob.example.com/"),
                new URIImpl(vSINDICE.NAMESPACE.toString() + "content-language"),
                "en",
                "en"
        );
    }
View Full Code Here

 
  private static Element handleProperty(Element propertyElement){
    String uriAttribute=propertyElement.getAttributeValue("uri");
    String classAttribute=propertyElement.getAttributeValue("class");
    String label=propertyElement.getChild("label", fresnelNS).getChildTextTrim("title", fresnelNS);
    URI pURI=new URIImpl(uriAttribute);   
           
    Element tableRow=new Element("tr")
      .setAttribute("style","padding: 0px; margin: 0px; border: 0px;");
   
    Element property=new Element("div")
      .setAttribute("class", "property-div")
      .setAttribute("style", "overflow: hidden;")
        .addContent(new Element("span")
          .setAttribute("style","vertical-align: top; margin: 0px; padding: 0px;")
            .addContent(new Element("table")
              .setAttribute("style","border: 0px; width: 100%; padding: 0px; margin: 0px; border-spacing: 0px;")
              .addContent(tableRow)));
   
    if (classAttribute!=null) {
      property.setAttribute("style", property.getAttributeValue("style")+";"+classAttribute);
    }
   
  // add label
   
    // div holding the label text
    Element labelDiv=new Element("div")
                    .setAttribute("style","cursor: help;")
                    .setAttribute("class","tooltip")
                    .setAttribute("title","Property: "+pURI.stringValue());

    if (label!=null && !label.trim().equals("")) {
      labelDiv.setText(label);
    } else {
      labelDiv.setText(pURI.getLocalName());
    }

    // td holding the labelDiv
    Element labelElement=new Element("td")
                  .setAttribute("style","width: 35%; vertical-align: top; padding: 0px; margin: 0px; border: 0px;")
                  .addContent(labelDiv);

    // add td holding label to row
    tableRow.addContent(labelElement);             
               
  // add values
    Element valuesElement=new Element("td")
      .setAttribute("style","width: *; vertical-align: top; padding: 0px; margin: 0px; border: 0px;");
   
   
    // get Content before/after declarations for value
    String beforeText="",afterText="";
   
   
    try {
      //Element before=(Element) XPath.selectSingleNode(propertyElement, "//content/before");
      Element before=propertyElement
        .getChild("values", fresnelNS)
          .getChild("content", fresnelNS)
            .getChild("before", fresnelNS);
      if (before != null) {
        beforeText=before.getTextTrim();
      }
    } catch (NullPointerException e1) {//(JDOMException e1) {     
      //e1.printStackTrace();
    }
    try {
      //Element after=(Element) XPath.selectSingleNode(propertyElement, "//content/after");
      Element after=propertyElement
      .getChild("values", fresnelNS)
        .getChild("content", fresnelNS)
          .getChild("after", fresnelNS);   
      if (after !=null) {
        afterText=after.getTextTrim();
      }
    } catch (NullPointerException e1) {//(JDOMException e1) {     
      //e1.printStackTrace();
    }
   
   
    Element values=new Element("div");   
    List<Element> valuesData=propertyElement.getChild("values",fresnelNS).getChildren("value",fresnelNS)
    for (Element value:valuesData) {
      values.addContent(beforeText);
      String text=value.getChildTextTrim("title", fresnelNS);
      String outputType=value.getAttributeValue("output-type");
      if (outputType!=null) {
        if (outputType.equals("http://www.w3.org/2004/09/fresnel#externalLink")) {
          values.addContent(new Element("a")
            .setAttribute("href", text)
            .setText(text));
        } else if (outputType.equals("http://www.w3.org/2004/09/fresnel#image")) {
          values.addContent(new Element("img")
            .setAttribute("src", text));         
        } else {         
          values.addContent(text+"(unknown output-type: "+outputType+")");
        }
      } else {
        try {
          URI textURI=new URIImpl(text);
          values.addContent(new Element("a")
            .setAttribute("href", text)
            .setText(text));
          String uriEncoded=URLEncoder.encode(textURI.stringValue(), "UTF-8");
          values.addContent(new Element("a")
              .setAttribute("onclick", "setHrefs()")
              .setAttribute("href", "?resource="+uriEncoded)
              .setAttribute("class", "tooltip")
              .setAttribute("title","Lens: DEFAULT :: Resource: "+textURI)
View Full Code Here

 
  private static Element handleMetaproperty(Element propertyElement){
    String uriAttribute=propertyElement.getAttributeValue("uri");
    String classAttribute=propertyElement.getAttributeValue("class");
    String label=propertyElement.getChild("label", fresnelNS).getChildTextTrim("title", fresnelNS);
    URI pURI=new URIImpl(uriAttribute);   
           
    Element tableRow=new Element("tr")
      .setAttribute("style","padding: 0px; margin: 0px; border: 0px;");
   
    Element property=new Element("div")
      .setAttribute("class", "property-div")
      .setAttribute("style", "overflow: hidden;")
        .addContent(new Element("span")
          .setAttribute("style","vertical-align: top; margin: 0px; padding: 0px;")
            .addContent(new Element("table")
              .setAttribute("style","border: 0px; width: 100%; padding: 0px; margin: 0px; border-spacing: 0px;")
              .addContent(tableRow)));
   
    if (classAttribute!=null) {
      property.setAttribute("style", property.getAttributeValue("style")+";"+classAttribute);
    }
   
  // add label
   
    // div holding the label text
    Element labelDiv=new Element("div")
                    .setAttribute("style","cursor: help;")
                    .setAttribute("class","tooltip")
                    .setAttribute("title","Property: "+pURI.stringValue());

    if (label!=null && !label.trim().equals("")) {
      labelDiv.setText(label);
    } else {
      labelDiv.setText(pURI.getLocalName());
    }

    // td holding the labelDiv
    Element labelElement=new Element("td")
                  .setAttribute("style","width: 35%; vertical-align: top; padding: 0px; margin: 0px; border: 0px;")
                  .addContent(labelDiv);

    // add td holding label to row
    tableRow.addContent(labelElement);             
               
    // add values
    Element valuesElement=new Element("td")
      .setAttribute("style","width: *; vertical-align: top; padding: 0px; margin: 0px; border: 0px;");
   
   
    // get Content before/after declarations for value
    String beforeText="",afterText="";
   
   
    try {
      //Element before=(Element) XPath.selectSingleNode(propertyElement, "//content/before");
      Element before=propertyElement
        .getChild("values", fresnelNS)
          .getChild("content", fresnelNS)
            .getChild("before", fresnelNS);
      if (before != null) {
        beforeText=before.getTextTrim();
      }
    } catch (NullPointerException e1) {//(JDOMException e1) {     
      //e1.printStackTrace();
    }
    try {
      //Element after=(Element) XPath.selectSingleNode(propertyElement, "//content/after");
      Element after=propertyElement
      .getChild("values", fresnelNS)
        .getChild("content", fresnelNS)
          .getChild("after", fresnelNS);   
      if (after !=null) {
        afterText=after.getTextTrim();
      }
    } catch (NullPointerException e1) {//(JDOMException e1) {     
      //e1.printStackTrace();
    }
   
   
    Element values=new Element("div");   
    List<Element> valuesData=propertyElement.getChild("values",fresnelNS).getChildren("value",fresnelNS)
    for (Element value:valuesData) {
      values.addContent(beforeText);
      String text=value.getChildTextTrim("title", fresnelNS);
      String outputType=value.getAttributeValue("output-type");
      if (outputType!=null) {
        if (outputType.equals("http://www.w3.org/2004/09/fresnel#externalLink")) {
          values.addContent(new Element("a")
            .setAttribute("href", text)
            .setText(text));
        } else if (outputType.equals("http://www.w3.org/2004/09/fresnel#image")) {
          values.addContent(new Element("img")
            .setAttribute("src", text));         
        } else {
          //NEW: take out unknown output-type
          values.addContent(text);//+"(unknown output-type: "+outputType+")");
        }
      } else {
        try {
          URI textURI=new URIImpl(text);
          values.addContent(new Element("a")
            .setAttribute("href", text)
            .setText(text));
          String uriEncoded=URLEncoder.encode(textURI.stringValue(), "UTF-8");
          values.addContent(new Element("a")
              .setAttribute("onclick", "setHrefs()")
              .setAttribute("href", "?resource="+uriEncoded)
              .setAttribute("class", "tooltip")
              .setAttribute("title","Lens: DEFAULT :: Resource: "+textURI)
View Full Code Here

        sailGraph.shutdown();
    }

    @Test
    public void testAll() throws Exception {
        URI planet = new URIImpl("http://example.org/terms/planet");
        URI gasGiant = new URIImpl("http://example.org/terms/gasGiant");
        URI narrower = new URIImpl("http://www.w3.org/2004/02/skos/core#narrower");

        SailConnection sc = sail.getConnection();
        try {
            sc.begin();
            sc.addStatement(planet, RDFS.LABEL, new LiteralImpl("planet", "en"));
View Full Code Here

    SailRepository myRepository = new SailRepository(new MemoryStore());
    myRepository.initialize();
    SailRepositoryConnection con = myRepository.getConnection();
    con.add(file, "", RDFFormat.TURTLE);
   
    RepositoryResult<Statement> result = con.getStatements(null, new URIImpl("http://isi.edu/integration/karma/dev#hasWorksheetHistory"), null, false);
    if(result.hasNext()) {
      Statement stmt = result.next();
      String history = stmt.getObject().stringValue();
      return new JSONArray(history);
    }
View Full Code Here

TOP

Related Classes of org.openrdf.model.impl.URIImpl

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.