001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.jena; 019 020import org.apache.jena.atlas.io.AWriter; 021import org.apache.jena.atlas.lib.CharSpace; 022import org.apache.jena.datatypes.RDFDatatype; 023import org.apache.jena.graph.Node; 024import org.apache.jena.riot.out.NodeFormatterNT; 025 026/** 027 * @author awoods 028 * @since 2017/01/03 029 */ 030public class FedoraNodeFormatterNT extends NodeFormatterNT { 031 032 /** 033 * 034 * @param charSpace 035 */ 036 public FedoraNodeFormatterNT(final CharSpace charSpace) { 037 super(charSpace); 038 } 039 040 /** 041 * 042 * @param w 043 * @param n 044 */ 045 @Override 046 public void formatLiteral(final AWriter w, final Node n) { 047 final RDFDatatype dt = n.getLiteralDatatype(); 048 final String lang = n.getLiteralLanguage(); 049 final String lex = n.getLiteralLexicalForm(); 050 051 if (lang != null && !lang.equals("")) { 052 formatLitLang(w, lex, lang); 053 } else if (dt == null) { 054 // RDF 1.0, simple literal. 055 formatLitString(w, lex); 056 // NOTE, Fedora: Remove condition 057// } else if ( JenaRuntime.isRDF11 && dt.equals(XSDDatatype.XSDstring) ) { 058// // RDF 1.1, xsd:string - output as short string. 059// formatLitString(w, lex) ; 060 } else { 061 // Datatype, no language tag, not short string. 062 formatLitDT(w, lex, dt.getURI()); 063 } 064 } 065}