|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectodml.core.Section
public class Section
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.
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 Section s 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 |
---|
public static final int MERGE_THIS_OVERRIDES_OTHER
public static final int MERGE_OTHER_OVERRIDES_THIS
public static final int MERGE_COMBINE
Constructor Detail |
---|
public Section()
public Section(java.lang.String type) throws java.lang.Exception
type
- String
java.lang.Exception
public Section(java.lang.String name, java.lang.String type) throws java.lang.Exception
Section
of a certain type and with a specified name.
name
- type
-
java.lang.Exception
public Section(java.lang.String name, java.lang.String type, java.lang.String reference) throws java.lang.Exception
name
- type
- reference
-
java.lang.Exception
public Section(Section parent, java.lang.String name, java.lang.String type) throws java.lang.Exception
parent
- Section
: the parent of this section.name
- - String
:type
- - String
:
java.lang.Exception
public Section(Section parent, java.lang.String name, java.lang.String type, java.lang.String reference, java.lang.String definition) throws java.lang.Exception
parent
- Section
: the parent of this section.name
- - String
:type
- - String
:definition
- - String
: the definition of this section.
java.lang.Exception
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
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.
java.lang.Exception
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
parent
- type
- String
: the name of the Section, must not be null or emptydefinition
- repository
- mappingURL
-
java.lang.Exception
Method Detail |
---|
public static java.lang.String checkTypeStyle(java.lang.String type)
type
- String
: the type that shall be checked / converted to CamelCase
String
: returning the checked / converted type-String in CamelCasepublic static java.lang.String checkNameStyle(java.lang.String name)
name
- String
the name.
public int add(Section section)
section
- - Section
: the new section.
public int sectionCount()
public java.lang.String[] subsectionsNames()
String
[]: an array containing the types of all fist level subsections.public Section getSection(int index)
index
- - int: the index of the requested subsection (i.e. position subsection-array)
public Section getSection(java.lang.String name)
name
- - String
: the name of the target section. May be a path.
public java.util.Vector<Section> getSections()
public Section getSectionByType(java.lang.String type)
type
- String
the type of the desired section.
Section
the found subsection or null;public java.util.Vector<Section> getSectionsByType(java.lang.String type)
type
- - String
: the type of subsections.
Vector
.public Section findSection(java.lang.String name)
name
- String the section name.
public Section findSectionByType(java.lang.String type)
Section
matching the requested type.
type
- String
the type of the section.
Section
the section or null;public java.util.Vector<Section> findSectionsByType(java.lang.String type)
type
- String
the type of sections.
Vector
of Section
s, may be emptypublic Section getRelatedSection(java.lang.String type)
type
- String
the type of the target section.
Section
;public java.util.Vector<Section> getRelatedSections(java.lang.String type)
type
- String
: The section type like 'stimulus'.
Vector
of Section
s which may be empty.public boolean isRoot()
public int getLevel()
public boolean removeSection(int index)
index
- Integer
the index of the section.public boolean removeSection(Section section)
section
- Section
the section that should be deleted.
Boolean
true if operation succeeded. False otherwise.public boolean removeSection(java.lang.String name)
name
- - String
: the name of the subsection accordingly the path (e.g. sec/subsec/toRemoveSec
public boolean setType(java.lang.String type)
type
- - String
: the new type of this section.
public boolean setName(java.lang.String name)
name
- String
the new name.
Boolean
whether or not the operation succeeded.public void setReference(java.lang.String reference)
Section
. the reference can be used to point to an entity e.g. defined in
a database.
reference
- public java.lang.String getReference()
Section
.
public void setDefinition(java.lang.String definition)
definition
- - String: the new description of this section.public void setRepository(java.lang.String url)
url
- URL
: the url of the new terminology.public void setRepository(java.net.URL url)
public java.lang.String getDefinition()
public java.lang.String getType()
String
public java.lang.String getName()
String
public Section getParent()
getParent
in interface javax.swing.tree.TreeNode
public java.util.Vector<Section> getLinkingSections()
Section
s that are referring (are linked) to this section.
Vector
of Section
the referring sections. May be empty!public boolean isLinked()
Boolean
: true if this section is linked to another sectionpublic Section getLinkedSection()
Boolean
: the linked sectionpublic boolean resolveLink()
Boolean
true if this section is linked to another section and has been merged otherwise false.public void resolveAllLinks()
public int add(Property property)
property
- - Property
: the property you want to add.
Integer
: the index of the added property in the properties vector or -1 if command failed.public int add(java.lang.String path, Property property)
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.
Integer
: the index of the added property in the properties vector or -1 if command failed.public int addProperty(java.lang.String name, java.lang.Object value)
Property
to this section.
name
- String
the name of the new Property.value
- Object
the new Property's value.
public boolean removeProperty(java.lang.String name)
name
- String
: the name of the property.
Boolean
true if successful, false if not.public boolean removeProperty(int index)
index
- Integer
: the index of the property. With -1Boolean
:true if operation succeeded and false otherwise.public java.lang.String[] getPropertyNames()
public int propertyCount()
public Property getProperty(int index)
index
- - int: the index in the properties vector.
Property
: the property or null if index exceeds the propertyCount.public Property getProperty(java.lang.String name)
name
- - String
: the name of the searched property.
Property
: the first matching property or null if no match found.public java.util.Date getDate(java.lang.String propertyName)
propertyName
- String
the propertyName or path.
Date
the date component or null if property not found or conversion fails.public java.util.Date getDate(java.lang.String propertyName, int i)
propertyName
- String
the propertyName or path.i
- Integer
the value index.
Date
the date component or null if property not found or conversion fails.public java.util.Date getTime(java.lang.String propertyName)
propertyName
- String
the propertyName or path.
Date
the time component or null if property not found or conversion fails.public java.util.Date getTime(java.lang.String propertyName, int index)
propertyName
- String
the propertyName or path.index
- Integer
the value index.
Date
the time component or null if property not found or conversion fails.public java.lang.String getText(java.lang.String propertyName)
propertyName
- String
the propertyName or path.
String
the text content or null if property not found or conversion fails.public java.lang.String getText(java.lang.String propertyName, int index)
propertyName
- String
the propertyName or path.index
- Integer
the value index.
String
the text content or null if property not found or conversion fails.public double getNumber(java.lang.String propertyName)
propertyName
- String
the propertyName or path.
Float
the content as Float, Float.NaN if conversion fails or null if property not found.public double getNumber(java.lang.String propertyName, int index)
propertyName
- String
the propertyName or path.index
- Integer
the value index.
Float
the content as Float, Float.NaN if conversion fails or null if property not found.public java.util.Vector<Property> getProperties()
public boolean hasTerminology()
Boolean
: true if this.terminology != null, false otherwisepublic java.net.URL getRepository()
URL
: the URL of the terminology may be null.public void merge(Section otherSection, int mergeOption)
otherSection
- Section
the other section which shall be merged with this section.mergeOption
- Integer
the way merging is done.public boolean containsProperty(java.lang.String propertyName)
Section
contains a Property
of the specified name or not.
propertyName
- String
: The property name;
Property
exists, false otherwise.public boolean containsSection(java.lang.String sectionName, java.lang.String sectionType)
Section
contains a subsection with the specified
name and type.
sectionName
- String
: The name searched forsectionType
- String
: The requested section type.
public boolean containsSection(java.lang.String name)
name
- String
@Deprecated public int contains(Property property)
Property
. Method compares only the name.
the method is marked @deprecated use indexOfProperty instead.
property
- Property
the property that should be found.
public int indexOfProperty(java.lang.String propertyName)
Property
. Method compares the name.
propertyName
- String
the property name that should be found.
public int indexOfSection(java.lang.String sectionName, java.lang.String sectionType)
sectionName
- String
: the requested section name.sectionType
- String
: the requested section type.
public int indexOfSection(java.lang.String sectionName)
sectionName
-
public int indexOfSection(Section section)
section
- Section
: Name and type of a subsection must match to the
name and type of this argument.
@Deprecated public int contains(Section section)
section
- Section
: the section that one looks for
Integer
: the index of the section if exists, -1 if not.public Section copy() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void setMapping(java.net.URL mapping)
mapping
- URL
: the url to which this section maps. Can (should) contain references to indicate the type
of section to include.public void setMapping(java.lang.String mapping)
mapping
- String
: the url to which this property maps. Must not contain a refernce part.public void removeMapping()
public java.net.URL getMapping()
URL
the mappingURLpublic java.net.URL findRepositoryURL()
URL
the repository url if set locally or by this section's parent or null if none found.public void validateTree()
public void validate()
public void optimizeTree()
public boolean isEmpty()
Section
is empty in the sense that it does not contain any properties or sections.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringExtended()
public java.lang.String toStringAllDetails()
public java.lang.String getPath()
String
returns the path as a String, different Sections / levels separated with '/'public java.util.Enumeration<javax.swing.tree.TreeNode> children()
children
in interface javax.swing.tree.TreeNode
public boolean getAllowsChildren()
getAllowsChildren
in interface javax.swing.tree.TreeNode
public javax.swing.tree.TreeNode getChildAt(int arg0)
getChildAt
in interface javax.swing.tree.TreeNode
public int getChildCount()
getChildCount
in interface javax.swing.tree.TreeNode
public int getIndex(javax.swing.tree.TreeNode arg0)
getIndex
in interface javax.swing.tree.TreeNode
public boolean isLeaf()
isLeaf
in interface javax.swing.tree.TreeNode
public void displayTree()
public void setLink(java.lang.String link)
link
- String
the link.public void setLink(java.lang.String link, boolean ignore)
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!public java.lang.String getLink()
String
the stored link or null.public void setInclude(java.lang.String include)
include
- A String
representing a valid url an absolute or relative path of the resource to included.public java.lang.String getInclude()
String
the inlcude information, or null if none stored.public void setDocumentAuthor(java.lang.String author)
author
- String
the author of the document.public java.lang.String getDocumentAuthor()
String
the Author of this document.public void setDocumentVersion(java.lang.String version)
version
- String
the version of the document.public java.lang.String getDocumentVersion()
String
the Version of the document, if available, null otherwise.public void setDocumentDate(java.util.Date date)
date
- Date
the date.public java.util.Date getDocumentDate()
Date
the create date of the document, or null.public void loadInclude()
public void loadAllIncludes()
public void setFileUrl(java.net.URL fileUrl)
fileUrl
- URL
the URL of the original file.public java.net.URL getFileUrl()
URL
the URL, if present, null otherwise.public Section getRootSection()
Section
the root section.public boolean containsIncludes()
Boolean
true if there are includes, false otherwise.public boolean containsLinks()
Boolean
true if there are links.public boolean containsMappings()
Boolean
true if mapping information is present, false otherwise.public boolean isTerminology()
Boolean
public void setAsTerminology(boolean isTerminology)
isTerminology
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |