Package net.sf.okapi.lib.xliff2.core
Class ExtAttributes
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.core.ExtAttributes
-
- All Implemented Interfaces:
Iterable<ExtAttribute>
public class ExtAttributes extends Object implements Iterable<ExtAttribute>
Represents a set ofExtAttributeobjects and associated namespaces.
-
-
Constructor Summary
Constructors Constructor Description ExtAttributes()Creates a new emptyExtAttributesobject.ExtAttributes(ExtAttributes original)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteAttribute(String namespaceURI, String localName)Removes an attribute from this set.ExtAttributegetAttribute(String namespaceURI, String localName)Gets an attribute if it exists.StringgetAttributeValue(String namespaceURI, String localName)Gets the value for a given attribute name of a given namespace.StringgetNamespacePrefix(String namespaceURI)Gets the prefix for a given namespace URI.Set<String>getNamespaces()Gets the set of keys for the namespaces in this object.booleanhasNamespace()Indicates if this set has at least one namespace defined.booleanisEmpty()Indicates if this set is empty or not.Iterator<ExtAttribute>iterator()Creates an iterator for the attributes in this set.ExtAttributesetAttribute(String localName, String value)Sets an attribute without namespace for this set.ExtAttributesetAttribute(String namespaceURI, String localName, String value)Sets an attribute in this set.ExtAttributesetAttribute(ExtAttribute attribute)Sets a given attribute in this set.voidsetNamespace(String prefix, String namespaceURI)Sets a namespace in this set.intsize()Gets the number of attributes in this set.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ExtAttributes
public ExtAttributes()
Creates a new emptyExtAttributesobject.
-
ExtAttributes
public ExtAttributes(ExtAttributes original)
Copy constructor.- Parameters:
original- the original object to duplicate.
-
-
Method Detail
-
getAttributeValue
public String getAttributeValue(String namespaceURI, String localName)
Gets the value for a given attribute name of a given namespace.- Parameters:
namespaceURI- the namespace URI of the attribute.localName- the name of the attribute.- Returns:
- the value (can be null), or null if not found.
-
getAttribute
public ExtAttribute getAttribute(String namespaceURI, String localName)
Gets an attribute if it exists.- Parameters:
namespaceURI- the namespace URI of the attribute QName.localName- the local name of the attribute.- Returns:
- the attribute or null.
-
setAttribute
public ExtAttribute setAttribute(ExtAttribute attribute)
Sets a given attribute in this set. If an attribute with the same name and namespace URI already exists, the value of the existing one is replaced by the new one, but the attribute object itself is not changed.- Parameters:
attribute- the attribute to add/set.- Returns:
- the set/added attribute (may be the attribute passed, or the existing one).
-
setAttribute
public ExtAttribute setAttribute(String namespaceURI, String localName, String value)
Sets an attribute in this set. If an attribute with the same name and namespace URI already exists, the value of the existing one is replaced by the new one, but the attribute object itself is not changed.- Parameters:
namespaceURI- the namespace URI of the attribute.localName- the name of the attribute.value- the value of the attribute.- Returns:
- the set/added attribute.
-
setAttribute
public ExtAttribute setAttribute(String localName, String value)
Sets an attribute without namespace for this set. (this means the attribute will be part of the namespace of the element where it is defined).- Parameters:
localName- the name of the attribute.value- the value of the attribute.- Returns:
- the new attribute.
-
deleteAttribute
public void deleteAttribute(String namespaceURI, String localName)
Removes an attribute from this set. If the attribute is not found, nothing is done.- Parameters:
namespaceURI- the namespace URI of the attribute.localName- the name of the attribute.
-
isEmpty
public boolean isEmpty()
Indicates if this set is empty or not.- Returns:
- true if this set is empty, false if not.
-
size
public int size()
Gets the number of attributes in this set.- Returns:
- the number of attributes in this set.
-
iterator
public Iterator<ExtAttribute> iterator()
Creates an iterator for the attributes in this set.- Specified by:
iteratorin interfaceIterable<ExtAttribute>- Returns:
- a new iterator for the attributes in this set.
-
setNamespace
public void setNamespace(String prefix, String namespaceURI)
Sets a namespace in this set.- Parameters:
prefix- the namespace prefix.namespaceURI- the namsepace URI.
-
getNamespacePrefix
public String getNamespacePrefix(String namespaceURI)
Gets the prefix for a given namespace URI.- Parameters:
namespaceURI- the namespace URI.- Returns:
- the prefix for the given namespace URI, or null if not found.
-
hasNamespace
public boolean hasNamespace()
Indicates if this set has at least one namespace defined.- Returns:
- true if this set has at least one namespace defined, false otherwise.
-
-