de.unidu.is.retrieval
Class Schema

java.lang.Object
  extended byde.unidu.is.retrieval.Schema
Direct Known Subclasses:
DTDSchema, HyREXSchema

public class Schema
extends java.lang.Object

A schema definition. A schema consists of a list of attributes, which are extracted from the XML document using XPath expressions (similar to the HyREX DDL file).

Since:
2004-01-03
Version:
$Revision: 1.17 $, $Date: 2005/03/02 10:42:42 $
Author:
Henrik Nottelmann

Field Summary
protected  SchemaElement rootElement
          The root element of the schema.
protected  java.lang.String schemaName
          The schema name.
protected  boolean useXPathForQuery
          A flag specifying if an XPath expression is used in the query, or if attributes are used.
 
Constructor Summary
Schema()
          Creates a new, empty schema instance.
Schema(java.lang.String schemaName)
          Creates a new, empty schema instance.
 
Method Summary
 void addAlias(java.lang.String xpath, java.lang.String alias)
          Adds an alias.
 void addAliases()
          Adds standard aliases (use converted XPaths).
 void clearAliases()
          Removes all aliases.
 java.lang.String convPath(java.lang.String path)
          Converts a XPath path by removing the first element name and "/text()", transforming "/" into "__", "-" into "_" and "@" into "at":
 java.util.List extractValues(org.w3c.dom.Document document, java.lang.String att)
          Extract all values from the document for the given attribute.
 java.lang.String getAlias(java.lang.String path)
          Returns the alias for the specified path.
 java.util.List getAliases()
          Returns a list with all aliases.
 java.util.List getAliasesForXPath(java.lang.String path)
          Returns the aliases for the specified path.
 SchemaElement getElement(java.lang.String path)
          Returns the schema element for the specified path (XPath expression or alias).
 java.lang.String getHierarchicalView()
          Returns a hierarchical view of this schema.
 java.lang.String getPath(java.lang.String path)
          Returns the unified path for queries.
 SchemaElement getRootElement()
          Returns the root schema element.
 java.lang.String getSchemaName()
          Returns the schema name.
 java.lang.String getXPath(java.lang.String alias)
          Returns the XPath expression for the specified path.
 java.util.List getXPaths()
          Returns a list with the XPath expressions.
 java.util.List getXPathsForAlias(java.lang.String alias)
          Returns the XPath expressions for the specified path.
 void setRootElement(SchemaElement element)
          Sets the root schema element.
 void setSchemaName(java.lang.String schemaName)
          Sets the schema name.
 void setUseXPathForQuery(boolean b)
          Specifies if XPath expressions are used in the query instead of attributes.
 void unifyPathForCondition(QueryCondition condition)
          Unifies the path in the specified query condition.
 boolean usesXPathForQuery()
          Returns true iff XPath expressions are used in the query instead of attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemaName

protected java.lang.String schemaName
The schema name.


rootElement

protected SchemaElement rootElement
The root element of the schema.


useXPathForQuery

protected boolean useXPathForQuery
A flag specifying if an XPath expression is used in the query, or if attributes are used.

Constructor Detail

Schema

public Schema()
Creates a new, empty schema instance.


Schema

public Schema(java.lang.String schemaName)
Creates a new, empty schema instance.

Parameters:
schemaName - schema name
Method Detail

getSchemaName

public java.lang.String getSchemaName()
Returns the schema name.

Returns:
schema name

setSchemaName

public void setSchemaName(java.lang.String schemaName)
Sets the schema name.

Parameters:
schemaName - schema name

getRootElement

public SchemaElement getRootElement()
Returns the root schema element.

Returns:
root schema element

setRootElement

public void setRootElement(SchemaElement element)
Sets the root schema element.

Parameters:
element - new root schema element

usesXPathForQuery

public boolean usesXPathForQuery()
Returns true iff XPath expressions are used in the query instead of attributes.

Returns:
true iff XPath expressions are used in the query instead of attributes

setUseXPathForQuery

public void setUseXPathForQuery(boolean b)
Specifies if XPath expressions are used in the query instead of attributes.

Parameters:
b - if true, XPath expressions are used in the query

getElement

public SchemaElement getElement(java.lang.String path)
Returns the schema element for the specified path (XPath expression or alias).

Parameters:
path - path (XPath expression or alias)
Returns:
corresponding schema element

getXPaths

public java.util.List getXPaths()
Returns a list with the XPath expressions.

Returns:
list with the XPath expressions (as strings)

getAliases

public java.util.List getAliases()
Returns a list with all aliases.

Returns:
list with the aliases (as strings)

getPath

public java.lang.String getPath(java.lang.String path)
Returns the unified path for queries. If XPath expressions are used in queries, then it is an XPath expression, otherwise it is an alias.

Parameters:
path - path (XPath expression or alias)
Returns:
unified path

unifyPathForCondition

public void unifyPathForCondition(QueryCondition condition)
Unifies the path in the specified query condition. If XPath expressions are used in queries, then it is an XPath expression, otherwise it is an alias.

Parameters:
condition - query condition

getAlias

public java.lang.String getAlias(java.lang.String path)
Returns the alias for the specified path.

Parameters:
path - path (XPath expression or alias)
Returns:
alias

getAliasesForXPath

public java.util.List getAliasesForXPath(java.lang.String path)
Returns the aliases for the specified path.

Parameters:
path - XPath expression)
Returns:
aliases

getXPath

public java.lang.String getXPath(java.lang.String alias)
Returns the XPath expression for the specified path.

Parameters:
alias - path (XPath expression or alias)
Returns:
XPath expression

getXPathsForAlias

public java.util.List getXPathsForAlias(java.lang.String alias)
Returns the XPath expressions for the specified path.

Parameters:
alias - alias
Returns:
XPath expressions

addAlias

public void addAlias(java.lang.String xpath,
                     java.lang.String alias)
Adds an alias.

Parameters:
xpath - XPath expression
alias - alias for the specified XPath expression

addAliases

public void addAliases()
Adds standard aliases (use converted XPaths).


clearAliases

public void clearAliases()
Removes all aliases.


convPath

public java.lang.String convPath(java.lang.String path)
Converts a XPath path by removing the first element name and "/text()", transforming "/" into "__", "-" into "_" and "@" into "at":

Parameters:
path - XPath
Returns:
converted path

extractValues

public java.util.List extractValues(org.w3c.dom.Document document,
                                    java.lang.String att)
Extract all values from the document for the given attribute.

Parameters:
document - XML document
att - attribute (XPath or alias)
Returns:
list with all values (as strings)

getHierarchicalView

public java.lang.String getHierarchicalView()
Returns a hierarchical view of this schema.

Returns:
hierarchical view of this schema