//////////////////////////////////////////////////////////////////////////////  Private  
read my address from database

@param pfnCallback
@private
186220
function _readMyAddress( pfnCallback )
{
	_db.query
	(
		"SELECT address FROM my_addresses",
		[],
		arrRows =>
		{
			if ( 0 === arrRows.length )
			{
				return pfnCallback( "no addresses" );
			}
			if ( arrRows.length > 1 )
			{
				return pfnCallback( "more than 1 address" );
			}

			//	...
			pfnCallback( null, arrRows[ 0 ].address );
		}
	);
}
253886
protected void doSetFrom(String from, String personal) {
        assertArgumentNotEmpty("from", from);
        assertArgumentNotEmpty("personal", personal); // only from required
        postcard.setFrom(createAddress(from, personal));
    }
1256189
static InetAddress getNIFirstAddress(int niIndex) throws SocketException {
        if (niIndex > 0) {
            NetworkInterface networkInterface = NetworkInterface.getByIndex(niIndex);
            Enumeration<InetAddress> addressesEnum = networkInterface.getInetAddresses();
            if (addressesEnum.hasMoreElements()) {
                return addressesEnum.nextElement();
            }
        }
        return InetAddress.anyLocalAddress();
    }
365968
public static String toAddressString(InetSocketAddress address) {
        if (address == null) {
            return StringUtils.EMPTY;
        } else {
            return toIpString(address) + ":" + address.getPort();
        }
    }
1356284
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:magicnumber"})
	private DBaseFileRecord readDBFRecord(int recordNumber) throws IOException {
		if (this.finished) {
			throw new EOFDBaseFileException();
		}
		if (this.fields == null) {
			throw new MustCallReadHeaderFunctionException();
		}

		//
		//-----------------------------------------------------------
		// Bytes       Size   Content
		//-----------------------------------------------------------
		//     0    1 byte    deleted flag:
		//                    '*' (star) if deleted
		//                    ' ' (space) if not deleted
		//  1..m    n bytes   contents of fields, for n see
		//                    the bytes 10..11 of the dBASE header

		// Compute the offset
		final long offset = this.readingPosition * this.recordSize + this.firstRecordOffset;

		// Read the record
		final byte[] rawData = new byte[this.recordSize];
		this.stream.readFully(rawData);

		// Read the deleted flag
		final int deletedFlag = rawData[0] & 0xFF;
		if (deletedFlag == 0x1A) {
			// END-OF-FILE character
			throw new EOFException();
		}
		if (deletedFlag != '*' && deletedFlag != ' ') {
			throw new InvalidDeletionFlagFormatException(recordNumber, deletedFlag);
		}
		if (deletedFlag == '*') {
			return null;
		}

		int rawOffset = 1;

		final DBaseFileRecord record = new DBaseFileRecord(recordNumber, offset);
		for (int i = 0; i < this.fieldCount; ++i) {

			final DBaseFileField field = this.fields.get(i);
			if (field != null) {

				Object value = null;

				// Read the content of the record
				switch (field.getType()) {
				//
				// Read a list of characters
				case STRING:
					final OutputParameter<String> strvalue = new OutputParameter<>();
					rawOffset += readStringRecordValue(
							field,
							recordNumber, i + 1,
							rawData, rawOffset,
							strvalue);
					value = strvalue.get();
					break;
				//
				// Read a date
				case DATE:
					final OutputParameter<Date> datevalue = new OutputParameter<>();
					rawOffset += readDateRecordValue(field, recordNumber, i + 1, rawData, rawOffset, datevalue);
					value = datevalue.get();
					break;
				//
				// Read a number
				case NUMBER:
				case FLOATING_NUMBER:
					final OutputParameter<Double> dblvalue = new OutputParameter<>();
					rawOffset += readNumberRecordValue(field, recordNumber, i + 1, rawData, rawOffset, dblvalue);
					value = dblvalue.get();
					break;
				//
				// Read a boolean
				case BOOLEAN:
					final OutputParameter<Boolean> boolvalue = new OutputParameter<>();
					rawOffset += readBooleanRecordValue(field, recordNumber, i + 1, rawData, rawOffset, boolvalue);
					value = boolvalue.get();
					break;
				//
				// Read a 2 byte integer
				case INTEGER_2BYTES:
					final OutputParameter<Integer> intvalue = new OutputParameter<>();
					rawOffset += read2ByteIntegerRecordValue(field, recordNumber, i + 1, rawData, rawOffset, intvalue);
					value = intvalue.get();
					break;
				//
				// Read a 4 byte integer
				case INTEGER_4BYTES:
					final OutputParameter<Long> longvalue = new OutputParameter<>();
					rawOffset += read4ByteIntegerRecordValue(field, recordNumber, i + 1, rawData, rawOffset, longvalue);
					value = longvalue.get();
					break;
				//
				// Read a 8 byte double
				case DOUBLE:
					final OutputParameter<Double> dblvalue2 = new OutputParameter<>();
					rawOffset += read8ByteDoubleRecordValue(field, recordNumber, i + 1, rawData, rawOffset, dblvalue2);
					value = dblvalue2.get();
					break;
					//$CASES-OMITTED$
				default:
				}

				if (value != null) {
					record.add(value);
				} else {
					record.add(null);
				}
			}

		}

		return record;
	}
476548
@Override
  public synchronized P readPage(int pageID) {
    countRead();
    P page = map.get(pageID);
    if(page != null) {
      if(LOG.isDebuggingFine()) {
        LOG.debugFine("Read from cache: " + pageID);
      }
    }
    else {
      if(LOG.isDebuggingFine()) {
        LOG.debugFine("Read from backing: " + pageID);
      }
      page = file.readPage(pageID);
      map.put(pageID, page);
    }
    return page;
  }
51902
@Override
  public final IEntityProcessor lazyGet(final Map<String, Object> pAddParam, final String pBeanName) throws Exception {
    IEntityProcessor proc = this.processorsMap.get(pBeanName);
    if (proc == null) {
      // locking:
      synchronized (this.processorsMap) {
        // make sure again whether it's null after locking:
        proc = this.processorsMap.get(pBeanName);
        if (proc == null) {
          if (pBeanName.equals(PrcAdvisedGoodsForGoodsSave.class.getSimpleName())) {
            proc = lazyGetPrcAdvisedGoodsForGoodsSave(pAddParam);
          } else if (pBeanName.equals(PrcSettingsAddSave.class.getSimpleName())) {
            proc = lazyGetPrcSettingsAddSave(pAddParam);
          } else if (pBeanName.equals(PrcTradingSettingsSave.class.getSimpleName())) {
            proc = lazyGetPrcTradingSettingsSave(pAddParam);
          } else if (pBeanName.equals(PrcItemCatalogSave.class.getSimpleName())) {
            proc = lazyGetPrcItemCatalogSave(pAddParam);
          } else if (pBeanName.equals(PrcSubcatalogsCatalogsGsSave.class.getSimpleName())) {
            proc = lazyGetPrcSubcatalogsCatalogsGsSave(pAddParam);
          } else if (pBeanName.equals(PrcSeSellerDel.class.getSimpleName())) {
            proc = lazyGetPrcSeSellerDel(pAddParam);
          } else if (pBeanName.equals(PrcSeSellerSave.class.getSimpleName())) {
            proc = lazyGetPrcSeSellerSave(pAddParam);
          } else if (pBeanName.equals(PrCuOrSv.class.getSimpleName())) {
            proc = lazyGetPrCuOrSv(pAddParam);
          } else if (pBeanName.equals(PrcGoodsAdviseCategoriesSave.class.getSimpleName())) {
            proc = lazyGetPrcGoodsAdviseCategoriesSave(pAddParam);
          } else if (pBeanName.equals(PrcItemSpecificsRetrieve.class.getSimpleName())) {
            proc = lazyGetPrcItemSpecificsRetrieve(pAddParam);
          } else if (pBeanName.equals(PrcItemSpecificsSave.class.getSimpleName())) {
            proc = lazyGetPrcItemSpecificsSave(pAddParam);
          } else if (pBeanName.equals(PrcItSpecEmbFlSave.class.getSimpleName())) {
            proc = lazyGetPrcItSpecEmbFlSave(pAddParam);
          } else if (pBeanName.equals(PrcItSpecEmbFlDel.class.getSimpleName())) {
            proc = lazyGetPrcItSpecEmbFlDel(pAddParam);
          } else {
            proc = this.fctBnEntitiesProcessors.lazyGet(pAddParam, pBeanName);
          }
        }
      }
    }
    if (proc == null) {
      this.logger.info(null, FctBnTradeEntitiesProcessors.class, pBeanName + " not found!");
    }
    return proc;
  }
226899
void readToData(boolean returnOnYield)
        throws IOException
    {
        InputStream is = getInputStream();

        if (is == null)
            return;

        for (int tag = is.read(); tag >= 0; tag = is.read()) {
            switch (tag) {
                case 'Y':
                    server.freeReadLock();
                    if (returnOnYield)
                        return;
                    server.readChannel(channel);
                    break;

                case 'Q':
                    server.freeReadLock();
                    this.is = null;
                    this.server = null;
                    return;

                case 'U':
                    this.url = readUTF();
                    break;

                case 'D':
                    chunkLength = (is.read() << 8) + is.read();
                    return;

                default:
                    readTag(tag);
                    break;
            }
        }
    }
901957
@Override
  public final IEntityProcessor lazyGet(
    final Map<String, Object> pAddParam,
      final String pBeanName) throws Exception {
    IEntityProcessor proc =
      this.processorsMap.get(pBeanName);
    if (proc == null) {
      // locking:
      synchronized (this.processorsMap) {
        // make sure again whether it's null after locking:
        proc = this.processorsMap.get(pBeanName);
        if (proc == null) {
          if (pBeanName
            .equals(PrcEntityRetrieve.class.getSimpleName())) {
            proc = createPutPrcEntityRetrieve();
          } else if (pBeanName
            .equals(PrcMatchForeignLineCreate.class.getSimpleName())) {
            proc = createPutPrcMatchForeignLineCreate();
          } else if (pBeanName
            .equals(PrcCsvColumnCreate.class.getSimpleName())) {
            proc = createPutPrcCsvColumnCreate();
          } else if (pBeanName
            .equals(PrcEntityCreate.class.getSimpleName())) {
            proc = createPutPrcEntityCreate();
          } else if (pBeanName
            .equals(PrcEntityDelete.class.getSimpleName())) {
            proc = createPutPrcEntityDelete();
          } else if (pBeanName
            .equals(PrcEntityPbDelete.class.getSimpleName())) {
            proc = createPutPrcEntityPbDelete();
          } else if (pBeanName
            .equals(PrcEntityFDelete.class.getSimpleName())) {
            proc = createPutPrcEntityFDelete();
          } else if (pBeanName
            .equals(PrcEntityFSave.class.getSimpleName())) {
            proc = createPutPrcEntityFSave();
          } else if (pBeanName
            .equals(PrcEntityFfolDelete.class.getSimpleName())) {
            proc = createPutPrcEntityFfolDelete();
          } else if (pBeanName
            .equals(PrcEntityFfolSave.class.getSimpleName())) {
            proc = createPutPrcEntityFfolSave();
          } else if (pBeanName
            .equals(PrcEntityFolDelete.class.getSimpleName())) {
            proc = createPutPrcEntityFolDelete();
          } else if (pBeanName
            .equals(PrcEntityFolSave.class.getSimpleName())) {
            proc = createPutPrcEntityFolSave();
          } else if (pBeanName
            .equals(PrcEntityPbCopy.class.getSimpleName())) {
            proc = createPutPrcEntityPbCopy();
          } else if (pBeanName
            .equals(PrcEntityCopy.class.getSimpleName())) {
            proc = createPutPrcEntityCopy();
          } else if (pBeanName
            .equals(PrcEntityPbSave.class.getSimpleName())) {
            proc = createPutPrcEntityPbSave();
          } else if (pBeanName
            .equals(PrcEntityPbEditDelete.class.getSimpleName())) {
            proc = createPutPrcEntityPbEditDelete();
          } else if (pBeanName
            .equals(PrcEmailMsgSave.class.getSimpleName())) {
            proc = createPutPrcEmailMsgSave();
          } else if (pBeanName
            .equals(PrcEntitySave.class.getSimpleName())) {
            proc = createPutPrcEntitySave();
          }
        }
      }
    }
    if (!this.isItSubfactory && proc == null) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "There is no entity processor with name " + pBeanName);
    }
    return proc;
  }
819982
@Override
    public int transferTo(int index, WritableByteChannel channel) {
        rangeCheck(index);
        
        try {
            long address = getAddress(index);
            int segPos = _addressFormat.getOffset(address);
            int segInd = _addressFormat.getSegment(address);
            
            // no data found
            if(segPos < Segment.dataStartPosition) return -1;
            
            // get data segment
            Segment seg = _segmentManager.getSegment(segInd);
            if(seg == null) return -1;
            
            // read data length
            int size = _addressFormat.getDataSize(address);
            int len = (size == 0) ? seg.readInt(segPos) : size;
            
            // transfer data to a writable channel
            if (len > 0) {
                seg.transferTo(segPos + 4, len, channel);
            }
            
            return len;
        } catch(Exception e) {
            return -1;
        }
    }
171793
@Override
    public Integer convertMQFeedbackToJS(Integer fb) {
        Integer result = null;

        // if fb is null, then the default result value of null is ok.
        if (fb != null)
            result = convertMQFeedbackToJS(fb.intValue());

        return result;
    }
580898
@Override
    public boolean isLoopbackAddress() {
        byte test = 0x00;
        for (int i = 0; i < 15; i++) {
            test |= ipaddress[i];
        }
        return (test == 0x00) && (ipaddress[15] == 0x01);
    }
865436
@Override
  public final LedgerPrevious retrievePrevious(
    final Map<String, Object> pAddParam, final Account pAccount,
      final Date pDate1, final String pSubaccId) throws Exception {
    getSrvBalance().recalculateAllIfNeed(pAddParam, pDate1);
    LedgerPrevious result = new LedgerPrevious();
    if (this.queryPrevious == null) {
      String flName = "/" + "accounting" + "/" + "ledger"
//+ "/" + "queryPrevious.sql";fast query cause error due changing subacc name
        + "/" + "queryPreviousSl.sql";
      this.queryPrevious = loadString(flName);
    }
    String query = queryPrevious.replace(":DATEBALANCE",
      String.valueOf(getSrvBalance()
        .evalDatePeriodStartFor(pAddParam, pDate1).getTime()));
    query = query.replace(":DATE1", String.valueOf(pDate1.getTime()));
    query = query.replace(":ACCID", "'" + pAccount.getItsId() + "'");
    String whereSubaccDebit = "";
    String whereSubaccCredit = "";
    String whereSubacc = "";
    if (pSubaccId != null && pSubaccId.length() > 0) {
      whereSubaccDebit = " and SUBACCDEBITID='" + pSubaccId + "'";
      whereSubaccCredit = " and SUBACCCREDITID='" + pSubaccId + "'";
      whereSubacc = " and SUBACCOUNT='" + pSubaccId + "'";
    }
    query = query.replace(":SUBACCDEBIT", whereSubaccDebit);
    query = query.replace(":SUBACCCREDIT", whereSubaccCredit);
    query = query.replace(":SUBACC", whereSubacc);
    IRecordSet<RS> recordSet = null;
    try {
      recordSet = getSrvDatabase().retrieveRecords(query);
      if (recordSet.moveToFirst()) {
        do {
          LedgerPreviousLine lpl = new LedgerPreviousLine();
          String subaccName = recordSet
            .getString("SUBACC");
          lpl.setDebit(BigDecimal.valueOf(recordSet.getDouble("DEBIT"))
            .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam)
              .getCostPrecision(), getSrvAccSettings()
                .lazyGetAccSettings(pAddParam).getRoundingMode()));
          lpl.setCredit(BigDecimal.valueOf(recordSet.getDouble("CREDIT"))
            .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam)
              .getCostPrecision(), getSrvAccSettings()
                .lazyGetAccSettings(pAddParam).getRoundingMode()));
          if (pAccount.getNormalBalanceType() == ENormalBalanceType.DEBIT) {
            lpl.setBalance(lpl.getDebit().subtract(lpl.getCredit()));
          } else {
            lpl.setBalance(lpl.getCredit().subtract(lpl.getDebit()));
          }
          result.getLinesMap().put(subaccName, lpl);
          result.setDebitAcc(result.getDebitAcc().add(lpl.getDebit()));
          result.setCreditAcc(result.getCreditAcc().add(lpl.getCredit()));
        } while (recordSet.moveToNext());
      }
    } finally {
      if (recordSet != null) {
        recordSet.close();
      }
    }
    if (pAccount.getNormalBalanceType() == ENormalBalanceType.DEBIT) {
      result.setBalanceAcc(result.getDebitAcc()
        .subtract(result.getCreditAcc()));
    } else {
      result.setBalanceAcc(result.getCreditAcc()
        .subtract(result.getDebitAcc()));
    }
    return result;
  }
538198
private static void checkAddress(String address, AddressFamily addrFamily) {
        if (addrFamily == null) {
            throw new NullPointerException("addrFamily");
        }

        switch (addrFamily) {
            case AF_UNSPEC:
                if (address != null) {
                    throw new HAProxyProtocolException("unable to validate an AF_UNSPEC address: " + address);
                }
                return;
            case AF_UNIX:
                return;
        }

        if (address == null) {
            throw new NullPointerException("address");
        }

        switch (addrFamily) {
            case AF_IPv4:
                if (!NetUtil.isValidIpV4Address(address)) {
                    throw new HAProxyProtocolException("invalid IPv4 address: " + address);
                }
                break;
            case AF_IPv6:
                if (!NetUtil.isValidIpV6Address(address)) {
                    throw new HAProxyProtocolException("invalid IPv6 address: " + address);
                }
                break;
            default:
                throw new Error();
        }
    }
1036645
@Override
    public InetAddress toInetAddress () throws UnknownHostException {
        if ( this.addr instanceof Address ) {
            return ( (Address) this.addr ).toInetAddress();
        }
        else if ( this.addr instanceof InetAddress ) {
            return (InetAddress) this.addr;
        }
        return null;
    }
135594
protected boolean readBackup(Decoder decoder) throws IOException {
    short numberOfBackupSteps = decoder.in.readVarShort(3);
    TrieNode fromNode = decoder.node;
    if (0 == numberOfBackupSteps) return true;
    for (int i = 0; i < numberOfBackupSteps; i++) {
      decoder.node = decoder.node.godparent();
    }
    if (verbose != null) {
      verbose.println(String.format("Backing up %s from from %s to %s", numberOfBackupSteps, fromNode.getDebugString(), decoder.node.getDebugString()));
    }
    return false;
  }
426785
function getAddressFromPriKeyBase64String(priKeyBase64String) {
  let priKeyBytes = base64DecodeFromString(priKeyBase64String);
  let pubBytes = getPubKeyFromPriKey(priKeyBytes);
  let addressBytes = computeAddress(pubBytes);
  let addressBase64 = base64EncodeToString(addressBytes);
  return addressBase64;
}