de.folt.models.datamodel
Class MultiLingualObjectCollection

java.lang.Object
  extended by java.util.Observable
      extended by de.folt.models.datamodel.BasicDataSource
          extended by de.folt.models.datamodel.MultiLingualObjectCollection
All Implemented Interfaces:
DataSource, java.util.Enumeration<MultiLingualObject>, java.util.Observer

public class MultiLingualObjectCollection
extends BasicDataSource

Author:
klemens To change the template for this generated type comment go to Window - Preferences - Java - Code Generation - Code and Comments

Nested Class Summary
 
Nested classes/interfaces inherited from class de.folt.models.datamodel.BasicDataSource
BasicDataSource.BasicDataSourceObserver
 
Constructor Summary
MultiLingualObjectCollection()
           
MultiLingualObjectCollection(DataSourceProperties dataSourceProperties)
           
 
Method Summary
 boolean addMonoLingualObject(MonoLingualObject monoLingualObject, boolean mergeObjects)
          addMultiLingualObject adds a MonoLingualObject to the given MultiLingualObject to the data source
 boolean addMultiLingualObject(MultiLingualObject multiLingualObject, boolean mergeObjects)
          addMultiLingualObject adds a MultiLingualObject to the data source
 boolean bPersist()
          bPersist method persists any data in the data source
 void cleanDataSource()
          cleanDataSource method is used to allow some clean operations e.g. after an instance has been loaded.
 boolean clearDataSource()
          clearDataSource removes the content in a data source.
 boolean containsFormattedSegment(java.lang.String formattedSegment, java.lang.String language)
          containsFormattedSegment checks if a formatted segment for a given language is contained in the Collection
 boolean containsPlainTextSegment(java.lang.String plainTextSegment, java.lang.String language)
          containsPlainTextSegment checks if a plainText segment for a given language is contained in the Collection
 boolean createDataSource(DataSourceProperties dataModelProperties)
          createDataSource creates a new Data source; this is esp. intended for creating a new database, e.g. in MySQL or Ms SQL Server.
 boolean deleteDataSource(DataSourceProperties dataModelProperties)
          deleteDataSource deletes an existing Data source; this is esp. intended for deleting a database, e.g. in MySQL or Ms SQL Server.
 MultiLingualObject get(java.lang.Integer id)
          get the MUL based on its id
 MultiLingualObject getFormattedSegment(java.lang.String formattedSegment, java.lang.String language)
          getFormattedSegment the MUL based on a formatted segment and language
 MultiLingualObject getPlainTextSegment(java.lang.String plainTextSegment, java.lang.String language)
          getPlainTextSegment the MUL based on a plaintext segment and language
 boolean hasMoreElements()
           
 void initEnumeration()
          initEnumeration initialises the Enumeration of the data source
 MultiLingualObject nextElement()
           
 MultiLingualObject put(MultiLingualObject value)
           
 void removeDataSource()
          removeDataSource method called when the DataSource should be removed
 boolean removeMonoLingualObject(MonoLingualObject monoLingualObject)
          removeMonoLingualObject removes a MonoLingualObject from the data source; not all data source may support this method and may return false in any case (e.g.
 boolean removeMultiLingualObject(MultiLingualObject multiLingualObject)
          removeMultiLingualObject removes a MultiLingualObject from the data source
 java.util.Vector<MonoLingualObject> search(MonoLingualObject searchMonoLingualObject, java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
          search search for a MonoLingualObject; if no language is given in the searchMonoLingualObject the search is done independent of the language
 org.jdom.Element translate(org.jdom.Element transUnit, org.jdom.Element file, XliffDocument xliffDocument, java.lang.String sourceLanguage, java.lang.String targetLanguage, int matchSimilarity, java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
          translate translates a trans-unit given the source language, target Language and match similarity
 void update(java.util.Observable arg0, java.lang.Object arg1)
           
 
Methods inherited from class de.folt.models.datamodel.BasicDataSource
addData, bAuthenticate, bSupportMultiThreading, changedMonolingualObjects, checkIfTranslationExistsInDataSource, checkIfTranslationExistsInDataSource, containsKey, containsValue, copyFrom, copyTo, currentTimeMillis, exportTmxFile, exportXliffFile, getAllAttributes, getChangedIds, getData, getDataSourceName, getDataSourceProperties, getDataSourceType, getDefaultDataSourceConfigurationsFileName, getFuzzyTree, getIds, getILogLevel, getLastErrorCode, getMonoLingualObjectFromId, getMonoLingualObjectFromUniqueId, getMultiLingualObjectCache, getMultiLingualObjectFromId, getMultiLingualObjectFromUniqueId, getUniqueIds, importTbxFile, importTmxFile, importXliffFile, isBChanged, isBLoadAttributesLazy, isSyncDataSource, main, removeData, runFilterMethod, saveModifiedMonoLingualObject, saveModifiedMultiLingualObject, searchRegExp, searchWordBased, setBChanged, setBLoadAttributesLazy, setDataSourceType, setDefaultDataSourceConfigurationsFileName, setILogLevel, setILogLevel, setLastErrorCode, setMultiLingualObjectCache, setOpenTMSPropertiesFile, subSegmentResultsToGlossary, subSegmentTranslate, update
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiLingualObjectCollection

public MultiLingualObjectCollection()

MultiLingualObjectCollection

public MultiLingualObjectCollection(DataSourceProperties dataSourceProperties)
Parameters:
dataSourceProperties - key: "dataSource" if exists a) will read the data source from this file and b) if bPersists(9 is called will be used to save the dataSource in this file
Method Detail

addMonoLingualObject

public boolean addMonoLingualObject(MonoLingualObject monoLingualObject,
                                    boolean mergeObjects)
Description copied from interface: DataSource
addMultiLingualObject adds a MonoLingualObject to the given MultiLingualObject to the data source

Specified by:
addMonoLingualObject in interface DataSource
Overrides:
addMonoLingualObject in class BasicDataSource
Parameters:
monoLingualObject - the MOL object to add
mergeObjects - if true first a search is done if the containing MonoLingualObjects exist in the data source (based on the segment text); if they exist they are merged; if false the MUL is added as new entry
Returns:
true if added; false if the MultiLingualObject does not exist

addMultiLingualObject

public boolean addMultiLingualObject(MultiLingualObject multiLingualObject,
                                     boolean mergeObjects)
Description copied from interface: DataSource
addMultiLingualObject adds a MultiLingualObject to the data source

Specified by:
addMultiLingualObject in interface DataSource
Overrides:
addMultiLingualObject in class BasicDataSource
Parameters:
multiLingualObject - the object to add
mergeObjects - if true first a search is done if the containing MonoLingualObjects exist in the data source (based on the segment text); if they exist they are merged; if false the MUL is added as new entry
Returns:
true if added; false if not

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration<MultiLingualObject>
Overrides:
hasMoreElements in class BasicDataSource

initEnumeration

public void initEnumeration()
Description copied from interface: DataSource
initEnumeration initialises the Enumeration of the data source

Specified by:
initEnumeration in interface DataSource
Overrides:
initEnumeration in class BasicDataSource

nextElement

public MultiLingualObject nextElement()
Specified by:
nextElement in interface java.util.Enumeration<MultiLingualObject>
Overrides:
nextElement in class BasicDataSource

cleanDataSource

public void cleanDataSource()
Description copied from interface: DataSource
cleanDataSource method is used to allow some clean operations e.g. after an instance has been loaded.
An example is disposing a tmx document after having read all the entries.

Specified by:
cleanDataSource in interface DataSource
Overrides:
cleanDataSource in class BasicDataSource

clearDataSource

public boolean clearDataSource()
                        throws OpenTMSException
Description copied from interface: DataSource
clearDataSource removes the content in a data source. In addition it can be used to delete a TMX data source.

Specified by:
clearDataSource in interface DataSource
Overrides:
clearDataSource in class BasicDataSource
Returns:
true if success
Throws:
OpenTMSException

containsFormattedSegment

public boolean containsFormattedSegment(java.lang.String formattedSegment,
                                        java.lang.String language)
containsFormattedSegment checks if a formatted segment for a given language is contained in the Collection

Parameters:
formattedSegment - the formatted text segment
language - the language to search for
Returns:
true if contained

containsPlainTextSegment

public boolean containsPlainTextSegment(java.lang.String plainTextSegment,
                                        java.lang.String language)
containsPlainTextSegment checks if a plainText segment for a given language is contained in the Collection

Parameters:
plainTextSegment - the plan text segment
language - the language to search for
Returns:
true if contained

createDataSource

public boolean createDataSource(DataSourceProperties dataModelProperties)
                         throws OpenTMSException
Description copied from interface: DataSource
createDataSource creates a new Data source; this is esp. intended for creating a new database, e.g. in MySQL or Ms SQL Server. In addition it can be used to create a new empty TMX data source.

Specified by:
createDataSource in interface DataSource
Overrides:
createDataSource in class BasicDataSource
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

deleteDataSource

public boolean deleteDataSource(DataSourceProperties dataModelProperties)
                         throws OpenTMSException
Description copied from interface: DataSource
deleteDataSource deletes an existing Data source; this is esp. intended for deleting a database, e.g. in MySQL or Ms SQL Server. In addition it can be used to delete a TMX data source.
Currently supported key values are:
tmxfile, tmxFile, dataSourceName, dataSource, xlifffile, xliffFile - specifies names of the data sources
sourceLanguage if an xliff File datasource is created default = de
targetLanguage if an xliff File datasource is created default = en

Specified by:
deleteDataSource in interface DataSource
Overrides:
deleteDataSource in class BasicDataSource
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

get

public MultiLingualObject get(java.lang.Integer id)
get the MUL based on its id

Parameters:
id - an id to search
Returns:
the MUL

getFormattedSegment

public MultiLingualObject getFormattedSegment(java.lang.String formattedSegment,
                                              java.lang.String language)
getFormattedSegment the MUL based on a formatted segment and language

Parameters:
formattedSegment -
language -
Returns:
the MUL

getPlainTextSegment

public MultiLingualObject getPlainTextSegment(java.lang.String plainTextSegment,
                                              java.lang.String language)
getPlainTextSegment the MUL based on a plaintext segment and language

Parameters:
plainTextSegment -
language -
Returns:
the MUL

put

public MultiLingualObject put(MultiLingualObject value)

removeDataSource

public void removeDataSource()
Description copied from interface: DataSource
removeDataSource method called when the DataSource should be removed

Specified by:
removeDataSource in interface DataSource
Overrides:
removeDataSource in class BasicDataSource

removeMonoLingualObject

public boolean removeMonoLingualObject(MonoLingualObject monoLingualObject)
Description copied from interface: DataSource
removeMonoLingualObject removes a MonoLingualObject from the data source; not all data source may support this method and may return false in any case (e.g. XliffDataSource)

Specified by:
removeMonoLingualObject in interface DataSource
Overrides:
removeMonoLingualObject in class BasicDataSource
Parameters:
monoLingualObject - the MUL to remove
Returns:
true if removed; false if not

removeMultiLingualObject

public boolean removeMultiLingualObject(MultiLingualObject multiLingualObject)
Description copied from interface: DataSource
removeMultiLingualObject removes a MultiLingualObject from the data source

Specified by:
removeMultiLingualObject in interface DataSource
Overrides:
removeMultiLingualObject in class BasicDataSource
Parameters:
multiLingualObject - the MOL to remove
Returns:
true if removed; false if not

search

public java.util.Vector<MonoLingualObject> search(MonoLingualObject searchMonoLingualObject,
                                                  java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
Description copied from interface: DataSource
search search for a MonoLingualObject; if no language is given in the searchMonoLingualObject the search is done independent of the language

Specified by:
search in interface DataSource
Overrides:
search in class BasicDataSource
Parameters:
searchMonoLingualObject - the MonoLingualObject to search for
searchParameters - the hash table contains search parameters (e.g. language to search for etc.)
Example: matchMultiLingualLinguisticProperties for MultiLingualObjects or matchMonoLingualLinguisticProperties for MonoLingualObjects as filters
Returns:
a vector of MOL which contain the segments of the given monoLingualObject

translate

public org.jdom.Element translate(org.jdom.Element transUnit,
                                  org.jdom.Element file,
                                  XliffDocument xliffDocument,
                                  java.lang.String sourceLanguage,
                                  java.lang.String targetLanguage,
                                  int matchSimilarity,
                                  java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
                           throws OpenTMSException
Description copied from interface: DataSource
translate translates a trans-unit given the source language, target Language and match similarity

Specified by:
translate in interface DataSource
Overrides:
translate in class BasicDataSource
Parameters:
transUnit - the trans unit to translate to use
file - the file element currently to translate
xliffDocument - the basic xliff document
sourceLanguage - the source language to use
targetLanguage - the target language to use
matchSimilarity - the similarity (fuzzy) match quality (0 - 100) to use
translationParameters - the hash table contains parameters which control some parameters, e.g. should header/source/target properties be written to alt-trans
Returns:
the modified trans-unit with new translation
Throws:
OpenTMSException

update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)
Specified by:
update in interface java.util.Observer
Overrides:
update in class BasicDataSource

bPersist

public boolean bPersist()
Description copied from interface: DataSource
bPersist method persists any data in the data source

Specified by:
bPersist in interface DataSource
Overrides:
bPersist in class BasicDataSource
Returns:
true in case of success or false otherwise