be.SIRAPRISE.client
Class Heading

java.lang.Object
  extended by be.SIRAPRISE.util.IntersectableMap<K,V>
      extended by be.SIRAPRISE.util.IntersectableLinkedHashMap<java.lang.String,TypeDeclaration>
          extended by be.SIRAPRISE.client.Heading
All Implemented Interfaces:
java.util.Map<java.lang.String,TypeDeclaration>

public class Heading
extends IntersectableLinkedHashMap<java.lang.String,TypeDeclaration>

A Heading maps attribute names onto typenames.

Author:
Erwin Smout

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
Heading()
           
 
Method Summary
 void add(java.lang.String attributeName, Heading heading)
          Adds a relation-typed attribute to the heading.
 void add(java.lang.String attributeName, java.lang.String typeName)
          Adds a scalar attribute to the heading.
 void add(java.lang.String attributeName, TypeDeclaration typeDeclaration)
          Adds an attribute declaration to the heading.
 java.util.Set<java.lang.String> getAttributeNames()
          Gets The set of attribute names
 Heading getHeading(java.lang.String attributeName)
          Gets the heading object defining the relation type of the named attribute, which must be relation-typed
 java.lang.String getTypeName(java.lang.String attributeName)
          Gets the typename of the named attribute.
 boolean isStrictUnionCompatibleWith(Heading other)
          Checks if the heading of another Relvar is exactly the same as this one : The set of attribute names in the other heading is equal to the set of attribute names in this heading The Type associated with each attribute name is the same in both headings
 java.lang.String print()
          Gets the heading specification in textual format HEADING(ATTRIBUTENAME(TYPENAME)RELATIONTYPEDATTRIBUTENAME(RELATION(HEADING(...))))
 java.lang.String printXML()
          Gets the heading specification in XML style
 Heading subHeadingExcluding(java.util.Set<java.lang.String> attributeNames)
          Gets a Heading that includes only the attribute definitions from this Heading whose attribute names do not appear in the given set
 Heading subHeadingIncluding(java.util.Set<java.lang.String> attributeNames)
          Gets a Heading that includes only the attribute definitions from this Heading whose attribute names appear in the given set
 void toStream1_0(java.io.DataOutputStream outputStream)
          Writes the heading to an outputstream in the V1.0 format
 
Methods inherited from class be.SIRAPRISE.util.IntersectableMap
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, intersect, intersect, isEmpty, keySet, minus, minus, put, putAll, remove, size, toString, union, union, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Heading

public Heading()
Method Detail

add

public final void add(java.lang.String attributeName,
                      Heading heading)
               throws DuplicateException
Adds a relation-typed attribute to the heading. The relation type of the attribute is defined by the given heading.

Parameters:
attributeName - The name of a relation-typed attribute to be added to the heading.
heading - The relation heading defining the relation type of the attribute
Throws:
DuplicateException - If the attributeName is already present in the heading

add

public final void add(java.lang.String attributeName,
                      java.lang.String typeName)
               throws DuplicateException
Adds a scalar attribute to the heading.

Parameters:
attributeName - The name of the attribute to be added to the heading.
typeName - The name of the attribute's type.
Throws:
DuplicateException - If the attributeName is already present in the heading

add

public final void add(java.lang.String attributeName,
                      TypeDeclaration typeDeclaration)
               throws DuplicateException
Adds an attribute declaration to the heading.

Parameters:
attributeName - The name of the attribute to be added to the heading.
typeDeclaration - The type declaration of the attribute.
Throws:
DuplicateException - If the attributeName is already present in the heading

getAttributeNames

public final java.util.Set<java.lang.String> getAttributeNames()
Gets The set of attribute names

Returns:
The set of attribute names

getHeading

public final Heading getHeading(java.lang.String attributeName)
                         throws NotFoundException,
                                TypeIsScalarException
Gets the heading object defining the relation type of the named attribute, which must be relation-typed

Parameters:
attributeName - The name of a relation-typed attribute whose heading is to be obtained
Returns:
the heading object defining the relation type of the named attribute, which must be relation-typed
Throws:
NotFoundException
TypeIsScalarException

getTypeName

public final java.lang.String getTypeName(java.lang.String attributeName)
                                   throws NotFoundException
Gets the typename of the named attribute. If the attribute is relation-typed, the string "RELATION" is returned. Further specification of the precise relation heading of the attribute can be obtained through a getHeadingType() invocation.

Parameters:
attributeName - The name of the attribute whose type name is to be obtained
Returns:
The typename of the named attribute
Throws:
NotFoundException

isStrictUnionCompatibleWith

public final boolean isStrictUnionCompatibleWith(Heading other)
Checks if the heading of another Relvar is exactly the same as this one :

Parameters:
other - the Heading of another Relvar
Returns:
true if the other RelvarHeading contains exactly the same set of atrributename/typedeclaration pairs

print

public final java.lang.String print()
Gets the heading specification in textual format HEADING(ATTRIBUTENAME(TYPENAME)RELATIONTYPEDATTRIBUTENAME(RELATION(HEADING(...))))

Returns:
the heading specification in textual format HEADING(ATTRIBUTENAME(TYPENAME)RELATIONTYPEDATTRIBUTENAME(RELATION(HEADING(...))))

printXML

public final java.lang.String printXML()
Gets the heading specification in XML style

Returns:
the formatted heading specification in XML xtyle

subHeadingExcluding

public final Heading subHeadingExcluding(java.util.Set<java.lang.String> attributeNames)
Gets a Heading that includes only the attribute definitions from this Heading whose attribute names do not appear in the given set

Parameters:
attributeNames - The names of the attributes that are not to appear in the subHeading
Returns:
A Heading that includes only the attribute definitions from this Heading whose attribute names do not appear in the given set

subHeadingIncluding

public final Heading subHeadingIncluding(java.util.Set<java.lang.String> attributeNames)
Gets a Heading that includes only the attribute definitions from this Heading whose attribute names appear in the given set

Parameters:
attributeNames - The names of the attributes that are to appear in the subHeading
Returns:
A Heading that includes only the attribute definitions from this Heading whose attribute names appear in the given set

toStream1_0

public final void toStream1_0(java.io.DataOutputStream outputStream)
                       throws java.io.IOException
Writes the heading to an outputstream in the V1.0 format

Parameters:
outputStream - the outputstream to write the heading to
Throws:
java.io.IOException