Package net.sf.okapi.lib.xliff2.core
Class Tags
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.core.Tags
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(PCont tag)Adds a protected content tag to this object.intadd(Tag tag)Adds a tag to this collection.Tagget(int key)Tagget(CharSequence ctext, int pos)Tagget(String id, TagType tagType)Gets the tag for a given id and tag type.TaggetClosingTag(String id)Gets the closing tag for a given tag ID.TaggetClosingTag(Tag openingTag)Gets the closing tag for a given opening tag.CTaggetCTag(int key)Gets theCTagfor a given key.CTaggetCTag(CharSequence ctext, int pos)Gets theCTagfor a given reference in a coded text.intgetKey(Tag tag)Gets the key for a given code or marker.MTaggetMTag(int key)Gets theMTagfor a given key.MTaggetMTag(CharSequence ctext, int pos)Gets theMTagfor a given reference in a coded text.CTaggetOpeningCTag(String id)Gets the openingCTagfor a given id.MTaggetOpeningMTag(String id)Gets the openingMTagfor a given id.TaggetOpeningTag(String id)Gets the opening tag for a given tag ID.TaggetOpeningTag(Tag closingTag)Gets the opening tag for a given closing tag.PContgetPCont(int key)Gets thePContfor a given key.PContgetPCont(CharSequence ctext, int pos)Gets thePContfor a given reference in a coded text.intgetPContCount()Gets the number of protected content items in this object.StoregetStore()Gets the store associated with this collection.booleanhasCTagWithData()Indicates if this collection of tags has at least one code with original data.inthashCode()Iterator<Tag>iterator()Iterator<PCont>iteratorPCont()Creates an iterator for thePContobjects in this collection.voidremove(int key)Removes a tag for a given key.voidremovePCont(int key)Removes thePContobject for a given key.protected voidresetPContLastValue()intsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
resetPContLastValue
protected void resetPContLastValue()
-
hasCTagWithData
public boolean hasCTagWithData()
Indicates if this collection of tags has at least one code with original data.- Returns:
- true if the collection has at least one code with original data, false otherwise.
-
getClosingTag
public Tag getClosingTag(Tag openingTag)
Gets the closing tag for a given opening tag.- Parameters:
openingTag- the opening tag.- Returns:
- the closing tag, or null if it is not found.
-
getClosingTag
public Tag getClosingTag(String id)
Gets the closing tag for a given tag ID.- Parameters:
id- the ID of the closing tag to search for.- Returns:
- the closing tag, or null if no tag with the given ID is found.
-
getOpeningTag
public Tag getOpeningTag(Tag closingTag)
Gets the opening tag for a given closing tag.- Parameters:
closingTag- the closing tag.- Returns:
- the opening tag, or null if it is not found.
-
getOpeningTag
public Tag getOpeningTag(String id)
Gets the opening tag for a given tag ID.- Parameters:
id- the ID of the opening tag to search for.- Returns:
- the opening tag, or null if no tag with the given ID is found.
-
getOpeningCTag
public CTag getOpeningCTag(String id)
Gets the openingCTagfor a given id.- Parameters:
id- the ID of the opening tag to search for.- Returns:
- the opening
CTagor null if no tag with the given ID is found. - Throws:
InvalidParameterException- if a tag is found but it is not aCTagobject.
-
getOpeningMTag
public MTag getOpeningMTag(String id)
Gets the openingMTagfor a given id.- Parameters:
id- the ID of the opening tag to search for.- Returns:
- the opening
MTagor null if no tag with the given ID is found. - Throws:
InvalidParameterException- if a tag is found but it is not aMTagobject.
-
getPContCount
public int getPContCount()
Gets the number of protected content items in this object.- Returns:
- the number of protected content items in this object.
-
getStore
public Store getStore()
Gets the store associated with this collection.- Returns:
- the store associated with this collection.
-
get
public Tag get(int key)
- Parameters:
key- the key of the annotation or code tag to retrieve.- Returns:
- the tag for the given key, or null if there is no corresponding tag.
-
get
public Tag get(CharSequence ctext, int pos)
- Parameters:
ctext- the coded text (e.g. String or StringBuilder object).pos- the position of the first character of the reference.- Returns:
- the tag for the given tag reference, or null if there is no corresponding tag.
-
getCTag
public CTag getCTag(int key)
Gets theCTagfor a given key.- Parameters:
key- the key of the code tag to retrieve.- Returns:
- the tag for the given key, or null if there is no corresponding tag.
-
getCTag
public CTag getCTag(CharSequence ctext, int pos)
Gets theCTagfor a given reference in a coded text.- Parameters:
ctext- the coded text (e.g. String or StringBuilder object).pos- the position of the first character of the reference.- Returns:
- the tag for the given tag reference, or null if there is no corresponding tag.
-
getMTag
public MTag getMTag(int key)
Gets theMTagfor a given key.- Parameters:
key- the key of the code tag to retrieve.- Returns:
- the tag for the given key, or null if there is no corresponding tag.
-
getMTag
public MTag getMTag(CharSequence ctext, int pos)
Gets theMTagfor a given reference in a coded text.- Parameters:
ctext- the coded text (e.g. String or StringBuilder object).pos- the position of the first character of the reference.- Returns:
- the tag for the given tag reference, or null if there is no corresponding tag.
-
get
public Tag get(String id, TagType tagType)
Gets the tag for a given id and tag type.- Parameters:
id- the id of the tag to retrieve.tagType- the tag type of the tag to retrieve.- Returns:
- the tag for the given id and tag type, or null if it is not found.
-
getPCont
public PCont getPCont(int key)
Gets thePContfor a given key.- Parameters:
key- the key of the protected content tag to retrieve.- Returns:
- the tag for the given key, or null if there is no corresponding tag.
-
getPCont
public PCont getPCont(CharSequence ctext, int pos)
Gets thePContfor a given reference in a coded text.- Parameters:
ctext- the coded text (e.g. String or StringBuilder object).pos- the position of the first character of the reference.- Returns:
- the tag for the given key, or null if there is no corresponding tag.
-
getKey
public int getKey(Tag tag)
Gets the key for a given code or marker.- Parameters:
tag- the tag to lookup.- Returns:
- the key of the given tag, or -1 if not found.
-
add
public int add(Tag tag)
Adds a tag to this collection.- Parameters:
tag- the marker to add.- Returns:
- the key of the new marker reference.
-
add
public int add(PCont tag)
Adds a protected content tag to this object.- Parameters:
tag- the marker to add.- Returns:
- the key of the new protected content marker reference.
-
iteratorPCont
public Iterator<PCont> iteratorPCont()
Creates an iterator for thePContobjects in this collection.- Returns:
- a new iterator for
PCont.
-
remove
public void remove(int key)
Removes a tag for a given key.Warning: This method does not remove the corresponding tag reference in the coded text.
- Parameters:
key- the key of the tag to remove.- Throws:
IndexOutOfBoundsException- if the key is not found.
-
removePCont
public void removePCont(int key)
Removes thePContobject for a given key.Warning: This method does not remove the corresponding reference in the coded text.
- Parameters:
key- the key of the tag to remove.- Throws:
IndexOutOfBoundsException- if the key is not found.
-
-