Protégé-OWL 3.4

edu.stanford.smi.protegex.owl.writer.rdfxml.util
Class Util

java.lang.Object
  extended by edu.stanford.smi.protegex.owl.writer.rdfxml.util.Util

public class Util
extends Object

User: matthewhorridge
The Univeristy Of Manchester
Medical Informatics Group
Date: March 22, 2005

matthew.horridge@cs.man.ac.uk
www.cs.man.ac.uk/~horridgm

Various utility methods that are needed by the resource renderer and axiom renderer etc.


Constructor Summary
Util()
           
 
Method Summary
static XMLWriterNamespaceManager getNamespacePrefixes(NamespaceManager nsm, String defaultNamespace)
          Gets the namespace prefixes for the combination of a NamespaceManager and XMLWriter.
static String getOntologyName(OWLModel model, TripleStore tripleStore)
           
static String getPrefixedName(String fullName, TripleStore tripleStore)
           
static String getResourceAttributeName(RDFResource resource, XMLWriter writer)
          Gets the value for a resource attribute value such as rdf:about or rdf:resource.
static RDFResource getType(RDFResource resource, TripleStore ts)
           
static void inlineObject(Visitable object, TripleStore tripleStore, XMLWriter writer)
          Inserts the object of a triple.
static void insertAboutAttribute(RDFResource resource, XMLWriter writer)
          Inserts an rdf:about attribute for the specified resource.
static void insertIDOrAboutAttribute(RDFResource resource, TripleStore tripleStore, XMLWriter writer)
          Inserts an rdf:ID attribute for the specified resource.
static void insertProperties(RDFResource resource, TripleStore tripleStore, XMLWriter writer)
          Inserts a property-value triple for a specified resource.
static void insertResourceAsElement(RDFResource resource, XMLWriter writer)
          Creates a new element, with a tag name that reflects the default namespace of the XMLWriter
static void insertResourceAttribute(RDFResource resource, XMLWriter writer)
          Inserts an rdf:resource attribute for the specified resource.
static boolean isExcludedProperty(RDFProperty property)
           
static boolean isInDefaultNamespace(RDFResource resource, XMLWriter writer)
          Checks whether a resource is in the default namespace for an XMLWriter
static void renderTypes(RDFResource resource, TripleStore tripleStore, RDFResource excludeType, XMLWriter writer)
          Renders the types for a resource as rdf:type triples.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

isExcludedProperty

public static boolean isExcludedProperty(RDFProperty property)

insertProperties

public static void insertProperties(RDFResource resource,
                                    TripleStore tripleStore,
                                    XMLWriter writer)
                             throws IOException
Inserts a property-value triple for a specified resource.

Parameters:
resource - The resource that the property-value triple is to be inserted for. It is expected that the resource element
Throws:
IOException

inlineObject

public static void inlineObject(Visitable object,
                                TripleStore tripleStore,
                                XMLWriter writer)
                         throws IOException
Inserts the object of a triple. If the object can be inlined as an attribute (for example if it is a named class) it will be.

Parameters:
object - The object of a triple to be inserted.
writer - The XMLWriter
Throws:
IOException

insertAboutAttribute

public static void insertAboutAttribute(RDFResource resource,
                                        XMLWriter writer)
                                 throws IOException
Inserts an rdf:about attribute for the specified resource. If the resource is in the rdfwriter's default namespace then the attribute value will be a # plus the local name. If the resource is not in the rdfwriter's default namespace then the attribute value will be the full resource URI.

Parameters:
resource - The resource
writer - The rdfwriter
Throws:
IOException

insertIDOrAboutAttribute

public static void insertIDOrAboutAttribute(RDFResource resource,
                                            TripleStore tripleStore,
                                            XMLWriter writer)
                                     throws IOException
Inserts an rdf:ID attribute for the specified resource. If the resource is in the rdfwriter's default namespace then the local name is used. If the resource is not in the rdfwriter's default namespace then the full resource URI is used.

Parameters:
resource - The resource
writer - The rdfwriter
Throws:
IOException

insertResourceAttribute

public static void insertResourceAttribute(RDFResource resource,
                                           XMLWriter writer)
                                    throws IOException
Inserts an rdf:resource attribute for the specified resource. If the resource is in the rdfwriter's default namespace then the attribute value will be a # with the local name concatenated. If the resource is not in the rdfwriter's default namespace then the attribute value will be the full resource URI.

Parameters:
resource - The resource
writer - The rdfwriter
Throws:
IOException

getResourceAttributeName

public static String getResourceAttributeName(RDFResource resource,
                                              XMLWriter writer)
Gets the value for a resource attribute value such as rdf:about or rdf:resource. If possible, the resource name is written as a relative URI that is resolved against the xml:base of the document.

Parameters:
resource - The resource

insertResourceAsElement

public static void insertResourceAsElement(RDFResource resource,
                                           XMLWriter writer)
                                    throws IOException
Creates a new element, with a tag name that reflects the default namespace of the XMLWriter

Parameters:
resource - The resource to be inserted as an element.
writer - The XML rdfwriter that the element will be written to.
Throws:
IOException

isInDefaultNamespace

public static boolean isInDefaultNamespace(RDFResource resource,
                                           XMLWriter writer)
Checks whether a resource is in the default namespace for an XMLWriter

Parameters:
resource - The resource to be checked.
writer - The XMLWriter that the resource's namespace should be checked against.
Returns:
true if the resource is in the rdfwriter's default namespace or false if the resource is not in the rdfwriter's default namespace.

getNamespacePrefixes

public static XMLWriterNamespaceManager getNamespacePrefixes(NamespaceManager nsm,
                                                             String defaultNamespace)
Gets the namespace prefixes for the combination of a NamespaceManager and XMLWriter. The default namespace for the rdfwriter may not be the same as the default namespace in the namespace manager, so the result of this method does not include the prefix for the default namespace in the rdfwriter.

Parameters:
nsm - The NamspaceManager
defaultNamespace - The default namespace
Returns:
A Map of String pairs. The keyset contains the prefixes.

renderTypes

public static void renderTypes(RDFResource resource,
                               TripleStore tripleStore,
                               RDFResource excludeType,
                               XMLWriter writer)
                        throws IOException
Renders the types for a resource as rdf:type triples.

Parameters:
resource - The resource whose rdf:type triples are to be rendered.
tripleStore - The triple store that the renderer should render with respect to - only type triples that are asserted in this triple store will be rendered.
excludeType - The one type that should not be rendered - this method expects that this type will have been used in the RDF/XML optimisation practice of putting one of the types as an element tag name.
writer - The XMLWriter that the triples will be added to.
Throws:
IOException

getType

public static RDFResource getType(RDFResource resource,
                                  TripleStore ts)

getOntologyName

public static String getOntologyName(OWLModel model,
                                     TripleStore tripleStore)

getPrefixedName

public static String getPrefixedName(String fullName,
                                     TripleStore tripleStore)

Protégé-OWL 3.4

Submit a bug report or feature request
Copyright (c) 1998-2009 Stanford University.