org.exist.fluent
Class AttributeBuilder

java.lang.Object
  extended by org.exist.fluent.AttributeBuilder

public class AttributeBuilder
extends Object

Allows attributes to be added to, replaced in and removed from an existing element in the database. The updates are batched for efficiency; you must call commit() to apply them to the database.

Author:
Piotr Kaminski

Method Summary
 AttributeBuilder attr(String name, Object value)
          Create a new attribute or change the value of an existing one.
 AttributeBuilder attrIf(boolean condition, String name, Object value)
          Add an attribute or change an existing attribute's value only if the given condition holds.
 void commit()
          Commit the attribute changes recorded with the other methods to the database.
 AttributeBuilder delAttr(String name)
          Delete an attribute.
 AttributeBuilder namespace(String key, String uri)
          Add a namespace binding to this builder's namespaces map.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

namespace

public AttributeBuilder namespace(String key,
                                  String uri)
Add a namespace binding to this builder's namespaces map.

Parameters:
key - the prefix to bind
uri - the URI to bind it to
Returns:
this attribute builder, for chaining calls

attr

public AttributeBuilder attr(String name,
                             Object value)
Create a new attribute or change the value of an existing one. Later calls will overwrite the values set by earlier ones.

Parameters:
name - the name of the attribute
value - the value of the attribute, if not a String will be converted using DataUtils.toXMLString(Object)
Returns:
this attribute builder, for chaining calls

attrIf

public AttributeBuilder attrIf(boolean condition,
                               String name,
                               Object value)
Add an attribute or change an existing attribute's value only if the given condition holds. Behaves just like attr(String, Object) if condition is true, does nothing otherwise.

Parameters:
condition - the condition that must be satisfied before the attribute's value is set
name - the name of the attribute
value - the value of the attribute
Returns:
this attribute builder, for chaining calls

delAttr

public AttributeBuilder delAttr(String name)
Delete an attribute. Does nothing if the attribute does not exist. It's allowed (though probably pointless) to delete attributes that were created using attr(String, Object), even if not yet committed.

Parameters:
name - the name of the attribute to delete
Returns:
this attribute builder, for chaining

commit

public void commit()
Commit the attribute changes recorded with the other methods to the database.



Copyright (C) All rights reserved.