|
Berkeley DB XML version 2.2.13 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.dbxml.XmlIndexSpecification
The encapsulation of the indexing specification
of a container. An indexing specification can be retrieved with the
XmlContainer.getIndexSpecification()
method, and modified using the
XmlContainer.setIndexSpecification(com.sleepycat.dbxml.XmlIndexSpecification, com.sleepycat.dbxml.XmlUpdateContext)
method.
Note that adding an index to a container results in re-indexing all of the documents in that container, which can take a very long time. It is good practice to design an application to add useful indices before populating a container.
A copy constructor is provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.
This object is not thread-safe, and can only be safely used by one thread at a time in an application.
Field Summary | |
static int |
KEY_EQUALITY
Equality key type. |
static int |
KEY_NONE
No key type. |
static int |
KEY_PRESENCE
Presence key type. |
static int |
KEY_SUBSTRING
Substring key type. |
static int |
NODE_ATTRIBUTE
Attribute node type. |
static int |
NODE_ELEMENT
Element node type. |
static int |
NODE_METADATA
Metadata node type. |
static int |
NODE_NONE
No node type. |
static int |
PATH_EDGE
Edge path type. |
static int |
PATH_NODE
Node path type. |
static int |
PATH_NONE
No path type. |
static int |
UNIQUE_OFF
The indexed value need not be unique container-wide |
static int |
UNIQUE_ON
The indexed value must be unique container-wide |
Constructor Summary | |
XmlIndexSpecification()
|
Method Summary | |
void |
addDefaultIndex(int type,
int syntax)
Adds an indexing strategy to the default index specification. |
void |
addDefaultIndex(String index)
Adds a single indexing strategy to the default index. |
void |
addIndex(String uri,
String name,
int type,
int syntax)
Identifies an indexing strategy to set for the identified node. |
void |
addIndex(String uri,
String name,
String index)
Adds an index to the index specification. |
void |
delete()
Free the native resources associated with this object. |
void |
deleteDefaultIndex(int type,
int syntax)
Delete the identified index from the default index specification. |
void |
deleteDefaultIndex(String index)
Deletes one or more indexing strategies to the default index. |
void |
deleteIndex(String uri,
String name,
int type,
int syntax)
Deletes a single index strategy from the identified node. |
void |
deleteIndex(String uri,
String name,
String index)
Deletes indexing strategies for a named document or metadata node. |
XmlIndexDeclaration |
find(String uri,
String name)
Returns the indexing strategies for a named document or metadata node. |
String |
getDefaultIndex()
Retrieves the default index. |
XmlIndexDeclaration |
next()
Obtains the next index in the XmlIndexSpecification . |
void |
replaceDefaultIndex(int type,
int syntax)
Replaces the default indexing strategy for the container. |
void |
replaceDefaultIndex(String index)
Identifies one or more indexing strategies to set for the default index. |
void |
replaceIndex(String uri,
String name,
int type,
int syntax)
Replaces the indexing strategies for a named document or metadata node. |
void |
replaceIndex(String uri,
String name,
String index)
Replaces the indexing strategies for a named document or metadata node. |
void |
reset()
Resets the index specification iterator to the beginning of the index list. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int UNIQUE_OFF
public static final int UNIQUE_ON
public static final int PATH_NONE
public static final int PATH_NODE
public static final int PATH_EDGE
public static final int NODE_NONE
public static final int NODE_ELEMENT
public static final int NODE_ATTRIBUTE
public static final int NODE_METADATA
public static final int KEY_NONE
public static final int KEY_PRESENCE
public static final int KEY_EQUALITY
public static final int KEY_SUBSTRING
Constructor Detail |
public XmlIndexSpecification()
Method Detail |
public void delete()
public void addIndex(String uri, String name, int type, int syntax) throws XmlException
uri
- The namespace of the node to be indexed. The default namespace is selected by passing an empty string for the namespace.name
- The name of the element or attribute node to be indexed.type
- A series of values bitwise OR'd together to form the index strategy.
To indicate whether the indexed value must be unique container-wide, use one of the following, or leave the value out entirely:
To identify the path type, use one of the following:
To identify the node type, use one of the following:
Note that if NODE_METADATA
is used, then PATH_NODE
must also be used as well.
To identify the key type, use one of the following:
For example:
XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_SUBSTRING
syntax
- Identifies the type of information being indexed. The value must be one of the XmlValue enumerated types:
XmlValue.NONE
XmlValue.ANY_URI
XmlValue.BASE_64_BINARY
XmlValue.BOOLEAN
XmlValue.DATE
XmlValue.DATE_TIME
XmlValue.DAY_TIME_DURATION
XmlValue.DECIMAL
XmlValue.DOUBLE
XmlValue.DURATION
XmlValue.FLOAT
XmlValue.G_DAY
XmlValue.G_MONTH
XmlValue.G_MONTH_DAY
XmlValue.G_YEAR
XmlValue.G_YEAR_MONTH
XmlValue.HEX_BINARY
XmlValue.NOTATION
XmlValue.QNAME
XmlValue.STRING
XmlValue.TIME
XmlValue.YEAR_MONTH_DURATION
XmlValue.UNTYPED_ATOMIC
Note that if KEY_PRESENCE
is specified for type
,
then this parameter must be XmlValue.NONE
.
XmlException
public void addIndex(String uri, String name, String index) throws XmlException
XmlContainer.setIndexSpecification(com.sleepycat.dbxml.XmlIndexSpecification, com.sleepycat.dbxml.XmlUpdateContext)
.
You identify the indexing strategy that you want to add to the index specification in one of two ways. The first way is to provide a string that identifies the desired indexing strategy. The second is to use XmlIndexSpecification and XmlValue class constants to identify the same information.
Either way, an index strategy is set by providing the name of a node and one or more indexing strategies for that node. The node name can be either that of an element, attribute, or metadata node. Metadata nodes are used only for indexing metadata. Element and attribute nodes are used for indexing XML document content. For example, in the XML fragment:
there are two node names that index strategies could be specified for, the element node name is 'art', and the attribute node name is 'title'."<art title='...'/>"
When specifying indexing strategies, you must provide the following information:
there is an edge at <a><b> and another one at <b><c>."<a><b><c>foo</c>o</b></a>"
In addition to setting index strategies for specified nodes, applications can also specify a default indexing strategy for all nodes in a container by using addDefaultIndex(int, int)
. When a container is first created the default indexing strategy is 'unique-node-metadata-equality-string'.
For more information on designing an indexing strategy for your application, see the Berkeley DB XML Getting Started Guide.
uri
- The namespace of the node to be indexed. The default namespace is
selected by passing an empty string for the namespace.name
- The name of the element or attribute node to be indexed.index
- A comma-separated list of strings that represent the indexing strategy.
The strings must contain the following information in the following order:
unique-{path type}-{node type}-{key type}-{syntax}
where:
unique indicates that the indexed value is unique in the container. If this keyword does not appear on the index string, then the indexed value is not required to be unique in the container.
{path type} is either node or edge.
{node type} is one of element, attribute, or metadata. If metadata is specified, then {path type} must be node.
{key type} is one of presence, equality, or substring.
{syntax} identifies the type of information being indexed. It must be one of the following values:
Note that if {key type} is presence, then {syntax} must be none or simply not specified.
For example, examples index strings are:
unique-node-element-presence
node-element-equality-string
edge-element-presence-none
node-element-equality-float
XmlException
public void deleteIndex(String uri, String name, int type, int syntax) throws XmlException
uri
- The namespace of the node for which you want the index deleted. The default namespace is selected by passing an empty string for the
namespace.name
- The name of the element or attribute node to be indexed.type
- A series of values bitwise OR'd
together to form the index strategy. See addIndex(String, String, int, int)
for a complete description.syntax
- Identifies the type of information being indexed. See addIndex(String, String, int, int)
for a complete description.
XmlException
public void deleteIndex(String uri, String name, String index) throws XmlException
uri
- The namespace of the node for which you want the index deleted. The default namespace is selected by passing an empty string for the
namespace.name
- The name of the element or attribute node to be indexed.index
- A comma-separated list of strings that represent the indexing strategy. See addIndex(String, String, String)
for a complete description.
XmlException
public void replaceIndex(String uri, String name, int type, int syntax) throws XmlException
uri
- The namespace of the node for which you want the index replaced. The default namespace is selected by passing an empty string for the
namespace.name
- The name of the element or attribute node to be indexed.type
- A series of values bitwise OR'd
together to form the index strategy. See addIndex(String, String, int, int)
for a complete description.syntax
- Identifies the type of information being indexed. See addIndex(String, String, int, int)
for a complete description.
XmlException
public void replaceIndex(String uri, String name, String index) throws XmlException
Identifies one or more indexing strategies to set for the identified node. The strategies are identified using a space-separated listing of strings.
uri
- The namespace of the node for which you want the index replaces. The default namespace is selected by passing an empty string for the
namespace.name
- The name of the element or attribute node to be indexed.index
- A comma-separated list of strings that represent the indexing strategy. See addIndex(String, String, String)
for a complete description.
XmlException
public void addDefaultIndex(int type, int syntax) throws XmlException
type
- A series of values bitwise OR'd
together to form the index strategy. See addIndex(String, String, int, int)
for a complete description.syntax
- Identifies the type of information being indexed. See addIndex(String, String, int, int)
for a complete description.
XmlException
public void addDefaultIndex(String index) throws XmlException
index
- A comma-separated list of strings that represent the indexing strategy. See addIndex(String, String, String)
for a complete description.
XmlException
public void deleteDefaultIndex(int type, int syntax) throws XmlException
addDefaultIndex(int, int)
.
type
- A series of values bitwise OR'd
together to form the index strategy. See addIndex(String, String, int, int)
for a complete description.syntax
- Identifies the type of information being indexed. See addIndex(String, String, int, int)
for a complete description.
XmlException
public void deleteDefaultIndex(String index) throws XmlException
index
- A comma-separated list of strings that represent the indexing strategy. See addIndex(String, String, String)
for a complete description.
XmlException
public void replaceDefaultIndex(int type, int syntax) throws XmlException
addIndex(java.lang.String, java.lang.String, int, int)
.
type
- A series of values bitwise OR'd
together to form the index strategy. See addIndex(String, String, int, int)
for a complete description.syntax
- Identifies the type of information being indexed. See addIndex(String, String, int, int)
for a complete description.
XmlException
public void replaceDefaultIndex(String index) throws XmlException
index
- A comma-separated list of strings that represent the indexing strategy. See addIndex(String, String, String)
for a complete description.
XmlException
public void reset() throws XmlException
next()
to iterate through the
indices contained in the index specification.
XmlException
public XmlIndexDeclaration find(String uri, String name) throws XmlException
uri
- The namespace of the node to be indexed. The default namespace is selected by passing an empty string for the namespace.name
- The name of the element or attribute node to be indexed.
XmlException
public XmlIndexDeclaration next() throws XmlException
XmlIndexSpecification
. Use
reset()
to reset this iterator.
This method returns null
if no additional indices exist in the index list.
XmlException
public String getDefaultIndex() throws XmlException
XmlException
|
Berkeley DB XML version 2.2.13 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |