All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ontoware.rdf2go.model.node.impl.LiteralImpl Maven / Gradle / Ivy

Go to download

RDF2go is an implementation-independent Java API with the design goals: portability (hence the name), performance and ease of implementation. This project was started at FZI Forschungszentrum Informatik Karlsruhe, Germany - www.fzi.de

The newest version!
/**
 * LICENSE INFORMATION
 *
 * Copyright 2005-2008 by FZI (http://www.fzi.de).
 * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
 *  = Max Völkel
 *  = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
 *  = 2010
 *
 * Further project information at http://semanticweb.org/wiki/RDF2Go
 */

package org.ontoware.rdf2go.model.node.impl;

import org.ontoware.rdf2go.model.node.BlankNode;
import org.ontoware.rdf2go.model.node.Literal;
import org.ontoware.rdf2go.model.node.Resource;
import org.ontoware.rdf2go.model.node.URI;

/**
 * Subclasses must have valid equals() and hashCode() implementations.
 * @author voelkel
 *
 */
public abstract class LiteralImpl implements Literal {

	/**
     * 
     */
    private static final long serialVersionUID = -4860142603655339470L;

	@Override
    public abstract String getValue(); 

	@Override
    public Resource asResource() throws ClassCastException {
		throw new ClassCastException("Literals are no resources");
	}

	@Override
    public Literal asLiteral() throws ClassCastException {
		return this;
	}

	@Override
    public URI asURI() throws ClassCastException {
		throw new ClassCastException("Literals are no URIs");
	}

	@Override
    public BlankNode asBlankNode() throws ClassCastException {
		throw new ClassCastException("Literals are no BlankNodes");
	}
	
	protected static String sparqlEncode( String raw )  {
		String result = raw;
		result = result.replace("\\","\\\\");
		result = result.replace("'","\\'");
		result = result.replace("\"","\\\"");
		return result;
	}



}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy