Add an additional {@link ExchangeRateProvider} to the instance's delegate
list.

@param prov The {@link ExchangeRateProvider} to be added, not {@code null}
.
@throws java.lang.NullPointerException if the provider is null.
.
337888
private void addProvider(ExchangeRateProvider prov) {
        providers.add(Optional.ofNullable(prov)
                .orElseThrow(() -> new NullPointerException("ConversionProvider required.")));
    }
356114
public static base_response add(nitro_service client, ntpserver resource) throws Exception {
		ntpserver addresource = new ntpserver();
		addresource.serverip = resource.serverip;
		addresource.servername = resource.servername;
		addresource.minpoll = resource.minpoll;
		addresource.maxpoll = resource.maxpoll;
		addresource.autokey = resource.autokey;
		addresource.key = resource.key;
		return addresource.add_resource(client);
	}
1006156
public function registerHook(IHookProvider $prov, $moduleName, $loadBefore = null) {
        $found = false;

        if(is_a($prov, '\\pff\\Iface\\IBeforeHook')) {
            $found = $this->addHook($this->_beforeController, $prov, $moduleName, $loadBefore);
        }

        if(is_a($prov, '\\pff\\Iface\\IAfterHook')) {
            $found = $this->addHook($this->_afterController, $prov, $moduleName, $loadBefore);
        }

        if(is_a($prov, '\\pff\\Iface\\IBeforeSystemHook')) {
            $found = $this->addHook($this->_beforeSystem, $prov, $moduleName, $loadBefore);
        }

        if(is_a($prov, '\\pff\\Iface\\IBeforeViewHook')) {
            $found = $this->addHook($this->_beforeView, $prov, $moduleName, $loadBefore);
        }

        if(is_a($prov, '\\pff\\Iface\\IAfterViewHook')) {
            $found = $this->addHook($this->_afterView, $prov, $moduleName, $loadBefore);
        }

        if(!$found) {
            throw new HookException("Cannot add given class as a hook provider: ". get_class($prov));
        }
    }
1369306
public void setValue(org.openprovenance.prov.model.Value value) {
	if (value!=null) {
	    this.value = value;
	    getAllAttributes().add((org.openprovenance.prov.model.Attribute)value);	//FIXME: should replace previous value!
	}
    }
687705
public void initialize(PropertyProvider propertyProvider) {

        host = propertyProvider.getProperty(PropertyProvider.PROPERTY_HOST);
        if (host == null) {
            host = propertyProvider.getProperty(PropertyProvider.PROPERTY_GRAYLOG_HOST);
        }

        String port = propertyProvider.getProperty(PropertyProvider.PROPERTY_PORT);
        if (port == null) {
            port = propertyProvider.getProperty(PropertyProvider.PROPERTY_GRAYLOG_PORT);
        }

        if (port != null && !"".equals(port)) {
            this.port = Integer.parseInt(port);
        }

        originHost = propertyProvider.getProperty(PropertyProvider.PROPERTY_ORIGIN_HOST);
        setExtractStackTrace(propertyProvider.getProperty(PropertyProvider.PROPERTY_EXTRACT_STACKTRACE));
        setFilterStackTrace("true".equalsIgnoreCase(propertyProvider.getProperty(PropertyProvider.PROPERTY_FILTER_STACK_TRACE)));

        String includeLogMessageParameters = propertyProvider
                .getProperty(PropertyProvider.PROPERTY_INCLUDE_LOG_MESSAGE_PARAMETERS);
        if (includeLogMessageParameters != null && !includeLogMessageParameters.trim().equals("")) {
            setIncludeLogMessageParameters("true".equalsIgnoreCase(includeLogMessageParameters));
        }

        setupStaticFields(propertyProvider);
        setupAdditionalFieldTypes(propertyProvider);
        facility = propertyProvider.getProperty(PropertyProvider.PROPERTY_FACILITY);
        String version = propertyProvider.getProperty(PropertyProvider.PROPERTY_VERSION);

        if (version != null && !"".equals(version)) {
            this.version = version;
        }

        String messageSize = propertyProvider.getProperty(PropertyProvider.PROPERTY_MAX_MESSAGE_SIZE);
        if (messageSize != null) {
            maximumMessageSize = Integer.parseInt(messageSize);
        }

        String timestampPattern = propertyProvider.getProperty(PropertyProvider.PROPERTY_TIMESTAMP_PATTERN);
        if (timestampPattern != null && !"".equals(timestampPattern)) {
            this.timestampPattern = timestampPattern;
        }
    }
455985
public void registerMultiValueProvider(MultiValueProvider multiValueProvider) {
    String name = multiValueProvider.getName();
    MultiValueProvider oldProvider = multiValues.put(name, multiValueProvider);
    if (oldProvider != null) {
      LOGGER.warn("MultiValueProvider [{}] @{} has been replaced by [{}]!",
        oldProvider,
        multiValueProvider.getName(),
        multiValueProvider);
    }
    notifyReportableObservers(multiValueProvider);
  }
656971
public ProteusApplication addDefaultRoutes(RoutingHandler router)
    {

        if (config.hasPath("health.statusPath")) {
            try {
                final String statusPath = config.getString("health.statusPath");

                router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
                {
                    exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
                    exchange.getResponseSender().send("OK");
                });

                this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());

            } catch (Exception e) {
                log.error("Error adding health status route.", e.getMessage());
            }
        }

        if (config.hasPath("application.favicon")) {
            try {

                final ByteBuffer faviconImageBuffer;

                final File faviconFile = new File(config.getString("application.favicon"));

                if (!faviconFile.exists()) {
                    try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();

                        byte[] buffer = new byte[4096];
                        int read = 0;
                        while (read != -1) {
                            read = stream.read(buffer);
                            if (read > 0) {
                                baos.write(buffer, 0, read);
                            }
                        }

                        faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
                    }

                } else {
                    try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();

                        byte[] buffer = new byte[4096];
                        int read = 0;
                        while (read != -1) {
                            read = stream.read(buffer);
                            if (read > 0) {
                                baos.write(buffer, 0, read);
                            }
                        }

                        faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
                    }
                }

                router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) ->
                {
                    exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString());
                    exchange.getResponseSender().send(faviconImageBuffer);
                });

            } catch (Exception e) {
                log.error("Error adding favicon route.", e.getMessage());
            }
        }

        return this;
    }
662140
@Override
    public boolean addSync() throws ResourceException {

        if (tc.isEntryEnabled()) {
            Tr.entry(this, tc, "addSync");
        }

        try {

            UOWCoordinator uowCoord = mcWrapper.getUOWCoordinator();
            if (uowCoord != null) {
                if (uowCoord.isGlobal()) {
                    if (mcWrapper.isConnectionSynchronizationProvider()) {
                        throw new UnsupportedOperationException("com.ibm.ws.Transaction.SynchronizationProvider");
                        /*
                         * Use the Synchronization object from the managed connection to
                         * register.
                         */
                        //Synchronization s = ((SynchronizationProvider)mcWrapper.getManagedConnection()).getSynchronization();
                        //LocationSpecificFunction.instance.getTransactionManager().registerSynchronization(uowCoord, s, EmbeddableWebSphereTransactionManager.SYNC_TIER_INNER);
                    }
                    /*
                     * This code will remain here just in case we run into this
                     * case. We should not be isEnlistmentDisabled in this code.
                     *
                     * Log a message and return, if isEnlistmentDisabled is true.
                     */
                    if (mcWrapper.isEnlistmentDisabled()) {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(this, tc, "Managed connection isEnlistmentDisabled is true.");
                            Tr.debug(this, tc, "Returning without registering.");
                        }
                        if (tc.isEntryEnabled()) {
                            Tr.exit(this, tc, "addSync", false);
                        }
                        return false;
                    }
                    /*
                     * Use our XATransactionWrapper
                     */
                    // Global Transaction
                    EmbeddableWebSphereTransactionManager tranMgr = mcWrapper.pm.connectorSvc.transactionManager;
                    tranMgr.registerSynchronization(uowCoord, this);
                    mcWrapper.markLocalTransactionWrapperInUse();
                    registeredForSync = true;
                } else {
                    // Local Transaction
                    // No need to register for synchronization for unshared/LTC/res-control=Application.
                    //  Instead of cleanup being done via after completion it will either happen at close or
                    //  commit/rollback which ever happens last.  This will allow the connection to be returned
                    //  to the pool prior to the end of the LTC scope allowing better utilization of the connection.
                    boolean shareable = mcWrapper.getConnectionManager().shareable();
                    if (!shareable && !J2CUtilityClass.isContainerAtBoundary(mcWrapper.pm.connectorSvc.transactionManager)) {
                        // Register an instance of an RRS no-transaction wrapper
                        // so the TM will create an RRS NativeLocalTranasction.  The wrapper
                        // provides "empty" TransactioWrapper and Synchronization behaviors,
                        // but indicates to the TM that the LTC requires RRS support.

                        //if (tc.isEntryEnabled()) {
                        //  Tr.exit(this, tc, "addSync: returning without registering.");
                        //}
                        //return false;
                        if (this.isRRSTransactional()) {
                            ((SynchronizationRegistryUOWScope) uowCoord).registerInterposedSynchronization(
                                                                                                           new RRSNoTransactionWrapper());
                        } else {
                            if (tc.isEntryEnabled()) {
                                Tr.exit(this, tc, "addSync", "returning without registering");
                            }
                            return false;
                        }
                    } else {

                        if (mcWrapper.isConnectionSynchronizationProvider()) {
                            throw new UnsupportedOperationException("com.ibm.ws.Transaction.SynchronizationProvider");
                            /*
                             * Use the Synchronization object from the managed connection to
                             * register.
                             */
                            //Synchronization s = ((SynchronizationProvider)mcWrapper.getManagedConnection()).getSynchronization();
                            //((SynchronizationRegistryUOWScope) uowCoord).registerInterposedSynchronization(s);
                            //registeredForSync = false;
                        } else {

                            /*
                             * In order
                             * to take advantage of the new level of code in which MCWrapper has the isEnlistmentDisabled()
                             */
                            if (mcWrapper.isEnlistmentDisabled()) {
                                if (tc.isDebugEnabled()) {
                                    Tr.debug(this, tc, "Managed connection isEnlistmentDisabled is true.");
                                    Tr.debug(this, tc, "Returning without registering.");
                                }
                                if (tc.isEntryEnabled()) {
                                    Tr.exit(this, tc, "addSync", false);
                                }
                                return false;
                            }
                            ((SynchronizationRegistryUOWScope) uowCoord).registerInterposedSynchronization(this);
                            mcWrapper.markLocalTransactionWrapperInUse();
                            registeredForSync = true;
                        }

                    }
                }
            } else {
                // No transaction context.  Should never happen.
                Tr.error(tc, "NO_VALID_TRANSACTION_CONTEXT_J2CA0040", "addSync", null, mcWrapper.gConfigProps.cfName);
                throw new ResourceException("INTERNAL ERROR: No valid transaction context present");
            }

        } catch (ResourceException e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.LocalTransactionWrapper.addSync",
                                                        "594",
                                                        this);
            Tr.error(tc, "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026", "addSync", e, "Exception");
            throw e;
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.LocalTransactionWrapper.addSync",
                                                        "605",
                                                        this);
            Tr.error(tc, "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026", "addSync", e, "Exception");
            ResourceException re = new ResourceException("addSync: caught Exception");
            re.initCause(e);
            throw re;
        }
        if (tc.isEntryEnabled()) {
            Tr.exit(this, tc, "addSync", registeredForSync);
        }

        return registeredForSync;

    }
635564
static ECDSAKeyProvider providerForKeys(final ECPublicKey publicKey, final ECPrivateKey privateKey) {
        if (publicKey == null && privateKey == null) {
            throw new IllegalArgumentException("Both provided Keys cannot be null.");
        }
        return new ECDSAKeyProvider() {
            @Override
            public ECPublicKey getPublicKeyById(String keyId) {
                return publicKey;
            }

            @Override
            public ECPrivateKey getPrivateKey() {
                return privateKey;
            }

            @Override
            public String getPrivateKeyId() {
                return null;
            }
        };
    }
769781
static RSAKeyProvider providerForKeys(final RSAPublicKey publicKey, final RSAPrivateKey privateKey) {
        if (publicKey == null && privateKey == null) {
            throw new IllegalArgumentException("Both provided Keys cannot be null.");
        }
        return new RSAKeyProvider() {
            @Override
            public RSAPublicKey getPublicKeyById(String keyId) {
                return publicKey;
            }

            @Override
            public RSAPrivateKey getPrivateKey() {
                return privateKey;
            }

            @Override
            public String getPrivateKeyId() {
                return null;
            }
        };
    }
16631
@Autowired(required = false)
	public void setTemplateProviderElements(List<ITemplateProviderElement> providers) {
		this.elements = new ArrayList<ITemplateProviderElement>(providers);

		Collections.sort(this.elements, new Comparator<ITemplateProviderElement>() {
			@Override
			public int compare(ITemplateProviderElement e1, ITemplateProviderElement e2) {
				int o1 = e1.getOrder(), o2 = e2.getOrder();
				return ((o1 < o2)? -1 : ((o1 == o2)? 0 : 1));
			}
		});

		for(ITemplateProviderElement provider : elements) {
			if(coreLogger.isDebugEnabled()) coreLogger.debug(Logs.LOG_01,
					ansiString(GREEN, provider.getClass().getSimpleName()),
					ansiString(GREEN, provider.getOrder())
			);
		}
	}
1372070
@Override
  public MtasDataCollector<?, ?> add(String key, double valueSum, long valueN)
      throws IOException {
    if (key != null) {
      MtasDataCollector<?, ?> subCollector = add(key, false);
      setValue(newCurrentPosition, Double.valueOf(valueSum).longValue(), valueN,
          newCurrentExisting);
      return subCollector;
    } else {
      return null;
    }
  }
347698
public static base_response add(nitro_service client, cacheforwardproxy resource) throws Exception {
		cacheforwardproxy addresource = new cacheforwardproxy();
		addresource.ipaddress = resource.ipaddress;
		addresource.port = resource.port;
		return addresource.add_resource(client);
	}
1173191
@Override
    public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) {
        for (ExchangeRateProvider prov : this.providers) {
            try {
                if (prov.isAvailable(conversionQuery)) {
                    ExchangeRate rate = prov.getExchangeRate(conversionQuery);
                    if (rate!=null) {
                        return rate;
                    }
                }
            } catch (Exception e) {
                Logger.getLogger(getClass().getName()).log(Level.WARNING,
                        "Rate Provider did not return data though at check before data was flagged as available," +
                                " provider=" + prov.getContext().getProviderName() + ", query=" + conversionQuery);
            }
        }
        throw new CurrencyConversionException(conversionQuery.getBaseCurrency(), conversionQuery.getCurrency(), null,
                "All delegate prov iders failed to deliver rate, providers=" + this.providers +
                        ", query=" + conversionQuery);
    }
1135332
public void putPresenter(@NonNull String viewId,
      @NonNull MvpPresenter<? extends MvpView> presenter) {

    if (viewId == null) {
      throw new NullPointerException("ViewId is null");
    }

    if (presenter == null) {
      throw new NullPointerException("Presenter is null");
    }

    PresenterHolder presenterHolder = presenterMap.get(viewId);
    if (presenterHolder == null) {
      presenterHolder = new PresenterHolder();
      presenterHolder.presenter = presenter;
      presenterMap.put(viewId, presenterHolder);
    } else {
      presenterHolder.presenter = presenter;
    }
  }
642056
@Override
    public ExchangeRate getReversed(ExchangeRate rate) {
        if (rate.getContext().getProviderName().equals(CONTEXT.getProviderName())) {
            return new ExchangeRateBuilder(rate.getContext()).setTerm(rate.getBaseCurrency())
                    .setBase(rate.getCurrency()).setFactor(new DefaultNumberValue(BigDecimal.ONE)).build();
        }
        return null;
    }
519665
@Override
  public final void makeReport(final Map<String, Object> pReqVars,
    final SalesInvoice pInvoice, final IRequestData pRequestData,
      final OutputStream pOus) throws Exception {
    AccSettings accSet = this.srvAccSettings.lazyGetAccSettings(pReqVars);
    String lang = (String) pReqVars.get("lang");
    String langDef = (String) pReqVars.get("langDef");
    DateFormat dateFormat = DateFormat
      .getDateInstance(DateFormat.MEDIUM, new Locale(lang));
    SalesInvoice inv = retrieveEntity(pReqVars, pInvoice, lang,
      !lang.equals(langDef));
    boolean isInvoiceBasis = false;
    for (SalesInvoiceTaxLine itl : inv.getTaxesLines()) {
      if (itl.getTaxableInvBas().compareTo(BigDecimal.ZERO) == 1) {
        isInvoiceBasis = true;
        break;
      }
    }
    Currency currency;
    if (inv.getForeignCurrency() != null) {
      currency = inv.getForeignCurrency();
    } else {
      currency = accSet.getCurrency();
    }
    String priceName;
    if (inv.getPriceIncTax()) {
      priceName = "priceIncTax";
    } else {
      priceName = "itsPrice";
    }
    I18nCurrency i18nCurrency = null;
    String curSign;
    boolean isPrnCurLf;
    if (!lang.equals(langDef)) {
      List<I18nCurrency> i18nCurrencyLst = this.srvOrm.retrieveList(
        pReqVars, I18nCurrency.class);
      for (I18nCurrency i18nCur : i18nCurrencyLst) {
        if (i18nCur.getHasName().getItsId().equals(currency.getItsId())
          && i18nCur.getLang().getItsId().equals(lang)) {
          i18nCurrency = i18nCur;
          break;
        }
      }
    }
    if (i18nCurrency != null) {
      isPrnCurLf = i18nCurrency.getPrintCurrencyLeft();
      if (i18nCurrency.getUseCurrencySign()) {
        curSign = i18nCurrency.getHasName().getItsSign();
      } else {
        curSign = " " + i18nCurrency.getItsName() + " ";
      }
    } else {
      isPrnCurLf = accSet.getPrintCurrencyLeft();
      if (accSet.getUseCurrencySign()) {
        curSign = currency.getItsSign();
      } else {
        curSign = " " + currency.getItsName() + " ";
      }
    }
    Document<WI> doc = this.pdfFactory.lazyGetFctDocument()
      .createDoc(accSet.getPageSize(), accSet.getPageOrientation());
    doc.setFontSize(accSet.getFontSize());
    doc.getPages().get(0).setMarginBottom(accSet.getMarginBottom());
    doc.getPages().get(0).setMarginTop(accSet.getMarginTop());
    doc.getPages().get(0).setMarginLeft(accSet.getMarginLeft());
    doc.getPages().get(0).setMarginRight(accSet.getMarginRight());
    PdfDocument<WI> docPdf = this.pdfFactory.createPdfDoc(doc);
    IDocumentMaker<WI> docMaker = this.pdfFactory.lazyGetDocumentMaker();
    docPdf.getPdfInfo().setAuthor("Beigesoft (TM) Accounting, "
      + accSet.getOrganization());
    IPdfMaker<WI> pdfMaker = this.pdfFactory.lazyGetPdfMaker();
    if (accSet.getTtfBoldFileName() != null) {
      pdfMaker.addFontTtf(docPdf, accSet.getTtfBoldFileName());
    }
    pdfMaker.addFontTtf(docPdf, accSet.getTtfFileName());
    double widthNdot = this.pdfFactory.lazyGetUomHelper()
      .fromPoints(2.0, 300.0, doc.getUnitOfMeasure()); //printer resolution
    doc.setBorder(widthNdot);
    doc.setContentPadding(0.0);
    doc.setContentPaddingBottom(mmToDocUom(1.0, doc.getUnitOfMeasure()));
    DocTable<WI> tblOwner = docMaker.addDocTableNoBorder(doc, 1, 1);
    I18nAccounting i18nAccounting =
      (I18nAccounting) pReqVars.get("i18nAccounting");
    if (i18nAccounting != null) {
      tblOwner.getItsCells().get(0)
        .setItsContent(i18nAccounting.getOrganizationName());
    } else {
      tblOwner.getItsCells().get(0).setItsContent(accSet.getOrganization());
    }
    int n = 0;
    if (accSet.getTaxIdentificationNumber() != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("taxIdentificationNumber", lang) + ": "
          + accSet.getTaxIdentificationNumber());
    }
    if (accSet.getRegZip() != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regZip", lang) + ": " + accSet.getRegZip());
    }
    String addr = null;
    if (i18nAccounting != null) {
      addr = i18nAccounting.getRegAddress1();
    } else {
      addr = accSet.getRegAddress1();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regAddress1", lang) + ": " + addr);
    }
    if (i18nAccounting != null) {
      addr = i18nAccounting.getRegAddress2();
    } else {
      addr = accSet.getRegAddress2();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regAddress2", lang) + ": " + addr);
    }
    if (i18nAccounting != null) {
      addr = i18nAccounting.getRegCity();
    } else {
      addr = accSet.getRegCity();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regCity", lang) + ": " + addr);
    }
    if (i18nAccounting != null) {
      addr = i18nAccounting.getRegState();
    } else {
      addr = accSet.getRegState();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regState", lang) + ": " + addr);
    }
    if (i18nAccounting != null) {
      addr = i18nAccounting.getRegCountry();
    } else {
      addr = accSet.getRegCountry();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblOwner);
      tblOwner.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regCountry", lang) + ": " + addr);
    }
    tblOwner.getItsCells().get(0).setFontNumber(1);
    docMaker.makeDocTableWrapping(tblOwner);
    tblOwner.setAlignHorizontal(EAlignHorizontal.RIGHT);
    DocTable<WI> tblTitle = docMaker.addDocTableNoBorder(doc, 1, 1);
    String invNum;
    if (inv.getIdBirth() != null) {
      invNum = inv.getIdDatabaseBirth().toString() + "-"
        + inv.getIdBirth();
    } else {
      invNum = inv.getIdDatabaseBirth().toString() + "-"
        + inv.getItsId();
    }
    String title = this.srvI18n.getMsg("Invoice", lang) + " #" + invNum + ", "
      + this.srvI18n.getMsg("date", lang) + ": "
        + dateFormat.format(inv.getItsDate());
    tblTitle.getItsCells().get(0).setItsContent(title);
    tblTitle.getItsCells().get(0).setFontNumber(1);
    tblTitle.setAlignHorizontal(EAlignHorizontal.CENTER);
    doc.setContainerMarginBottom(mmToDocUom(1.0, doc.getUnitOfMeasure()));
    docMaker.makeDocTableWrapping(tblTitle);
    DocTable<WI> tblCustomer = docMaker.addDocTableNoBorder(doc, 1, 1);
    I18nBuyer i18nBuyer = null;
    if (!lang.equals(langDef)) {
      i18nBuyer = getSrvOrm().retrieveEntityById(pReqVars,
        I18nBuyer.class, inv.getCustomer());
    }
    if (i18nBuyer != null) {
      tblCustomer.getItsCells().get(0)
        .setItsContent(i18nBuyer.getItsName());
    } else {
      tblCustomer.getItsCells().get(0)
        .setItsContent(inv.getCustomer().getItsName());
    }
    n = 0;
    if (inv.getCustomer().getTaxIdentificationNumber() != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("taxIdentificationNumber", lang) + ": "
          + inv.getCustomer().getTaxIdentificationNumber());
    }
    if (inv.getCustomer().getRegZip() != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regZip", lang) + ": " + inv.getCustomer().getRegZip());
    }
    if (i18nBuyer != null) {
      addr = i18nBuyer.getRegAddress1();
    } else {
      addr = inv.getCustomer().getRegAddress1();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regAddress1", lang) + ": " + addr);
    }
    if (i18nBuyer != null) {
      addr = i18nBuyer.getRegAddress2();
    } else {
      addr = inv.getCustomer().getRegAddress2();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regAddress2", lang) + ": " + addr);
    }
    if (i18nBuyer != null) {
      addr = i18nBuyer.getRegCity();
    } else {
      addr = inv.getCustomer().getRegCity();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regCity", lang) + ": " + addr);
    }
    if (i18nBuyer != null) {
      addr = i18nBuyer.getRegState();
    } else {
      addr = inv.getCustomer().getRegState();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regState", lang) + ": " + addr);
    }
    if (i18nBuyer != null) {
      addr = i18nBuyer.getRegCountry();
    } else {
      addr = inv.getCustomer().getRegCountry();
    }
    if (addr != null) {
      docMaker.addRowToDocTable(tblCustomer);
      tblCustomer.getItsCells().get(++n).setItsContent(this.srvI18n
        .getMsg("regCountry", lang) + ": " + addr);
    }
    tblCustomer.getItsCells().get(0).setFontNumber(1);
    BigDecimal price;
    BigDecimal subtotal;
    BigDecimal totalTaxes;
    BigDecimal total;
    if (inv.getItsLines() != null && inv.getItsLines().size() > 0) {
      doc.setContainerMarginBottom(mmToDocUom(2.0, doc.getUnitOfMeasure()));
      DocTable<WI> tblTiGoods = docMaker.addDocTableNoBorder(doc, 1, 1);
      tblTiGoods.getItsCells().get(0).setItsContent(this.srvI18n
        .getMsg(SalesInvoiceLine.class.getSimpleName() + "s", lang));
      tblTiGoods.getItsCells().get(0).setFontNumber(1);
      tblTiGoods.setAlignHorizontal(EAlignHorizontal.CENTER);
      docMaker.makeDocTableWrapping(tblTiGoods);
      doc.setContentPadding(mmToDocUom(1.0, doc.getUnitOfMeasure()));
      doc.setContentPaddingBottom(mmToDocUom(1.5, doc.getUnitOfMeasure()));
      int rowc;
      if (isInvoiceBasis) {
        rowc = 6;
      } else if (inv.getPriceIncTax()) {
        rowc = 7;
      } else {
        rowc = 8;
      }
      DocTable<WI> tblGoods = docMaker
        .addDocTable(doc, rowc, inv.getItsLines().size() + 1);
      tblGoods.setIsRepeatHead(true);
      tblGoods.getItsRows().get(0).setIsHead(true);
      tblGoods.getItsCells().get(0).setItsContent(this.srvI18n
        .getMsg("invItem", lang).replace(" ", "\n"));
      tblGoods.getItsColumns().get(0).setIsWidthFixed(true);
      tblGoods.getItsColumns().get(0).setWidthInPercentage(60.0);
      tblGoods.getItsCells().get(1).setItsContent(this.srvI18n
        .getMsg("unitOfMeasure", lang).replace(" ", "\n"));
      tblGoods.getItsColumns().get(1).setWraping(EWraping.WRAP_CONTENT);
      tblGoods.getItsCells().get(2).setItsContent(this.srvI18n
        .getMsg(priceName, lang).replace(" ", "\n"));
      tblGoods.getItsColumns().get(2).setWraping(EWraping.WRAP_CONTENT);
      tblGoods.getItsCells().get(3).setItsContent(this.srvI18n
        .getMsg("itsQuantity", lang).replace(" ", "\n"));
      tblGoods.getItsColumns().get(3).setWraping(EWraping.WRAP_CONTENT);
      int pos = 3;
      if (!inv.getPriceIncTax()) {
        pos++;
        tblGoods.getItsCells().get(pos).setItsContent(this.srvI18n
        .getMsg("subtotal", lang).replace(" ", "\n"));
        tblGoods.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
      } else if (isInvoiceBasis && inv.getPriceIncTax()) {
        pos++;
        tblGoods.getItsCells().get(pos).setItsContent(this.srvI18n
        .getMsg("itsTotal", lang).replace(" ", "\n"));
        tblGoods.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
      }
      pos++;
      tblGoods.getItsCells().get(pos)
        .setItsContent(this.srvI18n.getMsg("taxesDescription", lang));
      if (!isInvoiceBasis) {
        pos++;
        tblGoods.getItsCells().get(pos).setItsContent(this.srvI18n
          .getMsg("totalTaxes", lang).replace(" ", "\n"));
        tblGoods.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
        pos++;
        tblGoods.getItsCells().get(pos).setItsContent(this.srvI18n
          .getMsg("itsTotal", lang).replace(" ", "\n"));
        tblGoods.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
      }
      for (int i = 0; i < rowc; i++) {
        tblGoods.getItsCells().get(i).setFontNumber(1);
        tblGoods.getItsCells().get(i)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
      }
      int j = 1;
      for (SalesInvoiceLine ln : inv.getItsLines()) {
        if (inv.getForeignCurrency() != null) {
          price = ln.getForeignPrice();
          subtotal = ln.getForeignSubtotal();
          totalTaxes = ln.getForeignTotalTaxes();
          total = ln.getForeignTotal();
        } else {
          price = ln.getItsPrice();
          subtotal = ln.getSubtotal();
          totalTaxes = ln.getTotalTaxes();
          total = ln.getItsTotal();
        }
        int i = 0;
        int k = j * rowc + i++;
        tblGoods.getItsCells().get(k)
          .setItsContent(ln.getInvItem().getItsName());
        k = j * rowc + i++;
        tblGoods.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
        tblGoods.getItsCells().get(k)
          .setItsContent(ln.getUnitOfMeasure().getItsName());
        k = j * rowc + i++;
        tblGoods.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.RIGHT);
        tblGoods.getItsCells().get(k)
          .setItsContent(prn(pReqVars, price));
        k = j * rowc + i++;
        tblGoods.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.RIGHT);
        tblGoods.getItsCells().get(k)
          .setItsContent(prn(pReqVars, ln.getItsQuantity()));
        if (!inv.getPriceIncTax()) {
          k = j * rowc + i++;
          tblGoods.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblGoods.getItsCells().get(k)
            .setItsContent(prn(pReqVars, subtotal));
        } else if (isInvoiceBasis && inv.getPriceIncTax()) {
          k = j * rowc + i++;
          tblGoods.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblGoods.getItsCells().get(k)
            .setItsContent(prn(pReqVars, total));
        }
        k = j * rowc + i++;
        tblGoods.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
        tblGoods.getItsCells().get(k)
          .setItsContent(ln.getTaxesDescription());
        if (!isInvoiceBasis) {
          k = j * rowc + i++;
          tblGoods.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblGoods.getItsCells().get(k)
            .setItsContent(prn(pReqVars, totalTaxes));
          k = j * rowc + i++;
          tblGoods.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblGoods.getItsCells().get(k)
            .setItsContent(prn(pReqVars, total));
        }
        j++;
      }
    }
    if (inv.getServices() != null && inv.getServices().size() > 0) {
      doc.setContainerMarginBottom(mmToDocUom(2.0, doc.getUnitOfMeasure()));
      DocTable<WI> tblTiServices = docMaker.addDocTableNoBorder(doc, 1, 1);
      tblTiServices.getItsCells().get(0).setItsContent(this.srvI18n
        .getMsg(SalesInvoiceServiceLine.class.getSimpleName() + "s", lang));
      tblTiServices.getItsCells().get(0).setFontNumber(1);
      tblTiServices.setAlignHorizontal(EAlignHorizontal.CENTER);
      docMaker.makeDocTableWrapping(tblTiServices);
      doc.setContentPadding(mmToDocUom(1.0, doc.getUnitOfMeasure()));
      doc.setContentPaddingBottom(mmToDocUom(1.5, doc.getUnitOfMeasure()));
      int rowc;
      double wd15;
      if (isInvoiceBasis) {
        rowc = 6;
        wd15 = 30.0d;
      } else if (inv.getPriceIncTax()) {
        rowc = 7;
        wd15 = 15.0d;
      } else {
        rowc = 8;
        wd15 = 15.0d;
      }
      DocTable<WI> tblServices = docMaker
        .addDocTable(doc, rowc, inv.getServices().size() + 1);
      tblServices.setIsRepeatHead(true);
      tblServices.getItsRows().get(0).setIsHead(true);
      tblServices.getItsCells().get(0)
        .setItsContent(this.srvI18n.getMsg("service", lang));
      tblServices.getItsColumns().get(0).setIsWidthFixed(true);
      tblServices.getItsColumns().get(0).setWidthInPercentage(35.0);
      tblServices.getItsCells().get(1).setItsContent(this.srvI18n
        .getMsg("unitOfMeasure", lang).replace(" ", "\n"));
      tblServices.getItsColumns().get(1).setWraping(EWraping.WRAP_CONTENT);
      tblServices.getItsCells().get(2)
        .setItsContent(this.srvI18n.getMsg(priceName, lang).replace(" ", "\n"));
      tblServices.getItsColumns().get(2).setIsWidthFixed(true);
      tblServices.getItsColumns().get(2).setWidthInPercentage(wd15);
      tblServices.getItsCells().get(3).setItsContent(this.srvI18n
        .getMsg("itsQuantity", lang).replace(" ", "\n"));
      tblServices.getItsColumns().get(3).setWraping(EWraping.WRAP_CONTENT);
      int pos = 3;
      if (!inv.getPriceIncTax()) {
        pos++;
        tblServices.getItsCells().get(pos).setItsContent(this.srvI18n
          .getMsg("subtotal", lang).replace(" ", "\n"));
        tblServices.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
      } else if (isInvoiceBasis && inv.getPriceIncTax()) {
        pos++;
        tblServices.getItsCells().get(pos).setItsContent(this.srvI18n
          .getMsg("itsTotal", lang).replace(" ", "\n"));
        tblServices.getItsColumns().get(pos).setWraping(EWraping.WRAP_CONTENT);
      }
      pos++;
      tblServices.getItsCells().get(pos)
        .setItsContent(this.srvI18n.getMsg("taxesDescription", lang));
      if (!isInvoiceBasis) {
        tblServices.getItsColumns().get(pos).setIsWidthFixed(true);
        tblServices.getItsColumns().get(pos).setWidthInPercentage(20.0);
        pos++;
        tblServices.getItsCells().get(pos)
          .setItsContent(this.srvI18n.getMsg("totalTaxes", lang));
        tblServices.getItsColumns().get(pos).setIsWidthFixed(true);
        tblServices.getItsColumns().get(pos).setWidthInPercentage(wd15);
        pos++;
        tblServices.getItsCells().get(pos)
          .setItsContent(this.srvI18n.getMsg("itsTotal", lang));
        tblServices.getItsColumns().get(pos).setIsWidthFixed(true);
        tblServices.getItsColumns().get(pos).setWidthInPercentage(wd15);
      }
      for (int i = 0; i < rowc; i++) {
        tblServices.getItsCells().get(i).setFontNumber(1);
        tblServices.getItsCells().get(i)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
      }
      int j = 1;
      for (SalesInvoiceServiceLine ln : inv.getServices()) {
        if (inv.getForeignCurrency() != null) {
          price = ln.getForeignPrice();
          subtotal = ln.getForeignSubtotal();
          totalTaxes = ln.getForeignTotalTaxes();
          total = ln.getForeignTotal();
        } else {
          price = ln.getItsPrice();
          subtotal = ln.getSubtotal();
          totalTaxes = ln.getTotalTaxes();
          total = ln.getItsTotal();
        }
        int i = 0;
        int k = j * rowc + i++;
        tblServices.getItsCells().get(k)
          .setItsContent(ln.getService().getItsName());
        k = j * rowc + i++;
        tblServices.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
        tblServices.getItsCells().get(k)
          .setItsContent(ln.getUnitOfMeasure().getItsName());
        k = j * rowc + i++;
        tblServices.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.RIGHT);
        tblServices.getItsCells().get(k)
          .setItsContent(prn(pReqVars, price));
        k = j * rowc + i++;
        tblServices.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.RIGHT);
        tblServices.getItsCells().get(k)
          .setItsContent(prn(pReqVars, ln.getItsQuantity()));
        if (!inv.getPriceIncTax()) {
          k = j * rowc + i++;
          tblServices.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblServices.getItsCells().get(k)
            .setItsContent(prn(pReqVars, subtotal));
        } else if (isInvoiceBasis && inv.getPriceIncTax()) {
          k = j * rowc + i++;
          tblServices.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblServices.getItsCells().get(k)
            .setItsContent(prn(pReqVars, total));
        }
        k = j * rowc + i++;
        tblServices.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
        tblServices.getItsCells().get(k)
          .setItsContent(ln.getTaxesDescription());
        if (!isInvoiceBasis) {
          k = j * rowc + i++;
          tblServices.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblServices.getItsCells().get(k)
            .setItsContent(prn(pReqVars, totalTaxes));
          k = j * rowc + i++;
          tblServices.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblServices.getItsCells().get(k)
            .setItsContent(prn(pReqVars, total));
        }
        j++;
      }
    }
    if (inv.getTaxesLines() != null && inv.getTaxesLines().size() > 0) {
      doc.setContainerMarginBottom(mmToDocUom(2.0, doc.getUnitOfMeasure()));
      DocTable<WI> tblTiTaxes = docMaker.addDocTableNoBorder(doc, 1, 1);
      tblTiTaxes.setIsRepeatHead(true);
      tblTiTaxes.getItsRows().get(0).setIsHead(true);
      tblTiTaxes.getItsCells().get(0).setItsContent(this.srvI18n
        .getMsg(SalesInvoiceTaxLine.class.getSimpleName() + "s", lang));
      tblTiTaxes.getItsCells().get(0).setFontNumber(1);
      tblTiTaxes.setAlignHorizontal(EAlignHorizontal.CENTER);
      docMaker.makeDocTableWrapping(tblTiTaxes);
      doc.setContentPadding(mmToDocUom(1.0, doc.getUnitOfMeasure()));
      doc.setContentPaddingBottom(mmToDocUom(1.5, doc.getUnitOfMeasure()));
      int rowc;
      double rowtw;
      if (isInvoiceBasis) {
        rowc = 3;
        rowtw = 40.0d;
      } else {
        rowc = 2;
        rowtw = 70.0d;
      }
      DocTable<WI> tblTaxes = docMaker
        .addDocTable(doc, rowc, inv.getTaxesLines().size() + 1);
      tblTaxes.getItsCells().get(0)
        .setItsContent(this.srvI18n.getMsg("tax", lang));
      tblTaxes.getItsColumns().get(0).setIsWidthFixed(true);
      tblTaxes.getItsColumns().get(0).setWidthInPercentage(rowtw);
      if (isInvoiceBasis) {
        tblTaxes.getItsCells().get(1)
          .setItsContent(this.srvI18n.getMsg("taxable", lang));
      }
      tblTaxes.getItsCells().get(rowc - 1)
        .setItsContent(this.srvI18n.getMsg("itsTotal", lang));
      for (int i = 0; i < rowc; i++) {
        tblTaxes.getItsCells().get(i).setFontNumber(1);
        tblTaxes.getItsCells().get(i)
          .setAlignHorizontal(EAlignHorizontal.CENTER);
      }
      BigDecimal taxable;
      int j = 1;
      for (SalesInvoiceTaxLine ln : inv.getTaxesLines()) {
        if (inv.getForeignCurrency() != null) {
          taxable = ln.getTaxableInvBasFc();
          total = ln.getForeignTotalTaxes();
        } else {
          taxable = ln.getTaxableInvBas();
          total = ln.getItsTotal();
        }
        int i = 0;
        tblTaxes.getItsCells().get(j * rowc + i++)
          .setItsContent(ln.getTax().getItsName());
        int k = j * rowc + i++;
        if (isInvoiceBasis) {
          tblTaxes.getItsCells().get(k)
            .setAlignHorizontal(EAlignHorizontal.RIGHT);
          tblTaxes.getItsCells().get(k)
            .setItsContent(prn(pReqVars, taxable));
          k = j * rowc + i++;
        }
        tblTaxes.getItsCells().get(k)
          .setAlignHorizontal(EAlignHorizontal.RIGHT);
        tblTaxes.getItsCells().get(k)
          .setItsContent(prn(pReqVars, total));
        j++;
      }
    }
    doc.setAlignHoriCont(EAlignHorizontal.RIGHT);
    DocTable<WI> tblRez = docMaker.addDocTableNoBorder(doc, 2, 3);
    tblRez.getItsCells().get(0).setFontNumber(1);
    tblRez.getItsCells().get(0).setItsContent(this.srvI18n.getMsg("subtotal",
      lang) + ": ");
    tblRez.getItsCells().get(1).setFontNumber(1);
    String cnt;
    if (inv.getForeignCurrency() != null) {
      subtotal = inv.getForeignSubtotal();
      totalTaxes = inv.getForeignTotalTaxes();
      total = inv.getForeignTotal();
    } else {
      subtotal = inv.getSubtotal();
      totalTaxes = inv.getTotalTaxes();
      total = inv.getItsTotal();
    }
    if (isPrnCurLf) {
      cnt = curSign + prn(pReqVars, subtotal);
    } else {
      cnt = prn(pReqVars, subtotal) + curSign;
    }
    tblRez.getItsCells().get(1).setItsContent(cnt);
    tblRez.getItsCells().get(2).setFontNumber(1);
    tblRez.getItsCells().get(2).setItsContent(this.srvI18n.getMsg("totalTaxes",
      lang) + ": ");
    tblRez.getItsCells().get(3).setFontNumber(1);
    if (isPrnCurLf) {
      cnt = curSign + prn(pReqVars, totalTaxes);
    } else {
      cnt = prn(pReqVars, totalTaxes) + curSign;
    }
    tblRez.getItsCells().get(3).setItsContent(cnt);
    tblRez.getItsCells().get(4).setFontNumber(1);
    tblRez.getItsCells().get(4).setItsContent(this.srvI18n.getMsg("itsTotal",
      lang) + ": ");
    tblRez.getItsCells().get(5).setFontNumber(1);
    if (isPrnCurLf) {
      cnt = curSign + prn(pReqVars, total);
    } else {
      cnt = prn(pReqVars, total) + curSign;
    }
    tblRez.getItsCells().get(5).setItsContent(cnt);
    tblRez.setAlignHorizontal(EAlignHorizontal.RIGHT);
    docMaker.makeDocTableWrapping(tblRez);
    docMaker.addPagination(doc);
    docMaker.deriveElements(doc);
    pdfMaker.prepareBeforeWrite(docPdf);
    try {
      this.pdfFactory.lazyGetPdfWriter().write(null, docPdf, pOus);
    } finally {
      pOus.close();
    }
  }