de.init.its.process.re
Class XLIFFProcessor

java.lang.Object
  extended by de.init.its.process.re.XLIFFProcessor

public class XLIFFProcessor
extends java.lang.Object

Service class to write and read XLIFF Files from and to ITS ODT files This class makes heavy use of the filtering mechanisms of the OKAPI Framework to access all TEXT_UNITS.

Author:
m.kandora

Constructor Summary
XLIFFProcessor()
           
 
Method Summary
 ItsTree<Element> backward(java.net.URI resource, java.net.URI target, net.sf.okapi.common.LocaleId sourceLocale, net.sf.okapi.common.LocaleId targetLocale)
          Implements the backward process to generate ITS ODT Files from xliff files without loss of content information.
protected  ItsTree<Element> findByName(ItsTree<Element> t, java.lang.String name)
          Returns an element by name
 IOResult forward(java.net.URI resource, java.net.URI target, net.sf.okapi.common.LocaleId sourceLocale, net.sf.okapi.common.LocaleId targetLocale)
          Implements the forward process to create an XLIFF file from an ITS ODT resource
 boolean hasDataCategory(ItsTree<Element> child)
          returns true, if this subtree contains its to xliff mapping
 boolean isLeafGroup(java.lang.String id, ItsTree<Element> group)
          Returns true, if XLIFF group element contains no more groups and is considered a leaf
protected  Element mkSpanElement(java.util.Map<ItsAttributes,java.util.List<java.lang.String>> mapping)
          Creates a spanning Element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XLIFFProcessor

public XLIFFProcessor()
Method Detail

forward

public IOResult forward(java.net.URI resource,
                        java.net.URI target,
                        net.sf.okapi.common.LocaleId sourceLocale,
                        net.sf.okapi.common.LocaleId targetLocale)
Implements the forward process to create an XLIFF file from an ITS ODT resource

Parameters:
resource - the resource its odt file
target - the target file uri for writing the xliff file
sourceLocale - the source locale. use the static accessor methods to create a new one
targetLocale - the target locale
Returns:
the result of the operation

backward

public ItsTree<Element> backward(java.net.URI resource,
                                 java.net.URI target,
                                 net.sf.okapi.common.LocaleId sourceLocale,
                                 net.sf.okapi.common.LocaleId targetLocale)
Implements the backward process to generate ITS ODT Files from xliff files without loss of content information. the conversion process from xliff to odt will consider each translation-unit as text:p element in odt (this runs along with OKAPI to simplify things) the only reasonable source for converting documents back to odt format will be the trans-unit target element, since this will contain the translated resource.

Parameters:
resource - the xliff resource
target - the target to generate the odt file
Returns:
the result of the operation

findByName

protected ItsTree<Element> findByName(ItsTree<Element> t,
                                      java.lang.String name)
Returns an element by name

Parameters:
t -
name -
Returns:

isLeafGroup

public boolean isLeafGroup(java.lang.String id,
                           ItsTree<Element> group)
Returns true, if XLIFF group element contains no more groups and is considered a leaf

Parameters:
id - the id to look for
group - the group element
Returns:
true, if leaf

hasDataCategory

public boolean hasDataCategory(ItsTree<Element> child)
returns true, if this subtree contains its to xliff mapping

Parameters:
child - the child to check for its data category
Returns:
true, if subtree has data category

mkSpanElement

protected Element mkSpanElement(java.util.Map<ItsAttributes,java.util.List<java.lang.String>> mapping)
Creates a spanning Element

Parameters:
mapping -
Returns: