translate
Class MapImporter

java.lang.Object
  extended by translate.MapImporter

public class MapImporter
extends java.lang.Object

Class for loading an object model from an XML file and loading a map from an XML file.


Field Summary
private  java.lang.String ABSTRACT_OBJECT
           
private  java.util.HashSet<java.lang.String> abstractTypes
          abstract object classes
private  java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> classAttributes
          attributes for each class
private  java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> classHierarchy
          inheritance lists for each class
private  java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> classProperties
          properties for each class
private  java.util.HashMap<java.lang.String,java.lang.String> classVariables
          a mapping of class variables to default values
private  java.lang.String CONSTRUCTED_OBJECT
           
private  long ID_COUNTER
          used for assigning unique identifiers
private  java.util.HashSet<java.lang.String> objectTypes
          constructed object classes
(package private)  java.util.ArrayList<RelationValue> relations
          the relation values
private  java.util.HashSet<java.lang.String> relationTypes
          spatial relation classes
private  java.lang.String SPATIAL_RELATION
           
 
Constructor Summary
MapImporter(java.lang.String ontologyFile)
          Loads the object model from a specified file.
 
Method Summary
 void convertType(OntologyObject object, java.lang.String className)
          Converts the specified object into the new type.
 OntologyObject copy(OntologyObject object)
          Creates a copy of the specified object.
private  java.util.HashSet<Attribute> getAttributes(org.w3c.dom.Element element)
          Gets the attributes of an instance of a class.
 java.util.ArrayList<java.lang.String> getConstructableRelationTypes()
          Gets a list of spatial relation classes that are instantiable.
 java.util.ArrayList<java.lang.String> getConstructedObjectTypes()
          Gets a list of constructed object classes in the object model.
private  GraphicalObject getGraphics(org.w3c.dom.Element element)
          Gets the graphics for an object.
private  java.util.ArrayList<History> getHistory(org.w3c.dom.Element element)
          Gets the history of an object.
 java.util.ArrayList<RelationValue> getRelations()
          Gets the relation values.
 java.util.ArrayList<java.lang.String> getRelationTypes()
          Gets a list of spatial relation classes in the object model.
 Map importMap(java.lang.String mapFile)
          Imports a map from an XML file
 OntologyObject newInstance(java.lang.String className, long id)
          Constructs a new ontology object.
 void setRelations(java.util.ArrayList<RelationValue> relations)
          Sets the relation values.
private  void traverseElement(org.w3c.dom.Element element, java.util.ArrayList<java.lang.String> hierarchy, java.util.HashSet<java.lang.String> types, java.util.ArrayList<java.lang.String> properties)
          Recursive method for traversing through the classes in the object model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABSTRACT_OBJECT

private java.lang.String ABSTRACT_OBJECT

CONSTRUCTED_OBJECT

private java.lang.String CONSTRUCTED_OBJECT

SPATIAL_RELATION

private java.lang.String SPATIAL_RELATION

objectTypes

private java.util.HashSet<java.lang.String> objectTypes
constructed object classes


relationTypes

private java.util.HashSet<java.lang.String> relationTypes
spatial relation classes


abstractTypes

private java.util.HashSet<java.lang.String> abstractTypes
abstract object classes


classVariables

private java.util.HashMap<java.lang.String,java.lang.String> classVariables
a mapping of class variables to default values


classProperties

private java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> classProperties
properties for each class


classHierarchy

private java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> classHierarchy
inheritance lists for each class


classAttributes

private java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> classAttributes
attributes for each class


relations

java.util.ArrayList<RelationValue> relations
the relation values


ID_COUNTER

private long ID_COUNTER
used for assigning unique identifiers

Constructor Detail

MapImporter

public MapImporter(java.lang.String ontologyFile)
            throws java.lang.Exception
Loads the object model from a specified file.

Parameters:
ontologyFile - - the ontology file
Throws:
java.lang.Exception - - Exceptions that occur from parsing the model
Method Detail

traverseElement

private void traverseElement(org.w3c.dom.Element element,
                             java.util.ArrayList<java.lang.String> hierarchy,
                             java.util.HashSet<java.lang.String> types,
                             java.util.ArrayList<java.lang.String> properties)
Recursive method for traversing through the classes in the object model.

Parameters:
element - - the DOM element
hierarchy - - the list of the inheritance hierarchy
types - - the class names belonging to the base inheritance class

importMap

public Map importMap(java.lang.String mapFile)
              throws java.lang.Exception
Imports a map from an XML file

Parameters:
mapFile - - the map XML file
Returns:
- the map
Throws:
java.lang.Exception - - Exceptions that occur from parsing the map

getHistory

private java.util.ArrayList<History> getHistory(org.w3c.dom.Element element)
Gets the history of an object.

Parameters:
element - - the DOM element
Returns:
- the history

getAttributes

private java.util.HashSet<Attribute> getAttributes(org.w3c.dom.Element element)
Gets the attributes of an instance of a class.

Parameters:
element - - the DOM element
Returns:
- the attributes

getGraphics

private GraphicalObject getGraphics(org.w3c.dom.Element element)
Gets the graphics for an object.

Parameters:
element - - the DOM element
Returns:
- the graphical object or null the element conains no graphics

newInstance

public OntologyObject newInstance(java.lang.String className,
                                  long id)
Constructs a new ontology object. The values for the intstance attributes of the object will be null. If an ID of -1 is specified, then a unique identifier will be generated.

Parameters:
className - - the class name of the new object
id - - the identifier to assign the object
Returns:
- the new ontology object

copy

public OntologyObject copy(OntologyObject object)
Creates a copy of the specified object. All of the attributes will be the same, except for the object ID.

Parameters:
object - - the object to copy
Returns:
- the copy

convertType

public void convertType(OntologyObject object,
                        java.lang.String className)
Converts the specified object into the new type.

Parameters:
object -
className -

setRelations

public void setRelations(java.util.ArrayList<RelationValue> relations)
Sets the relation values.


getRelations

public java.util.ArrayList<RelationValue> getRelations()
Gets the relation values.


getConstructableRelationTypes

public java.util.ArrayList<java.lang.String> getConstructableRelationTypes()
Gets a list of spatial relation classes that are instantiable. For example, Card4 is instantiable while CardinalDirection is not.


getRelationTypes

public java.util.ArrayList<java.lang.String> getRelationTypes()
Gets a list of spatial relation classes in the object model.


getConstructedObjectTypes

public java.util.ArrayList<java.lang.String> getConstructedObjectTypes()
Gets a list of constructed object classes in the object model.