本文整理汇总了Java中org.apache.jena.atlas.io.IndentedWriter类的典型用法代码示例。如果您正苦于以下问题:Java IndentedWriter类的具体用法?Java IndentedWriter怎么用?Java IndentedWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndentedWriter类属于org.apache.jena.atlas.io包,在下文中一共展示了IndentedWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: json
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public static void json(HttpServletRequest req, HttpServletResponse resp, JsonValue responseContent) {
try {
resp.setHeader(HttpNames.hCacheControl, "no-cache");
resp.setHeader(HttpNames.hContentType, WebContent.contentTypeJSON);
resp.setStatus(HttpSC.OK_200);
try(ServletOutputStream out = resp.getOutputStream(); IndentedWriter b = new IndentedWriter(out); ) {
b.setFlatMode(true);
JSON.write(b, responseContent);
b.ensureStartOfLine();
b.flush();
out.write('\n');
}
} catch (IOException ex) {
LOG.warn("json: IOException", ex);
try {
resp.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, "Internal server error");
} catch (IOException ex2) {}
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:S_JSON.java
示例2: outputValuesOneRow
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
private static void outputValuesOneRow(IndentedWriter out, List<Var> variables, Binding row, SerializationContext cxt) {
// A value may be null for UNDEF
for (Var var : variables) {
out.print(" ");
Node value = row.get(var);
if (value == null) {
out.print("UNDEF");
} else {
// Context for bnodes.
// Bnodes don't occur in legal syntax but a rewritten query may
// have them. The output will not be legal SPARQL.
// ARQ (SPARQL with extensions) does parse blankd nodes in VALUES.
SPARQLGenerateFmtUtils.printNode(out, value, cxt);
}
}
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:17,代码来源:SPARQLGenerateQuerySerializer.java
示例3: processResults
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
private void processResults(TarqlQueryExecution ex) throws IOException {
if (testQuery && ex.getFirstQuery().getConstructTemplate() != null) {
IndentedWriter out = new IndentedWriter(System.out);
new FmtTemplate(out, new SerializationContext(ex.getFirstQuery())).format(ex.getFirstQuery().getConstructTemplate());
out.flush();
}
if (ex.getFirstQuery().isSelectType()) {
System.out.println(ResultSetFormatter.asText(ex.execSelect()));
} else if (ex.getFirstQuery().isAskType()) {
System.out.println(ResultSetFormatter.asText(ex.execSelect()));
} else if (ex.getFirstQuery().isConstructType()) {
resultTripleIterator = resultTripleIterator.andThen(ex.execTriples());
} else {
cmdError("Only query forms CONSTRUCT, SELECT and ASK are supported");
}
}
开发者ID:tarql,项目名称:tarql,代码行数:17,代码来源:tarql.java
示例4: writeTurtle
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public void writeTurtle(String baseIRI, PrefixMapping prefixes, boolean writeBase) {
// Auto-register RDF prefix so that rdf:type is displayed well
// All other prefixes come from the query and should be as author intended
prefixes = ensureRDFPrefix(prefixes);
if (writeBase) {
// Jena's streaming Turtle writers don't output base even if it is provided,
// so we write it directly.
IndentedWriter w = new IndentedWriter(out);
RiotLib.writeBase(w, baseIRI);
w.flush();
}
StreamRDF writer = new WriterStreamRDFBlocks(out);
if (dedupWindowSize > 0) {
writer = new StreamRDFDedup(writer, dedupWindowSize);
}
writer.start();
writer.base(baseIRI);
for (Entry<String, String> e : prefixes.getNsPrefixMap().entrySet()) {
writer.prefix(e.getKey(), e.getValue());
}
StreamOps.sendTriplesToStream(triples, writer);
writer.finish();
}
开发者ID:tarql,项目名称:tarql,代码行数:26,代码来源:StreamingRDFWriter.java
示例5: handleMissingConfigFile
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
private static void handleMissingConfigFile(Path path) {
//throw new DeltaConfigException("No such file: "+path.toString());
JsonObject obj = JSONX.buildObject(b->{
b.key(F_VERSION).value(DeltaConst.SYSTEM_VERSION);
// Default log provider
b.key(F_LOG_TYPE).value(DeltaConst.LOG_FILE);
});
try ( IndentedWriter out = new IndentedWriter(Files.newOutputStream(path)); ) {
JSON.write(out, obj);
out.ensureStartOfLine();
} catch (IOException ex) { IO.exception(ex); }
}
开发者ID:afs,项目名称:rdf-delta,代码行数:13,代码来源:LocalServerConfig.java
示例6: handle
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
@Override
public void handle(Patch patch) {
IndentedWriter x = new IndentedWriter(System.out) ;
x.setLineNumbers(true);
x.setLinePrefix("GSP>> ");
RDFChanges scData = new RDFChangesWriteUpdate(x) ;
patch.play(scData);
x.flush();
}
开发者ID:afs,项目名称:rdf-delta,代码行数:10,代码来源:PHandlerGSPOutput.java
示例7: formatPattern
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public static void formatPattern(IndentedWriter out, BasicPattern pattern, SerializationContext sCxt) {
boolean first = true;
for (Triple triple : pattern) {
if (!first) {
out.print("\n");
}
printTriple(out, triple, sCxt);
out.print(" .");
first = false;
}
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:12,代码来源:SPARQLGenerateFmtUtils.java
示例8: printTriple
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public static void printTriple(IndentedWriter out, Triple triple, SerializationContext sCxt) {
printNode(out, triple.getSubject(), sCxt);
out.print(" ");
printNode(out, triple.getPredicate(), sCxt);
out.print(" ");
printNode(out, triple.getObject(), sCxt);
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:8,代码来源:SPARQLGenerateFmtUtils.java
示例9: SPARQLGenerateFmtExprARQVisitor
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public SPARQLGenerateFmtExprARQVisitor(IndentedWriter writer, SerializationContext cxt) {
out = writer;
if (cxt == null) {
context = new SerializationContext();
} else {
context = cxt;
}
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:9,代码来源:SPARQLGenerateFmtExprSPARQL.java
示例10: SPARQLGenerateQuerySerializer
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public SPARQLGenerateQuerySerializer(IndentedWriter out, SerializationContext context) {
this.out = out;
this.context = context;
this.fmtTemplate = new SPARQLGenerateFormatterTemplate(out, context);
this.fmtExpr = new SPARQLGenerateFmtExprSPARQL(out, context);
this.fmtElement = new SPARQLGenerateFormatterElement(out, context);
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:8,代码来源:SPARQLGenerateQuerySerializer.java
示例11: appendVarList
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
void appendVarList(Query query, IndentedWriter sb, List<String> vars) {
boolean first = true;
for (String varName : vars) {
Var var = Var.alloc(varName);
if (!first) {
sb.print(" ");
}
sb.print(var.toString());
first = false;
}
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:13,代码来源:SPARQLGenerateQuerySerializer.java
示例12: appendURIList
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
static void appendURIList(Query query, IndentedWriter sb, List<Node> vars) {
SerializationContext cxt = new SerializationContext(query);
boolean first = true;
for (Node node : vars) {
if (!first) {
sb.print(" ");
}
SPARQLGenerateFmtUtils.printNode(sb, node, cxt);
first = false;
}
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:12,代码来源:SPARQLGenerateQuerySerializer.java
示例13: slotToString
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
protected String slotToString(Node n) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try (IndentedWriter w = new IndentedWriter(os)) {
SPARQLGenerateFmtUtils.printNode(w, n, context);
}
return new String(os.toByteArray(), Charset.defaultCharset());
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:9,代码来源:SPARQLGenerateFormatterBase.java
示例14: printYAML
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public static void printYAML(IndentedWriter w, Object obj) {
if ( obj == null ) {
w.print("<<null>>");
return ;
}
if ( obj instanceof List ) {
@SuppressWarnings("unchecked")
List<Object> list = (List<Object>)obj ;
w.print("(\n");
w.incIndent();
list.forEach( x-> {
printYAML(w,x) ;
w.println();
}) ;
w.decIndent();
w.print(")");
} else if ( obj instanceof Map ) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>)obj ;
w.print("{ ");
w.incIndent();
map.keySet().forEach( k-> {
w.printf("%-8s : ", k) ;
Object v = map.get(k) ;
if ( compound(v) )
w.println();
printYAML(w, v) ;
w.println();
}) ;
w.decIndent();
w.print("}");
//w.println();
} else {
w.printf("%s[%s]",obj,obj.getClass().getName()) ;
}
}
开发者ID:afs,项目名称:lizard,代码行数:38,代码来源:YAML.java
示例15: toString
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
@Override
public String toString() {
StringWriter sw = new StringWriter() ;
IndentedWriter out = new IndentedWriter(sw) { } ;
print(out) ;
out.flush() ;
return sw.toString() ;
}
开发者ID:afs,项目名称:lizard,代码行数:9,代码来源:ConfCluster.java
示例16: write
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
@Override
public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
{
// Writers are discouraged : just hope the charset is UTF-8.
IndentedWriter x = RiotLib.create(out) ;
SSE.write(x, graph) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:8,代码来源:ExRIOT_out3.java
示例17: main
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public static void main(String[] args)
{
// Create the data.
// This wil be the background (unnamed) graph in the dataset.
Model model = createModel() ;
// First part or the query string
String prolog = "PREFIX dc: <"+DC.getURI()+">" ;
// Query string.
String queryString = prolog + NL +
"SELECT ?title WHERE {?x dc:title ?title}" ;
Query query = QueryFactory.create(queryString) ;
// Print with line numbers
query.serialize(new IndentedWriter(System.out,true)) ;
System.out.println() ;
// Create a single execution of this query, apply to a model
// which is wrapped up as a Dataset
// Or QueryExecutionFactory.create(queryString, model) ;
try(QueryExecution qexec = QueryExecutionFactory.create(query, model)) {
// A ResultSet is an iterator - any query solutions returned by .next()
// are not accessible again.
// Create a ResultSetRewindable that can be reset to the beginning.
// Do before first use.
ResultSetRewindable rewindable = ResultSetFactory.makeRewindable(qexec.execSelect()) ;
ResultSetFormatter.out(rewindable) ;
rewindable.reset() ;
ResultSetFormatter.out(rewindable) ;
}
}
开发者ID:xcurator,项目名称:xcurator,代码行数:35,代码来源:ExQuerySelect2.java
示例18: writeNTriples
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public void writeNTriples() {
StreamRDF writer = new WriterStreamRDFPlain(new IndentedWriter(out));
if (dedupWindowSize > 0) {
writer = new StreamRDFDedup(writer, dedupWindowSize);
}
writer.start();
StreamOps.sendTriplesToStream(triples, writer);
writer.finish();
}
开发者ID:tarql,项目名称:tarql,代码行数:10,代码来源:StreamingRDFWriter.java
示例19: collected
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
private void send$() {
long number = counter.incrementAndGet();
byte[] bytes = collected();
String idStr;
if ( patchId != null )
idStr = Id.str(patchId);
else
idStr = Long.toString(number);
FmtLog.info(LOG, "Send patch %s (%d bytes) -> %s", idStr, bytes.length, label);
if ( false ) {
if ( LOG.isDebugEnabled() ) {
// Ouch.
String s = new String(bytes, StandardCharsets.UTF_8);
LOG.debug("== Sending ...");
// Do NOT close!
IndentedWriter w = IndentedWriter.stdout;
String x = w.getLinePrefix();
w.setLinePrefix(">> ");
w.print(s);
w.setLinePrefix(x);
if ( ! s.endsWith("\n") )
w.println();
w.flush();
LOG.debug("== ==");
}
}
int attempts = 0 ;
for(;;) {
HttpPost postRequest = new HttpPost(urlSupplier.get());
postRequest.setEntity(new ByteArrayEntity(bytes));
try(CloseableHttpResponse r = httpClient.execute(postRequest) ) {
attempts++;
statusLine = r.getStatusLine();
response = readResponse(r);
int sc = r.getStatusLine().getStatusCode();
if ( sc >= 200 && sc <= 299 )
return ;
if ( sc >= 300 && sc <= 399 ) {
FmtLog.info(LOG, "Send patch %s HTTP %d", idStr, sc);
throw new DeltaHttpException(sc, "HTTP Redirect");
}
if ( sc == 401 && attempts == 1 && resetAction != null ) {
resetAction.run();
continue;
}
if ( sc >= 400 && sc <= 499 )
throw new DeltaHttpException(sc, r.getStatusLine().getReasonPhrase());
if ( sc >= 500 )
throw new DeltaHttpException(sc, r.getStatusLine().getReasonPhrase());
break;
}
catch (DeltaHttpException ex) { throw ex; }
catch (IOException e) { throw IOX.exception(e); }
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:62,代码来源:RDFChangesHTTP.java
示例20: SPARQLGenerateFmtExprSPARQL
import org.apache.jena.atlas.io.IndentedWriter; //导入依赖的package包/类
public SPARQLGenerateFmtExprSPARQL(IndentedWriter writer, SerializationContext cxt) {
super(writer, cxt);
visitor = new SPARQLGenerateFmtExprARQVisitor(writer, cxt);
}
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:5,代码来源:SPARQLGenerateFmtExprSPARQL.java
注:本文中的org.apache.jena.atlas.io.IndentedWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论