All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lionbridge.content.sdk.models.TranslationOptions Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package com.lionbridge.content.sdk.models;

import com.lionbridge.content.sdk.ContentAPI;
import com.lionbridge.content.sdk.utilities.XmlUtils;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

public class TranslationOptions {
	private String currency;
	private URI notifyCompleteUrl;
	private URI notifyQuoteReadyUrl;
	private URI notifyQuotePaidUrl;
	private int serviceId;
	private SourceLanguage sourceLanguage;
	private List targetLanguages = new ArrayList<>();

	private boolean testMode = false;

	public TranslationOptions() {}

	public TranslationOptions(String sourceLanguage, List targetLanguages) throws IllegalArgumentException {
		if (sourceLanguage == null) {
			throw new IllegalArgumentException("Must specify a source language.");
		}
		this.sourceLanguage = new SourceLanguage(sourceLanguage);
		if (targetLanguages != null) {
			for(int i=0; i targetLanguages, String currency, URI notifyCompleteUrl, URI notifyQuoteReadyUrl, URI notifyQuotePaidUrl) {
		this(sourceLanguage, targetLanguages);
		this.currency = currency;
		this.notifyCompleteUrl = notifyCompleteUrl;
		this.notifyQuoteReadyUrl = notifyQuoteReadyUrl;
		this.notifyQuotePaidUrl = notifyQuotePaidUrl;
	}

	public String toXmlString() {
		StringBuilder builder = new StringBuilder();
		builder.append("");
		builder = XmlUtils.appendXmlTag(builder, "Currency", this.currency);
		if (this.notifyCompleteUrl != null) {
			builder = XmlUtils.appendXmlTag(builder, "NotifyCompleteURL", this.notifyCompleteUrl.toString());
		}
		if (this.notifyQuoteReadyUrl != null) {
			builder = XmlUtils.appendXmlTag(builder, "NotifyQuoteReadyURL", this.notifyQuoteReadyUrl.toString());
		}
		if (this.notifyQuotePaidUrl != null) {
			builder = XmlUtils.appendXmlTag(builder, "NotifyQuotePaidURL", this.notifyQuotePaidUrl.toString());
		}
		if (this.serviceId != 0) {
			builder = XmlUtils.appendXmlTag(builder, "ServiceID", String.valueOf(this.serviceId));
		}
		if (this.sourceLanguage != null) {
			builder.append(this.sourceLanguage.toXmlString());
		}
		if (this.targetLanguages != null) {
			builder.append("");
			for(int i=0; i");
		}
		builder.append("");
		return builder.toString();
	}

	public void initialize(ContentAPI client, Service service, boolean testing) {
		this.testMode = testing;
		this.initialize(client, service);
	}

	public void initialize(ContentAPI client, Service service) {
		if (client == null) {
			throw new IllegalArgumentException("Client cannot be null");
		}
		if (service == null) {
			throw new IllegalArgumentException("Service cannot be null");
		}
		if (this.currency == null) {
			this.setCurrency(client.getDefaultCurrency());
		}
		this.setServiceId(service.getServiceId());
		if (this.targetLanguages == null) {
			this.setTargetLanguages(service.getTargetLanguages());
		}
		List serviceSourceLanguageCodes = new ArrayList<>();
		for (int i=0; i serviceTargetLanguageCodes = new ArrayList<>();
		for (int i=0; i serviceSourceLanguageCodes = new ArrayList<>();
		for (int i=0; i serviceTargetLanguageCodes = new ArrayList<>();
		for (int i=0; i getTargetLanguages() {
		return targetLanguages;
	}

	public void setTargetLanguages(final List targetLanguages) {
		this.targetLanguages = targetLanguages;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy