odml.core
Class Section

java.lang.Object
  extended by odml.core.Section
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeNode

public class Section
extends java.lang.Object
implements java.io.Serializable, javax.swing.tree.TreeNode

The Section class defines the odML section, one of the two core elements that can contain odMLProperties - if it is not the root of the odMLTree - as well as section to built a tree structure. A Section is defined by its name and may carry a description. Furthermore a section may contain one terminology which contains property definitions and which can be used to validate the properties. Properties defined in the terminology will be checked for consistency and missing fields like type or unit will be added from the terminology. To create a valid section a name must be provided, everything else is extra.

Since:
08.2009
Author:
Jan Grewe, Christine Seitz
See Also:
Serialized Form

Field Summary
static int MERGE_COMBINE
           
static int MERGE_OTHER_OVERRIDES_THIS
           
static int MERGE_THIS_OVERRIDES_OTHER
           
 
Constructor Summary
Section()
          The default constructor.
Section(Section parent, java.lang.String name, java.lang.String type)
          Constructor that creates a new section with the specified name and the specified parent.
Section(Section parent, java.lang.String name, java.lang.String type, java.lang.String reference, java.lang.String definition)
          Constructor that creates a new section of a certain type and with the specified name and definition.
Section(Section parent, java.lang.String name, java.lang.String type, java.lang.String reference, java.lang.String definition, java.net.URL baseURL)
           
Section(Section parent, java.lang.String name, java.lang.String type, java.lang.String reference, java.lang.String definition, java.net.URL repository, java.net.URL mappingURL)
          Constructor that creates a new section with all the possible information (name, description, terminology and mappingURL.
Section(java.lang.String type)
          Constructor for creating a section of a certain type.
Section(java.lang.String name, java.lang.String type)
          Create a Section of a certain type and with a specified name.
Section(java.lang.String name, java.lang.String type, java.lang.String reference)
           
 
Method Summary
 int add(Property property)
          Adds a property to this section and returns its index.
 int add(Section section)
          Adds a new subsection to this section.
 int add(java.lang.String path, Property property)
          Adds a property to the section given by the the path and returns its index.
 int addProperty(java.lang.String name, java.lang.Object value)
          Ads a new Property to this section.
static java.lang.String checkNameStyle(java.lang.String name)
          Checks the name style of a section.
static java.lang.String checkTypeStyle(java.lang.String type)
          Checks whether the given section type is in lower case, i.e. having one word beginning with an uppercase letter.
 java.util.Enumeration<javax.swing.tree.TreeNode> children()
           
 int contains(Property property)
          Deprecated. 
 int contains(Section section)
          Deprecated. 
 boolean containsIncludes()
          Returns whether the tree starting at this section contains Includes (i.e. links to external resources)
 boolean containsLinks()
          Returns whether the tree starting at this section contains links.
 boolean containsMappings()
          Returns whether the tree starting at this section contains mapping information that might need to be resolved.
 boolean containsProperty(java.lang.String propertyName)
          Returns whether this Section contains a Property of the specified name or not.
 boolean containsSection(java.lang.String name)
          Returns whether this section contains a section of the specified name.
 boolean containsSection(java.lang.String sectionName, java.lang.String sectionType)
          Returns whether this Section contains a subsection with the specified name and type.
 Section copy()
          Creates a copy of this section via serialization.
 void displayTree()
          Displays the odml tree in a dialog window.
 java.net.URL findRepositoryURL()
          Returns the repository url stored in this section or in one of its ancestors.
 Section findSection(java.lang.String name)
          findSection looks for a child section with the specified name.
 Section findSectionByType(java.lang.String type)
          Finds the first child Section matching the requested type.
 java.util.Vector<Section> findSectionsByType(java.lang.String type)
          Finds all child sections of the specified type.
 boolean getAllowsChildren()
           
 javax.swing.tree.TreeNode getChildAt(int arg0)
           
 int getChildCount()
           
 java.util.Date getDate(java.lang.String propertyName)
          Returns the date component of the first value's content of the defined property.
 java.util.Date getDate(java.lang.String propertyName, int i)
          Returns the date component of the i-th value's content of the defined property.
 java.lang.String getDefinition()
          Returns the description of this section.
 java.lang.String getDocumentAuthor()
          Returns the author of this document.
 java.util.Date getDocumentDate()
          Returns the date this document was created.
 java.lang.String getDocumentVersion()
          Returns the version of this document, if set.
 java.net.URL getFileUrl()
          Returns the stored file url, i.e. the url of the file this section originated from.
 java.lang.String getInclude()
          Returns the include information stored in this section.
 int getIndex(javax.swing.tree.TreeNode arg0)
           
 int getLevel()
          Returns the level of this section (i.e. the depth / position in the tree)
 java.lang.String getLink()
          Returns the link stored for this section.
 Section getLinkedSection()
          Returns the linked section of the given one.
 java.util.Vector<Section> getLinkingSections()
          Returns those Sections that are referring (are linked) to this section.
 java.net.URL getMapping()
          Returns the mappingURL of this section.
 java.lang.String getName()
          Returns the section name.
 double getNumber(java.lang.String propertyName)
          Returns the first value's content as Float of the defined property.
 double getNumber(java.lang.String propertyName, int index)
          Returns the i-th value's content as Float of the defined property.
 Section getParent()
          Returns the parent section of this section.
 java.lang.String getPath()
          This method returns the absolute path of this section beginning from the root.
 java.util.Vector<Property> getProperties()
          Returns all properties stored in this section.
 Property getProperty(int index)
          Returns the property with this index.
 Property getProperty(java.lang.String name)
          Returns the first property stored in this section that matches the name.
 java.lang.String[] getPropertyNames()
          Returns a list of the property names in this section.
 java.lang.String getReference()
          Get the reference element of the Section.
 Section getRelatedSection(java.lang.String type)
          Returns that Section of the specified type that has the strongest relation to this section.
 java.util.Vector<Section> getRelatedSections(java.lang.String type)
          Returns all Sections that have the specified type and are have the strongest relation to this section.
 java.net.URL getRepository()
          Get the URL of the linked terminology.
 Section getRootSection()
          Returns the root of the odml-tree.
 Section getSection(int index)
          Returns a subsection as defined by the index.
 Section getSection(java.lang.String name)
          Returns the first section with its name matching the argument.
 Section getSectionByType(java.lang.String type)
          Return a child section that matches the requested type.
 java.util.Vector<Section> getSections()
          Returns all first level subsections.
 java.util.Vector<Section> getSectionsByType(java.lang.String type)
          Returns a Vector of subsections of the requested type.
 java.lang.String getText(java.lang.String propertyName)
          Returns the first value's content of the defined property as text.
 java.lang.String getText(java.lang.String propertyName, int index)
          Returns the i-th value's text content of the defined property.
 java.util.Date getTime(java.lang.String propertyName)
          Returns the time component of the first value's content of the defined property.
 java.util.Date getTime(java.lang.String propertyName, int index)
          Returns the time component of the i-th value's content of the defined property.
 java.lang.String getType()
          Returns the type of this section.
 boolean hasTerminology()
          indicates whether a terminology is set or not
 int indexOfProperty(java.lang.String propertyName)
          Returns the index of the first matching Property.
 int indexOfSection(Section section)
          Returns the index of the first matching subsection that matches in name and type to the one passed as argument.
 int indexOfSection(java.lang.String sectionName)
          Find the index of a subsection that first matches regarding its name.
 int indexOfSection(java.lang.String sectionName, java.lang.String sectionType)
          Returns the index of the first matching subsection that matches in its name and type.
 boolean isEmpty()
          Returns whether a Section is empty in the sense that it does not contain any properties or sections.
 boolean isLeaf()
           
 boolean isLinked()
          Returns whether this section is linked to another one.
 boolean isRoot()
          Ask if this section is the root section, i.e. its level must be 0.
 boolean isTerminology()
          Returns whether this section was set to be a terminology.
 void loadAllIncludes()
          Loads includes from this section and cycles through all subsections.
 void loadInclude()
          Loads an included file into this section and merges them while the locally defined information (properties of this section) overwrites the imported one.
 void merge(Section otherSection, int mergeOption)
          Merges this section with another section.
 void optimizeTree()
          This method scans the tree and optimizes the tree.
 int propertyCount()
          Returns the number of properties stored in this section.
 void removeMapping()
          Removes the mappingURL of this section.
 boolean removeProperty(int index)
          Removes the property defined by its index the properties that are stored in this section.
 boolean removeProperty(java.lang.String name)
          Removes a property matching with its name from the properties that are stored in this section.
 boolean removeSection(int index)
          Removes the subsection at the given index.
 boolean removeSection(Section section)
          Deletes a section from the tree.
 boolean removeSection(java.lang.String name)
          Removes the first subsection that matches the specified name.
 void resolveAllLinks()
          Cycles through all subsections and resolves all links.
 boolean resolveLink()
          Ask this section to follow its links and to resolve it.
 int sectionCount()
          Returns the number of subsections.
 void setAsTerminology(boolean isTerminology)
          Defines that this section is a terminology.
 void setDefinition(java.lang.String definition)
          Sets the description of this section.
 void setDocumentAuthor(java.lang.String author)
          Sets the author of this document.
 void setDocumentDate(java.util.Date date)
          Set the date of the document.
 void setDocumentVersion(java.lang.String version)
          Set the Version of the document.
 void setFileUrl(java.net.URL fileUrl)
          Sets the fileURL of the file this section originated from.
 void setInclude(java.lang.String include)
          Sets the include information of this section.
 void setLink(java.lang.String link)
          Set a link.
 void setLink(java.lang.String link, boolean ignore)
          Set a link.
 void setMapping(java.lang.String mapping)
          Tries to convert the given mappingURL String to a valid URL and sets the internal mappingURL to it.
 void setMapping(java.net.URL mapping)
          Sets the mapping to the given one.
 boolean setName(java.lang.String name)
          Set the name of the section.
 void setReference(java.lang.String reference)
          Set the reference element of the Section. the reference can be used to point to an entity e.g. defined in a database.
 void setRepository(java.lang.String url)
          Sets the terminology of the section.
 void setRepository(java.net.URL url)
           
 boolean setType(java.lang.String type)
          Sets the type of the section.
 java.lang.String[] subsectionsNames()
          Returns a list of all the types of first level subsections.
 java.lang.String toString()
          Returns a String representation of this section.
 java.lang.String toStringAllDetails()
          Returns a detailed String representation of this section.
 java.lang.String toStringExtended()
          Returns an extended String representation of this section.
 void validate()
          Validates this section against the related terminology.
 void validateTree()
          Validate the whole metadata tree against the terminologies.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MERGE_THIS_OVERRIDES_OTHER

public static final int MERGE_THIS_OVERRIDES_OTHER
See Also:
Constant Field Values

MERGE_OTHER_OVERRIDES_THIS

public static final int MERGE_OTHER_OVERRIDES_THIS
See Also:
Constant Field Values

MERGE_COMBINE

public static final int MERGE_COMBINE
See Also:
Constant Field Values
Constructor Detail

Section

public Section()
The default constructor. Creating the root for the odmlTree, i.e. no name is necessary and no parent must be given.


Section

public Section(java.lang.String type)
        throws java.lang.Exception
Constructor for creating a section of a certain type. The section name equals the type.

Parameters:
type - String
Throws:
java.lang.Exception

Section

public Section(java.lang.String name,
               java.lang.String type)
        throws java.lang.Exception
Create a Section of a certain type and with a specified name.

Parameters:
name -
type -
Throws:
java.lang.Exception

Section

public Section(java.lang.String name,
               java.lang.String type,
               java.lang.String reference)
        throws java.lang.Exception
Parameters:
name -
type -
reference -
Throws:
java.lang.Exception

Section

public Section(Section parent,
               java.lang.String name,
               java.lang.String type)
        throws java.lang.Exception
Constructor that creates a new section with the specified name and the specified parent. Parent and name may be null.

Parameters:
parent - Section: the parent of this section.
name - - String:
type - - String:
Throws:
java.lang.Exception

Section

public Section(Section parent,
               java.lang.String name,
               java.lang.String type,
               java.lang.String reference,
               java.lang.String definition)
        throws java.lang.Exception
Constructor that creates a new section of a certain type and with the specified name and definition.

Parameters:
parent - Section: the parent of this section.
name - - String:
type - - String:
definition - - String: the definition of this section.
Throws:
java.lang.Exception

Section

public Section(Section parent,
               java.lang.String name,
               java.lang.String type,
               java.lang.String reference,
               java.lang.String definition,
               java.net.URL baseURL)
        throws java.lang.Exception
Parameters:
parent - Section: the parent of this section.
name - String: the section name.
type - String: the section type.
definition - String: a description, can be null.
baseURL - URL: the URL of the underlying terminology.
Throws:
java.lang.Exception

Section

public Section(Section parent,
               java.lang.String name,
               java.lang.String type,
               java.lang.String reference,
               java.lang.String definition,
               java.net.URL repository,
               java.net.URL mappingURL)
        throws java.lang.Exception
Constructor that creates a new section with all the possible information (name, description, terminology and mappingURL. Also parentURLs (logical parent) and partenSections are included)

Parameters:
parent -
type - String: the name of the Section, must not be null or empty
definition -
repository -
mappingURL -
Throws:
java.lang.Exception
Method Detail

checkTypeStyle

public static java.lang.String checkTypeStyle(java.lang.String type)
Checks whether the given section type is in lower case, i.e. having one word beginning with an uppercase letter. If not generating CamelCase by deleting white-spaces and putting letter of formerly new word to uppercase. If String is beginning with a digit adding S_ for indicating a Section-type

Parameters:
type - String: the type that shall be checked / converted to CamelCase
Returns:
String: returning the checked / converted type-String in CamelCase

checkNameStyle

public static java.lang.String checkNameStyle(java.lang.String name)
Checks the name style of a section. Names must not contain '/'. Is replaced by '-'

Parameters:
name - String the name.
Returns:
String the converted (if needed) name.

add

public int add(Section section)
Adds a new subsection to this section.

Parameters:
section - - Section: the new section.
Returns:
- int: returns the index of the added section if successful (i.e. the number of subsections as added one is last), -1 otherwise.

sectionCount

public int sectionCount()
Returns the number of subsections.

Returns:
- int: the number of subsections. I.e. the size of the subsections vector.

subsectionsNames

public java.lang.String[] subsectionsNames()
Returns a list of all the types of first level subsections.

Returns:
- String[]: an array containing the types of all fist level subsections.

getSection

public Section getSection(int index)
Returns a subsection as defined by the index.

Parameters:
index - - int: the index of the requested subsection (i.e. position subsection-array)
Returns:
the section of that index or null if index not valid.

getSection

public Section getSection(java.lang.String name)
Returns the first section with its name matching the argument. Matching is case-insensitive.

Parameters:
name - - String: the name of the target section. May be a path.
Returns:
the first section matching with its name

getSections

public java.util.Vector<Section> getSections()
Returns all first level subsections.

Returns:
Vector
: the subsections or null if no subsections.

getSectionByType

public Section getSectionByType(java.lang.String type)
Return a child section that matches the requested type. Method does not crawl through the rest of the tree. Use FindSectionByType, instead.

Parameters:
type - String the type of the desired section.
Returns:
Section the found subsection or null;

getSectionsByType

public java.util.Vector<Section> getSectionsByType(java.lang.String type)
Returns a Vector of subsections of the requested type. Matching is case-insensitive. Note: function returns those matches in which the search type is super-type (e.g. stimulus/white_noise).

Parameters:
type - - String: the type of subsections.
Returns:
Vector
the matching sections or an empty Vector.

findSection

public Section findSection(java.lang.String name)
findSection looks for a child section with the specified name. In contrast to getSection, findSection recursively crawls down all subsection. Returns the first occurrence! If name is a path this method is equivalent to getSection(name).

Parameters:
name - String the section name.
Returns:
The found section or null.

findSectionByType

public Section findSectionByType(java.lang.String type)
Finds the first child Section matching the requested type.

Parameters:
type - String the type of the section.
Returns:
Section the section or null;

findSectionsByType

public java.util.Vector<Section> findSectionsByType(java.lang.String type)
Finds all child sections of the specified type. Recursively cycles down the tree.

Parameters:
type - String the type of sections.
Returns:
Vector of Sections, may be empty

getRelatedSection

public Section getRelatedSection(java.lang.String type)
Returns that Section of the specified type that has the strongest relation to this section. Section relations rate from children over siblings to parents, their siblings, grandparents, their siblings and so on...

Parameters:
type - String the type of the target section.
Returns:
The first matching Section;

getRelatedSections

public java.util.Vector<Section> getRelatedSections(java.lang.String type)
Returns all Sections that have the specified type and are have the strongest relation to this section. Relation strengths decrease from children over siblings to parents, their siblings, grandparents, their siblings and so on... Sections with equal relation strength are returned. That means that they are siblings.

Parameters:
type - String: The section type like 'stimulus'.
Returns:
Vector of Sections which may be empty.

isRoot

public boolean isRoot()
Ask if this section is the root section, i.e. its level must be 0.

Returns:
- boolean: true if section is root, false otherwise.

getLevel

public int getLevel()
Returns the level of this section (i.e. the depth / position in the tree)

Returns:
- int: the level of this section.

removeSection

public boolean removeSection(int index)
Removes the subsection at the given index.

Parameters:
index - Integer the index of the section.

removeSection

public boolean removeSection(Section section)
Deletes a section from the tree.

Parameters:
section - Section the section that should be deleted.
Returns:
Boolean true if operation succeeded. False otherwise.

removeSection

public boolean removeSection(java.lang.String name)
Removes the first subsection that matches the specified name. Name can also be a path.

Parameters:
name - - String: the name of the subsection accordingly the path (e.g. sec/subsec/toRemoveSec
Returns:
boolean: true if removing successful, false otherwise

setType

public boolean setType(java.lang.String type)
Sets the type of the section.

Parameters:
type - - String: the new type of this section.
Returns:
- boolean: returns true if successful or false if not.

setName

public boolean setName(java.lang.String name)
Set the name of the section.

Parameters:
name - String the new name.
Returns:
Boolean whether or not the operation succeeded.

setReference

public void setReference(java.lang.String reference)
Set the reference element of the Section. the reference can be used to point to an entity e.g. defined in a database.

Parameters:
reference -

getReference

public java.lang.String getReference()
Get the reference element of the Section.

Returns:
String - the reference or null if empty.

setDefinition

public void setDefinition(java.lang.String definition)
Sets the description of this section.

Parameters:
definition - - String: the new description of this section.

setRepository

public void setRepository(java.lang.String url)
Sets the terminology of the section.

Parameters:
url - URL: the url of the new terminology.

setRepository

public void setRepository(java.net.URL url)

getDefinition

public java.lang.String getDefinition()
Returns the description of this section.

Returns:
- String: the description stored with this section or null if none stored.

getType

public java.lang.String getType()
Returns the type of this section.

Returns:
- String

getName

public java.lang.String getName()
Returns the section name.

Returns:
String

getParent

public Section getParent()
Returns the parent section of this section.

Specified by:
getParent in interface javax.swing.tree.TreeNode
Returns:
Section: the parent section.

getLinkingSections

public java.util.Vector<Section> getLinkingSections()
Returns those Sections that are referring (are linked) to this section.

Returns:
Vector of Section the referring sections. May be empty!

isLinked

public boolean isLinked()
Returns whether this section is linked to another one.

Returns:
Boolean: true if this section is linked to another section

getLinkedSection

public Section getLinkedSection()
Returns the linked section of the given one. Does not follow the linked sections links!

Returns:
Boolean: the linked section

resolveLink

public boolean resolveLink()
Ask this section to follow its links and to resolve it. In case this section is linked to another one it will be extended by the properties found in the linked section.

Returns:
Boolean true if this section is linked to another section and has been merged otherwise false.

resolveAllLinks

public void resolveAllLinks()
Cycles through all subsections and resolves all links. Uses resolveLink() recursively. Call it on


add

public int add(Property property)
Adds a property to this section and returns its index.

Parameters:
property - - Property: the property you want to add.
Returns:
Integer: the index of the added property in the properties vector or -1 if command failed.

add

public int add(java.lang.String path,
               Property property)
Adds a property to the section given by the the path and returns its index. If sections in path not existing yet, creating them. path beginning with '/' meaning starting from the root.

Parameters:
path - String: the path form the root, where the property shall be added; different levels separated by "/", path ending on section-name!!
property - - Property: the property you want to add.
Returns:
Integer: the index of the added property in the properties vector or -1 if command failed.

addProperty

public int addProperty(java.lang.String name,
                       java.lang.Object value)
Ads a new Property to this section.

Parameters:
name - String the name of the new Property.
value - Object the new Property's value.
Returns:
int the property index.

removeProperty

public boolean removeProperty(java.lang.String name)
Removes a property matching with its name from the properties that are stored in this section. Removes the first occurrence with this name and does not check for duplicate entries!

Parameters:
name - String : the name of the property.
Returns:
Boolean true if successful, false if not.

removeProperty

public boolean removeProperty(int index)
Removes the property defined by its index the properties that are stored in this section.

Parameters:
index - Integer : the index of the property. With -1Returns:
Boolean :true if operation succeeded and false otherwise.

getPropertyNames

public java.lang.String[] getPropertyNames()
Returns a list of the property names in this section. Method does not traverse through the subsections.

Returns:
String[] an array of Strings.

propertyCount

public int propertyCount()
Returns the number of properties stored in this section.

Returns:
int: the number of stored properties.

getProperty

public Property getProperty(int index)
Returns the property with this index.

Parameters:
index - - int: the index in the properties vector.
Returns:
Property: the property or null if index exceeds the propertyCount.

getProperty

public Property getProperty(java.lang.String name)
Returns the first property stored in this section that matches the name. Name matching is case-insensitive. The name can also be a path looking like /section/section/property. Leading "/" means beginning from root, leading section-name meaning path beginning from current section. In case no direct match is found method also checks the synonyms. The first match is returned. Identical for search via path, just changing position in tree.

Parameters:
name - - String: the name of the searched property.
Returns:
- Property: the first matching property or null if no match found.

getDate

public java.util.Date getDate(java.lang.String propertyName)
Returns the date component of the first value's content of the defined property.

Parameters:
propertyName - String the propertyName or path.
Returns:
Date the date component or null if property not found or conversion fails.

getDate

public java.util.Date getDate(java.lang.String propertyName,
                              int i)
Returns the date component of the i-th value's content of the defined property.

Parameters:
propertyName - String the propertyName or path.
i - Integer the value index.
Returns:
Date the date component or null if property not found or conversion fails.

getTime

public java.util.Date getTime(java.lang.String propertyName)
Returns the time component of the first value's content of the defined property.

Parameters:
propertyName - String the propertyName or path.
Returns:
Date the time component or null if property not found or conversion fails.

getTime

public java.util.Date getTime(java.lang.String propertyName,
                              int index)
Returns the time component of the i-th value's content of the defined property.

Parameters:
propertyName - String the propertyName or path.
index - Integer the value index.
Returns:
Date the time component or null if property not found or conversion fails.

getText

public java.lang.String getText(java.lang.String propertyName)
Returns the first value's content of the defined property as text.

Parameters:
propertyName - String the propertyName or path.
Returns:
String the text content or null if property not found or conversion fails.

getText

public java.lang.String getText(java.lang.String propertyName,
                                int index)
Returns the i-th value's text content of the defined property.

Parameters:
propertyName - String the propertyName or path.
index - Integer the value index.
Returns:
String the text content or null if property not found or conversion fails.

getNumber

public double getNumber(java.lang.String propertyName)
Returns the first value's content as Float of the defined property.

Parameters:
propertyName - String the propertyName or path.
Returns:
Float the content as Float, Float.NaN if conversion fails or null if property not found.

getNumber

public double getNumber(java.lang.String propertyName,
                        int index)
Returns the i-th value's content as Float of the defined property.

Parameters:
propertyName - String the propertyName or path.
index - Integer the value index.
Returns:
Float the content as Float, Float.NaN if conversion fails or null if property not found.

getProperties

public java.util.Vector<Property> getProperties()
Returns all properties stored in this section.

Returns:
- Vector: returns the properties Vector which may be empty.

hasTerminology

public boolean hasTerminology()
indicates whether a terminology is set or not

Returns:
Boolean: true if this.terminology != null, false otherwise

getRepository

public java.net.URL getRepository()
Get the URL of the linked terminology. Recursively crawls up the tree and returns the first one found.

Returns:
URL: the URL of the terminology may be null.

merge

public void merge(Section otherSection,
                  int mergeOption)
Merges this section with another section. Generally all properties in the other section will be copied. The way the merging is done in case of conflict can be set by the mergeOption parameter which can assume the following values:
  1. MERGE_THIS_OVERRIDES_OTHER: the local information overrides the information passed in otherSection .
  2. MERGE_OTHER_OVERRIDES_THIS: the global information passed with otherSection overrides local information.
  3. MERGE_COMBINE: the local information will be combined with the passed section. properties with the same name will be fused.
Merging works recursively. Only those subsections are merged that share the same name and type! Otherwise they are simply added.

Parameters:
otherSection - Section the other section which shall be merged with this section.
mergeOption - Integer the way merging is done.

containsProperty

public boolean containsProperty(java.lang.String propertyName)
Returns whether this Section contains a Property of the specified name or not.

Parameters:
propertyName - String: The property name;
Returns:
boolean true, if such a Property exists, false otherwise.

containsSection

public boolean containsSection(java.lang.String sectionName,
                               java.lang.String sectionType)
Returns whether this Section contains a subsection with the specified name and type.

Parameters:
sectionName - String: The name searched for
sectionType - String: The requested section type.
Returns:
boolean: true if such a subsection exists, false otherwise

containsSection

public boolean containsSection(java.lang.String name)
Returns whether this section contains a section of the specified name.

Parameters:
name - String
Returns:
boolean

contains

@Deprecated
public int contains(Property property)
Deprecated. 

Returns the index of the first matching Property. Method compares only the name. the method is marked @deprecated use indexOfProperty instead.

Parameters:
property - Property the property that should be found.
Returns:
int: the index of the property if such a property already exists, -1 if not.

indexOfProperty

public int indexOfProperty(java.lang.String propertyName)
Returns the index of the first matching Property. Method compares the name.

Parameters:
propertyName - String the property name that should be found.
Returns:
integer: the index of the property if such a property already exists, -1 if not.

indexOfSection

public int indexOfSection(java.lang.String sectionName,
                          java.lang.String sectionType)
Returns the index of the first matching subsection that matches in its name and type. Returns -1 if no match found.

Parameters:
sectionName - String: the requested section name.
sectionType - String: the requested section type.
Returns:
boolean: true if such a subsection exists, false otherwise.

indexOfSection

public int indexOfSection(java.lang.String sectionName)
Find the index of a subsection that first matches regarding its name.

Parameters:
sectionName -
Returns:
int the index

indexOfSection

public int indexOfSection(Section section)
Returns the index of the first matching subsection that matches in name and type to the one passed as argument. Returns -1 if no match found.

Parameters:
section - Section: Name and type of a subsection must match to the name and type of this argument.
Returns:
int: the index of the requested subsection. -1 if no matrch found.

contains

@Deprecated
public int contains(Section section)
Deprecated. 

Checks whether or not this section already contains a subsection with the same name and type. Method does not traverse the subsections! Method is marked @deprecated ! Use containsSection(String name, String type) instead.

Parameters:
section - Section: the section that one looks for
Returns:
Integer: the index of the section if exists, -1 if not.

copy

public Section copy()
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Creates a copy of this section via serialization. This copy is an exact doublet

Returns:
Section: returns an exact copy of the section
Throws:
java.io.IOException
java.lang.ClassNotFoundException

setMapping

public void setMapping(java.net.URL mapping)
Sets the mapping to the given one.

Parameters:
mapping - URL: the url to which this section maps. Can (should) contain references to indicate the type of section to include.

setMapping

public void setMapping(java.lang.String mapping)
Tries to convert the given mappingURL String to a valid URL and sets the internal mappingURL to it.

Parameters:
mapping - String: the url to which this property maps. Must not contain a refernce part.

removeMapping

public void removeMapping()
Removes the mappingURL of this section.


getMapping

public java.net.URL getMapping()
Returns the mappingURL of this section.

Returns:
URL the mappingURL

findRepositoryURL

public java.net.URL findRepositoryURL()
Returns the repository url stored in this section or in one of its ancestors.

Returns:
URL the repository url if set locally or by this section's parent or null if none found.

validateTree

public void validateTree()
Validate the whole metadata tree against the terminologies.


validate

public void validate()
Validates this section against the related terminology. Tests all Properties but does not cycle through its subsections!


optimizeTree

public void optimizeTree()
This method scans the tree and optimizes the tree. Empty Properties are removed. It optimizes linked sections in the sense that local sections are simplified that they only contain information that deviates from the global description. This method recursively cycles through the whole tree starting at the RootSection.


isEmpty

public boolean isEmpty()
Returns whether a Section is empty in the sense that it does not contain any properties or sections.

Returns:
boolean true if there are no subsections and no properties, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of this section. I.e the fact that it is a section and it's name.

Overrides:
toString in class java.lang.Object

toStringExtended

public java.lang.String toStringExtended()
Returns an extended String representation of this section. I.e it's name, level, completePath, number and names of subsections and number and names of appended properties


toStringAllDetails

public java.lang.String toStringAllDetails()
Returns a detailed String representation of this section. I.e it's name, level, completePath + definition, termURL, mappingURL + number and names of subsections and number and names of appended properties


getPath

public java.lang.String getPath()
This method returns the absolute path of this section beginning from the root. Paths are made up from section names separated by "/". Leading '/' indicates an absolute path.

Returns:
String returns the path as a String, different Sections / levels separated with '/'

children

public java.util.Enumeration<javax.swing.tree.TreeNode> children()
Specified by:
children in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int arg0)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode arg0)
Specified by:
getIndex in interface javax.swing.tree.TreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode

displayTree

public void displayTree()
Displays the odml tree in a dialog window. This view has no further function but to give an impression of the stored information.


setLink

public void setLink(java.lang.String link)
Set a link. This indicates that this section is linked to another one and thus inherits its properties. Links can only be established between sections of the same type and are defined by the absolute paths in the odml tree. Paths are the '/' separated names of sections, e.g. /dataset 1/myStimulus/.

Parameters:
link - String the link.

setLink

public void setLink(java.lang.String link,
                    boolean ignore)
Set a link. A link indicates that this section is linked to another one and thus inherits its properties. Links can only be established between sections of the same type and are defined by the absolute paths in the odml tree. Paths are the '/' separated names of sections, e.g. /dataset 1/myStimulus/. Using this function a link can be set that is untested.

Parameters:
link - String the link as an absolute path (beginning at the root section and starting with / e.g. '/dataset 1/myStimulus/')
ignore - Boolean setting this true does not test the link for validity!

getLink

public java.lang.String getLink()
Returns the link stored for this section.

Returns:
String the stored link or null.

setInclude

public void setInclude(java.lang.String include)
Sets the include information of this section. The include string can represent an url or a relative path. Setting the include information does not automatically load the resource. To do so call loadInclude() method.

Parameters:
include - A String representing a valid url an absolute or relative path of the resource to included.

getInclude

public java.lang.String getInclude()
Returns the include information stored in this section.

Returns:
String the inlcude information, or null if none stored.

setDocumentAuthor

public void setDocumentAuthor(java.lang.String author)
Sets the author of this document. Author elements are only valid in root sections. They are otherwise ignored.

Parameters:
author - String the author of the document.

getDocumentAuthor

public java.lang.String getDocumentAuthor()
Returns the author of this document. Usually this information is only available in root sections.

Returns:
String the Author of this document.

setDocumentVersion

public void setDocumentVersion(java.lang.String version)
Set the Version of the document. Version elements are only valid in root sections. They are otherwise ignored.

Parameters:
version - String the version of the document.

getDocumentVersion

public java.lang.String getDocumentVersion()
Returns the version of this document, if set. Usually this information is only available in root sections.

Returns:
String the Version of the document, if available, null otherwise.

setDocumentDate

public void setDocumentDate(java.util.Date date)
Set the date of the document. Usually this information is only allowed in root sections. It will be ignored if stored in normal sections.

Parameters:
date - Date the date.

getDocumentDate

public java.util.Date getDocumentDate()
Returns the date this document was created. This information is only available in root sections.

Returns:
Date the create date of the document, or null.

loadInclude

public void loadInclude()
Loads an included file into this section and merges them while the locally defined information (properties of this section) overwrites the imported one.


loadAllIncludes

public void loadAllIncludes()
Loads includes from this section and cycles through all subsections. If you want to load all includes in the tree call this function on the rootSection.


setFileUrl

public void setFileUrl(java.net.URL fileUrl)
Sets the fileURL of the file this section originated from. This information is used to resolve includes if they are relative. Usually only present in the root section.

Parameters:
fileUrl - URL the URL of the original file.

getFileUrl

public java.net.URL getFileUrl()
Returns the stored file url, i.e. the url of the file this section originated from. Usually only set while reading from file and only present in the root section. sections.

Returns:
URL the URL, if present, null otherwise.

getRootSection

public Section getRootSection()
Returns the root of the odml-tree.

Returns:
Section the root section.

containsIncludes

public boolean containsIncludes()
Returns whether the tree starting at this section contains Includes (i.e. links to external resources). *

Returns:
Boolean true if there are includes, false otherwise.

containsLinks

public boolean containsLinks()
Returns whether the tree starting at this section contains links.

Returns:
Boolean true if there are links.

containsMappings

public boolean containsMappings()
Returns whether the tree starting at this section contains mapping information that might need to be resolved.

Returns:
Boolean true if mapping information is present, false otherwise.

isTerminology

public boolean isTerminology()
Returns whether this section was set to be a terminology. The default is false.

Returns:
Boolean

setAsTerminology

public void setAsTerminology(boolean isTerminology)
Defines that this section is a terminology.

Parameters:
isTerminology -