gov.nasa.arc.brahms.common.data.format.ontology
Class OntologyFormat

java.lang.Object
  extended by gov.nasa.arc.brahms.common.data.format.ontology.OntologyFormat
All Implemented Interfaces:
IFormat

public class OntologyFormat
extends java.lang.Object
implements IFormat

The OntologyFormat writes out BrahmsObjects in the DARPA Agent Markup Language (DAML) to specify the ontology for a Brahms model used to define policies for the model.

Version:
10 September 2003
Author:
Ron van Hoof

Field Summary
protected static java.lang.String LOG_PROPERTY
           
 
Constructor Summary
OntologyFormat()
          Constructor, creates a new OntologyFormat
 
Method Summary
protected static void closeKAoSMappingFile()
          Closes the KAoS Mapping file.
protected static java.lang.String convertPackageToDirectory(java.lang.String brahmspackage)
          Converts the specified brahms package name into a directory string by converting the dots to path separators.
protected static java.lang.String convertPackageToURL(java.lang.String brahmspackage)
          Converts the specified brahms package name into a URL directory string by converting the dots to URL path separators.
protected static java.lang.String createXMLString(java.lang.String s)
          Creates a new String from the specified String converting special characters such as &, <, >, " and ' to XML codes for support by XML parsers.
static IFormat getFormat()
          Returns an instance of the OntologyFormat
 IFormatter getFormatter(BrahmsObject obj)
          Returns the Ontology formatter for the given object.
protected static java.io.DataOutputStream getKAoSMappingFile(java.util.Properties p)
          Returns the KAoS Mapping file in which fully qualified names for Brahms elements are mapped to the fully qualified URL's for the KAoS ontology elements.
protected static java.io.File getOntologyFile(BrahmsObject o, java.util.Properties p)
          Returns the file name for the ontology file for the given Brahms object.
protected static java.lang.String getOntologyURL(BrahmsObject o, java.util.Properties p)
          Returns the complete URL for the ontology file for the specified BrahmsObject.
 void init()
          Initialize the format linking the objects to the appropriate formatter
protected static java.io.DataOutputStream openKAoSMappingFile(Model model, java.util.Properties p)
          Creates and opens the KAoS Mapping file in which fully qualified names for Brahms elements are mapped to the fully qualified URL's for the KAoS ontology elements.
protected static java.io.DataOutputStream openOntologyFile(BrahmsObject o, java.util.Properties p)
          Determines the file name for the ontology file for the given Brahms object, creates the file, opens it and returns the stream to that file.
 void writeFormat(BrahmsObject obj, java.util.Properties p, java.io.DataOutputStream out)
          Writes the given object out in the format defined for that object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_PROPERTY

protected static final java.lang.String LOG_PROPERTY
See Also:
Constant Field Values
Constructor Detail

OntologyFormat

public OntologyFormat()
Constructor, creates a new OntologyFormat

Method Detail

getFormat

public static IFormat getFormat()
Returns an instance of the OntologyFormat

Returns:
IFormat an OntologyFormat

getOntologyFile

protected static java.io.File getOntologyFile(BrahmsObject o,
                                              java.util.Properties p)
Returns the file name for the ontology file for the given Brahms object. This method should only be used by the model and concepts.

Parameters:
o - the BrahmsObject for which the ontology file is to be determined
p - the Properties with additional information relevant to the ontology generator
Returns:
File the ontology File

getOntologyURL

protected static java.lang.String getOntologyURL(BrahmsObject o,
                                                 java.util.Properties p)
Returns the complete URL for the ontology file for the specified BrahmsObject.

Parameters:
o - the BrahmsObject for which the ontology URL is to be returned
p - the Properties with additional information relevant to determine the URL
Returns:
String the ontology URL for the specified BrahmsObject

openOntologyFile

protected static java.io.DataOutputStream openOntologyFile(BrahmsObject o,
                                                           java.util.Properties p)
Determines the file name for the ontology file for the given Brahms object, creates the file, opens it and returns the stream to that file. This method should only be used by the model and concepts.

Parameters:
o - the BrahmsObject for which a file is to be opened for writing
p - the Properties with additional information relevant to the ontology generator
Returns:
DataOutputStream the stream to write to the file

openKAoSMappingFile

protected static java.io.DataOutputStream openKAoSMappingFile(Model model,
                                                              java.util.Properties p)
Creates and opens the KAoS Mapping file in which fully qualified names for Brahms elements are mapped to the fully qualified URL's for the KAoS ontology elements.

Parameters:
model - the Model for which the mapping file is to be created
p - the Properties with additional information relevant to create the mapping file
Returns:
DataOutputStream the output stream to be used to write mapping information into the file.

getKAoSMappingFile

protected static java.io.DataOutputStream getKAoSMappingFile(java.util.Properties p)
Returns the KAoS Mapping file in which fully qualified names for Brahms elements are mapped to the fully qualified URL's for the KAoS ontology elements.

Parameters:
p - the Properties with additional information relevant to obtain the mapping file
Returns:
DataOutputStream the output stream to be used to write mapping information into the file.

closeKAoSMappingFile

protected static void closeKAoSMappingFile()
Closes the KAoS Mapping file.


convertPackageToDirectory

protected static java.lang.String convertPackageToDirectory(java.lang.String brahmspackage)
Converts the specified brahms package name into a directory string by converting the dots to path separators.

Parameters:
brahmspackage - the package to be converted
Returns:
String the converted package

convertPackageToURL

protected static java.lang.String convertPackageToURL(java.lang.String brahmspackage)
Converts the specified brahms package name into a URL directory string by converting the dots to URL path separators.

Parameters:
brahmspackage - the package to be converted
Returns:
String the converted package

createXMLString

protected static java.lang.String createXMLString(java.lang.String s)
Creates a new String from the specified String converting special characters such as &, <, >, " and ' to XML codes for support by XML parsers. XML parsers cannot handle those special characters in Strings.

Parameters:
s - the String to be converted to an XML String
Returns:
String the converted XML String

init

public void init()
Initialize the format linking the objects to the appropriate formatter


getFormatter

public IFormatter getFormatter(BrahmsObject obj)
Returns the Ontology formatter for the given object.

Specified by:
getFormatter in interface IFormat
Parameters:
obj - the BrahmsObject to be formatted
Returns:
IFormatter the object containing the formatting logic for the object

writeFormat

public void writeFormat(BrahmsObject obj,
                        java.util.Properties p,
                        java.io.DataOutputStream out)
Writes the given object out in the format defined for that object.

Specified by:
writeFormat in interface IFormat
Parameters:
obj - the BrahmsObject to be written out in this format
p - the Properties relevant for the formatting of the output
out - the DataOutputStream to write the format output to


Copyright © 1997-2012 All Rights Reserved.