当前位置: 首页>>代码示例>>Java>>正文


Java StrUtils类代码示例

本文整理汇总了Java中org.apache.jena.atlas.lib.StrUtils的典型用法代码示例。如果您正苦于以下问题:Java StrUtils类的具体用法?Java StrUtils怎么用?Java StrUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StrUtils类属于org.apache.jena.atlas.lib包,在下文中一共展示了StrUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replay

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
private Graph replay() {
    IO.close(bout);
    final boolean DEBUG = false;
    
    if ( DEBUG ) {
        System.out.println("== Graph ==");
        RDFDataMgr.write(System.out, baseGraph, Lang.NQ);
        System.out.println("== Replay ==");
        String x = StrUtils.fromUTF8bytes(bout.toByteArray());
        System.out.print(x);
        System.out.println("== ==");
    }
    
    // A completely separate graph (different dataset)
    Graph graph2 = txnGraph();
    
    try(ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray())) {
        RDFPatchOps.applyChange(graph2, bin);
        if ( DEBUG ) {
            System.out.println("== Graph outcome ==");
            RDFDataMgr.write(System.out, graph2, Lang.NT);
            System.out.println("== ==");
        }
        return graph2;
    } catch (IOException ex) { IO.exception(ex); return null; }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:27,代码来源:TestRDFChangesGraph.java

示例2: parseZookeeper

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
private static void parseZookeeper(Model model, ConfCluster confCluster) {
    String qs = StrUtils.strjoinNL(prefixes,
                                   "SELECT * {",
                                   ":zookeeper :server ?X"  ,
                                   "    OPTIONAL { ?X  :hostname ?hostname }",
                                   "    OPTIONAL { ?X  :port ?port }",
                                   "}") ;
    Map<String, VNode> placements = new HashMap<>() ;
    for ( QuerySolution row : Q.queryToList(model, qs) ) {
        String host = Q.getStringOrNull(row, "hostname") ;
        if ( host == null )
            throw new LizardException("No zookeeper host") ;
        String p = Q.getStringOrNull(row, "port") ;
        if ( p == null )
            throw new LizardException("No zookeeper port") ;
        int port = Integer.parseInt(p) ;
        ConfZookeeper confZK = ConfZookeeper.create(host, port) ;
        confCluster.zkServer.add(confZK) ;
    }
}
 
开发者ID:afs,项目名称:lizard,代码行数:21,代码来源:LzConfParserRDF.java

示例3: performQuery

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
public static void performQuery(Dataset ds) {
    //            Quack.setVerbose(true) ;
    //            ARQ.setExecutionLogging(InfoLevel.NONE);

    String x = "<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType15>" ;
    String qs1 = "SELECT * { VALUES ?s {"+x+"} ?s ?p ?o }" ;
    
    String qs2 = StrUtils.strjoinNL("PREFIX : <http://example/>"
                                  ,"SELECT (count(*) AS ?C)  "
                                  ,"{ ?s ?p ?o }" ) ;
    String qs3 = "SELECT * { ?s ?p ?o }" ;
    
    String qs = qs1 ;
    Query q = QueryFactory.create(qs) ;
    performQuery(ds, q);
}
 
开发者ID:afs,项目名称:lizard,代码行数:17,代码来源:DeployDev.java

示例4: parseTable

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
private static <X> RowList<X> parseTable(ItemParser<X> parser, String... s) {        
    RowListBuilder<X> builder = new RowListBuilderBase<>() ;
    
    String x = StrUtils.strjoinNL(s) ;
    Item item = SSE.parse(x) ;

    ItemList list = item.getList() ;
    BuilderLib.checkTag(list, "table") ;
    list = list.cdr() ;

    for (Item e : list) {
        Row<X> r = parseRow(parser, e) ;
        builder.add(r) ;
    }
    return builder.build() ;
}
 
开发者ID:afs,项目名称:quack,代码行数:17,代码来源:QJT.java

示例5: loadOntology

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * Loads an ontology to the triple store, in the
 * default graph.
 * @param fileName File name with the ontology context.
 */
public static void loadOntology(InputStream fileName) {
 
 List<String> ont = new ArrayList<>();
 
 // Check if the ontology is already there
 Dataset dataset = ThingDirectory.get().dataset;
 dataset.begin(ReadWrite.READ);
 try {
  String prefix = StrUtils.strjoinNL
		  ( "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
		  , "PREFIX owl: <http://www.w3.org/2002/07/owl#>");
  String query = prefix + "SELECT ?s WHERE {?s rdf:type owl:Ontology}";
  
  try (QueryExecution qexec = QueryExecutionFactory.create(query, dataset)) {
	  ResultSet result = qexec.execSelect();
	  while (result.hasNext()) {
		  ont.add(result.next().get("s").toString());
	  }
  }
  
 } finally {
  dataset.end();
 }
 
 // Load QUDT ontology
 if (ont.isEmpty()) {
  dataset = ThingDirectory.get().dataset;
     dataset.begin( ReadWrite.WRITE );
     try {
   	  Model m = dataset.getDefaultModel();
   	  //RDFDataMgr.read(m, fileName);
   	  RDFDataMgr.read(m, fileName, Lang.TURTLE);
   	  dataset.commit();
     } finally {
   	  dataset.end();
     }
 }
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:44,代码来源:ThingDescriptionUtils.java

示例6: reversePrefix

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
public Object reversePrefix(String str) {
	for (Iterator<Object> it = conf_prefix.keySet().iterator(); it.hasNext();) {
		String key = (String) it.next();
		if (str.indexOf(key) > -1)
			return StrUtils.replace(str, key, conf_prefix.get(key).toString());
	}

	return str;
}
 
开发者ID:iotoasis,项目名称:SDA,代码行数:10,代码来源:ConfigurationImpl.java

示例7: reverseRoot

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
public String reverseRoot(String path) {
	if (path != null && path.indexOf("{ROOT}") > -1) {
		return StrUtils.replace(path, "{ROOT}", getRoot());
	}

	return path;
}
 
开发者ID:iotoasis,项目名称:SDA,代码行数:8,代码来源:ConfigurationImpl.java

示例8: changes_write_read_05

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
@Test public void changes_write_read_05() {
    byte[] output = write(changes->{
        changes.txnBegin();
        changes.txnCommit();
    });
    assertNotEquals(0, output.length) ;
    String x = StrUtils.fromUTF8bytes(output);
    assertEquals("TX .\nTC .\n", x);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:10,代码来源:TestRDFChanges.java

示例9: main

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
public static void main(String...argv) {
    JenaSystem.init();
    Table table = new PFbyTable.Table() ;
    
    add(table, ":s1", ":o1") ;
    add(table, ":s1", ":o2") ;
    add(table, ":s2", ":o1") ;
    add(table, ":s2", ":o2") ;
    add(table, ":s2", ":o3") ;
    
    Dataset ds = DatasetFactory.create() ;
    
    PropertyFunctionFactory pff = (uri)->new PFbyTable() ;
    // rdf:rest is special to property functions!  
    String iri = "http://example/trans" ;
    PFbyTable.addTable(NodeFactory.createURI(iri), table);
    PropertyFunctionRegistry.get().put(iri, pff) ;
    
    String x = StrUtils.strjoinNL
        ("PREFIX : <http://example/>"
        ,"PREFIX rdf: <"+RDF.getURI()+">"
        ,"PREFIX rdfs: <"+RDFS.getURI()+">"
        //,"SELECT * { ?s ?p ?o . ?s rdfs:member :o1 . ?s rdf:rest :o1 }"
        //,"SELECT * { ?s rdfs:member :o1 }"
        ,"SELECT * { { ?s :trans :o1 } UNION { :s2 :trans ?o }  UNION { ?X :trans ?Y } }"
        ) ;
    Query query = QueryFactory.create(x) ;
    System.out.println(query); 
    
    Op op = Algebra.compile(query) ;
    Op op1 = Algebra.optimize(op) ;
    System.out.println(op1);
    SSE.write(op1); 
    
    QueryExecution qExec = QueryExecutionFactory.create(query, ds) ;
    QueryExecUtils.executeQuery(qExec);
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:38,代码来源:DevPF.java

示例10: queryData

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
private int queryData(Dataset dataset, String toponym){
    int addressCounter = 0;
    log.info("START") ;
    
    long startTime = System.nanoTime() ;
    
    String pre = StrUtils.strjoinNL( 
        "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" ,
        "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" ,
        "PREFIX schema: <http://schema.org/>" ,
        "PREFIX text: <http://jena.apache.org/text#>" ,
        "PREFIX ogc: <http://www.opengis.net/ont/geosparql#>") ;
    String qs = StrUtils.strjoinNL( "SELECT DISTINCT ?s ?address ?wkt " ,
                                " { ?s text:query (schema:streetAddress '" + toponym + "') ;" ,
                                "      schema:streetAddress ?address ;" ,
                                "      ogc:geometry ?geo ." ,
                                "   ?geo ogc:asWKT ?wkt ." ,
                                " }") ;
    
    dataset.begin(ReadWrite.READ) ;
    try {
        Query q = QueryFactory.create(pre + "\n" + qs) ;
        QueryExecution qexec = QueryExecutionFactory.create(q , dataset) ;
        //QueryExecUtils.executeQuery(q, qexec) ;
        ResultSet results = qexec.execSelect();            
        for( ; results.hasNext(); ){
            addressCounter++;
            QuerySolution sol = results.nextSolution();
            System.out.println( sol.get("s") );
            
        }
    } 
    finally { 
        dataset.end() ; 
    }
    long finishTime = System.nanoTime() ;
    double time = (finishTime-startTime)/1.0e6 ;
    log.info(String.format("FINISH - %.2fms", time)) ;
    return addressCounter;
}
 
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:41,代码来源:JenaTextConfigTest.java

示例11: loadOntology

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * Loads an ontology to the triple store, in the
 * default graph.
 * @param fileName File name with the ontology context.
 */
public static void loadOntology(InputStream fileName) {
 
 List<String> ont = new ArrayList<>();
 
 // Check if the ontology is already there
 Dataset dataset = Repository.get().dataset;
 dataset.begin(ReadWrite.READ);
 try {
  String prefix = StrUtils.strjoinNL
		  ( "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
		  , "PREFIX owl: <http://www.w3.org/2002/07/owl#>");
  String query = prefix + "SELECT ?s WHERE {?s rdf:type owl:Ontology}";
  
  try (QueryExecution qexec = QueryExecutionFactory.create(query, dataset)) {
	  ResultSet result = qexec.execSelect();
	  while (result.hasNext()) {
		  ont.add(result.next().get("s").toString());
	  }
  }
  
 } finally {
  dataset.end();
 }
 
 // Load QUDT ontology
 if (ont.isEmpty()) {
  dataset = Repository.get().dataset;
     dataset.begin( ReadWrite.WRITE );
     try {
   	  Model m = dataset.getDefaultModel();
   	  //RDFDataMgr.read(m, fileName);
   	  RDFDataMgr.read(m, fileName, Lang.TURTLE);
   	  dataset.commit();
     } finally {
   	  dataset.end();
     }
 }
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:44,代码来源:ThingDescriptionUtils.java

示例12: browseSemanticWeb

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * Downloads a file making its best:
 * - following redirects
 * - implementing the best content negotiation
 * curl -I -L -H "Accept: application/rdf+xml" http://datos.bne.es/resource/XX947766
 */
public static String browseSemanticWeb(String url) {
    String document = "";
    String acceptHeaderValue = StrUtils.strjoin(",", "application/rdf+xml", "application/turtle;q=0.9", "application/x-turtle;q=0.9", "text/n3;q=0.8", "text/turtle;q=0.8", "text/rdf+n3;q=0.7", "application/xml;q=0.5", "text/xml;q=0.5", "text/plain;q=0.4", "*/*;q=0.2");
    boolean redirect = false;
    try {
        URL obj = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
        conn.setRequestProperty("Accept", acceptHeaderValue);
        conn.setReadTimeout(5000);
        int status = conn.getResponseCode();
        if (status != HttpURLConnection.HTTP_OK) {
            if (status == HttpURLConnection.HTTP_MOVED_TEMP
                    || status == HttpURLConnection.HTTP_MOVED_PERM
                    || status == HttpURLConnection.HTTP_SEE_OTHER) {
                redirect = true;
            }
        }
        if (redirect) {
            String newUrl = conn.getHeaderField("Location");
            String cookies = conn.getHeaderField("Set-Cookie");
            conn = (HttpURLConnection) new URL(newUrl).openConnection();
            conn.setRequestProperty("Cookie", cookies);
        }
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String inputLine;
        StringBuffer html = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            html.append(inputLine);
        }
        in.close();
        document = html.toString();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return document;
}
 
开发者ID:oeg-upm,项目名称:odrlapi,代码行数:43,代码来源:RDFUtils.java

示例13: load3

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * 複数回ロードする。
 */
public static void load3() {
    System.out.println("##### load3 #####");
    GraphStore graphStore = createGraphStore();
    printDebug(graphStore, "before");
    String cmd = StrUtils.strjoin(" ;\n",
            "LOAD <file:/data/rdf/update-data1.ttl> INTO GRAPH <http://sparqlbook.jp/graph>",
            "LOAD <file:/data/rdf/update-data2.ttl> INTO GRAPH <http://sparqlbook.jp/graph>");
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:14,代码来源:LoadExamples.java

示例14: loadData

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * MOVEの実行に先立ち、データをロードする。
 * 
 * @return ロード後のGraphStore
 */
public static GraphStore loadData() {
    GraphStore graphStore = createGraphStore();
    String cmd = StrUtils.strjoin(" ;\n",
            "LOAD <file:/data/rdf/update-data1.ttl> INTO GRAPH <http://sparqlbook.jp/graph1>",
            "LOAD <file:/data/rdf/update-data2.ttl> INTO GRAPH <http://sparqlbook.jp/graph2>",
            "LOAD <file:/data/rdf/update-data3.ttl>"); // default graph
    UpdateAction.parseExecute(cmd, graphStore);
    return graphStore;
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:15,代码来源:MoveExamples.java

示例15: loadData

import org.apache.jena.atlas.lib.StrUtils; //导入依赖的package包/类
/**
 * ADDの実行に先立ち、データをロードする。
 * 
 * @return ロード後のGraphStore
 */
public static GraphStore loadData() {
    GraphStore graphStore = createGraphStore();
    String cmd = StrUtils.strjoin(" ;\n",
            "LOAD <file:/data/rdf/update-data1.ttl> INTO GRAPH <http://sparqlbook.jp/graph1>",
            "LOAD <file:/data/rdf/update-data2.ttl> INTO GRAPH <http://sparqlbook.jp/graph2>",
            "LOAD <file:/data/rdf/update-data3.ttl>"); // default graph
    UpdateAction.parseExecute(cmd, graphStore);
    return graphStore;
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:15,代码来源:AddExamples.java


注:本文中的org.apache.jena.atlas.lib.StrUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。