Encodes the atom at index (atmIdx) to a SMARTS
expression that matches itself.

@param atmIdx atom index
@return SMARTS atom expression
358434
private String encodeAtomExpr(int atmIdx) {
        final IAtom atom = mol.getAtom(atmIdx);

        boolean complex = mode == MODE_EXACT;

        StringBuilder sb = new StringBuilder();

        switch (atom.getAtomicNumber()) {
            case 0:  // *
                sb.append('*');
                break;
            case 5:  // B
            case 6:  // C
            case 7:  // N
            case 8:  // O
            case 15: // P
            case 16: // S
            case 9:  // F
            case 17: // Cl
            case 35: // Br
            case 53: // I
                sb.append(atom.isAromatic() ? atom.getSymbol().toLowerCase(Locale.ROOT)
                                            : atom.getSymbol());
                break;
            default:
                complex = true;
                sb.append(atom.isAromatic() ? atom.getSymbol().toLowerCase(Locale.ROOT)
                                            : atom.getSymbol());
                break;
        }

        if (mode == MODE_EXACT) {

            int hcount = atom.getImplicitHydrogenCount();
            int valence = hcount;
            int connections = hcount;

            int atmDeg = this.deg[atmIdx];
            for (int i = 0; i < atmDeg; i++) {
                IBond bond = mol.getBond(bondAdj[atmIdx][i]);
                IAtom nbr = bond.getOther(atom);
                if (nbr.getAtomicNumber() != null && nbr.getAtomicNumber() == 1)
                    hcount++;
                int bord = bond.getOrder() != null ? bond.getOrder().numeric() : 0;
                if (bord == 0)
                    throw new IllegalArgumentException("Molecule had unsupported zero-order or unset bonds!");
                valence += bord;
                connections++;
            }

            sb.append('H').append(hcount);
            sb.append('v').append(valence);
            sb.append('X').append(connections);
        }

        Integer chg = atom.getFormalCharge();
        if (chg == null) chg = 0;


        if (chg <= -1 || chg >= +1) {
            if (chg >= 0) sb.append('+');
            else sb.append('-');
            int abs = Math.abs(chg);
            if (abs > 1) sb.append(abs);
            complex = true;
        } else if (mode == MODE_EXACT) {
            sb.append("+0");
        }

        return complex ? '[' + sb.toString() + ']' : sb.toString();
    }
349340
private String encodeBondExpr(int bondIdx, int beg, int end) {
        IBond bond = mol.getBond(bondIdx);
        if (bond.getOrder() == null)
            return "";

        boolean bArom = bond.isAromatic();
        boolean aArom = mol.getAtom(beg).isAromatic() && mol.getAtom(end).isAromatic();
        switch (bond.getOrder()) {
            case SINGLE:
                if (bArom) {
                    return aArom ? "" : ":";
                } else {
                    return aArom ? "-" : "";
                }
            case DOUBLE:
                return bArom ? "" : "=";
            case TRIPLE:
                return "#";
            default:
                throw new IllegalArgumentException("Unsupported bond type: " + bond.getOrder());
        }
    }
1263541
public static String encode(Byte[] in) {
		byte[] tmp = new byte[in.length];
		for(int i = 0; i < tmp.length; i++) {
			tmp[i] = in[i];
		}
		return encode(tmp);
	}
1135062
private void store(int bidx, IQueryAtom queryatom) {
        ++sptr;
        stack[sptr].bidx = bidx;
        stack[sptr].iter = null;
        if (queryatom != null)
            stack[sptr].atom = queryatom;
        else
            stack[sptr].atom = null;
    }
544075
public Name getPrefix(int index) {
		LinkedList newNames = new LinkedList();
		for (int i = 0; i < index; i++) {
			newNames.add(names.get(i));
		}

		return new DistinguishedName(newNames);
	}
626119
@Nonnull
  public static String getHexEncoded (@Nonnull final byte [] aInput)
  {
    ValueEnforcer.notNull (aInput, "Input");

    return getHexEncoded (aInput, 0, aInput.length);
  }
166223
public ByteBuffer getValue(int index) throws IOException {
        if (index >= structure.valueSizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        int length = structure.valueSizes.get(index);
        return ByteBuffer.wrap(value, structure.valueByteOffsets.get(index), length).asReadOnlyBuffer();
    }
1112122
public static String getAt(CharSequence self, Collection indices) {
        StringBuilder answer = new StringBuilder();
        for (Object value : indices) {
            if (value instanceof Range) {
                answer.append(getAt(self, (Range) value));
            } else if (value instanceof Collection) {
                answer.append(getAt(self, (Collection) value));
            } else {
                int idx = DefaultTypeTransformation.intUnbox(value);
                answer.append(getAt(self, idx));
            }
        }
        return answer.toString();
    }
274851
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt8(this.offset, dst, dstIndex);
        dstIndex += 8;
        SMBUtil.writeInt8(this.length, dst, dstIndex);
        dstIndex += 8;

        SMBUtil.writeInt4(this.flags, dst, dstIndex);
        dstIndex += 4;
        dstIndex += 4; // Reserved
        return dstIndex - start;
    }
1188119
public String ENgetlinkid( int index ) throws EpanetException {
        ByteBuffer bb = ByteBuffer.allocate(64);
        int errcode = epanet.ENgetlinkid(index, bb);
        checkError(errcode);

        String label;
        label = byteBuffer2String(bb);
        return label;
    }
311738
public static IRArrayStoreStatementBuilder arrayStore( IRExpressionBuilder target, IRExpressionBuilder index, IRExpressionBuilder value ) {
    IRArrayStoreStatementBuilder statement = new IRArrayStoreStatementBuilder( target, index, value );
    return statement;
  }
612533
private void encodeExpr(int idx, int bprev, StringBuilder sb) {
        avisit[idx] = numVisit++;
        sb.append(aexpr[idx]);
        final int d = deg[idx];

        int remain = d;
        for (int j = 0; j < d; j++) {
            int nbr = atomAdj[idx][j];
            int bidx = bondAdj[idx][j];

            // ring open/close
            if (rbnds[bidx] < 0) {
                // open
                final int rnum = chooseRingNumber();
                if (rnum > 9) sb.append('%');
                sb.append(rnum);
                rbnds[bidx] = rnum;
            } else if (rbnds[bidx] > 0) {
                // close
                final int rnum = rbnds[bidx];
                releaseRingNumber(rnum);
                if (rnum > 9) sb.append('%');
                sb.append(rnum);
            }

            if (mode == MODE_EXACT && avisit[nbr] == 0 ||
                bidx == bprev ||
                rbnds[bidx] != 0)
                remain--;
        }

        for (int j = 0; j < d; j++) {
            int nbr = atomAdj[idx][j];
            int bidx = bondAdj[idx][j];
            if (mode == MODE_EXACT && avisit[nbr] == 0 ||
                bidx == bprev ||
                rbnds[bidx] != 0)
                continue; // ignored
            remain--;
            if (avisit[nbr] == 0) {
                // peripheral bond
                if (remain > 0) sb.append('(');
                sb.append(bexpr[bidx]);
                sb.append(mol.getAtom(nbr).isAromatic() ? 'a' : '*');
                if (remain > 0) sb.append(')');
            } else {
                if (remain > 0) sb.append('(');
                sb.append(bexpr[bidx]);
                encodeExpr(nbr, bidx, sb);
                if (remain > 0) sb.append(')');
            }
        }
    }
507504
public Name getSuffix(int index) {
		if (index > names.size()) {
			throw new ArrayIndexOutOfBoundsException();
		}

		LinkedList newNames = new LinkedList();
		for (int i = index; i < names.size(); i++) {
			newNames.add(names.get(i));
		}

		return new DistinguishedName(newNames);
	}
730351
public ByteBuffer toByteBuffer(int index, int length)
    {
        checkPositionIndexes(index, index + length, this.length);
        index += offset;
        return ByteBuffer.wrap(data, index, length).order(LITTLE_ENDIAN);
    }
1169263
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(this.ciphers != null ? this.ciphers.length : 0, dst, dstIndex);
        dstIndex += 2;

        if ( this.ciphers != null ) {
            for ( int cipher : this.ciphers ) {
                SMBUtil.writeInt2(cipher, dst, dstIndex);
                dstIndex += 2;
            }
        }
        return dstIndex - start;
    }
1216024
public String convertIndexToString(int index)
    {
        String tempString = null;
        if ((index >= 0) && (index <= 9))
        {
            char value[] = new char[1];
            value[0] = (char)('0' + index);
            tempString = new String(value);         // 1 = '1'; 2 = '2'; etc...
        }
        else
            tempString = Constants.BLANK;
        return tempString;
    }
241434
@Override
    public String wordAtIndex(int index) {
        T element = idxMap.get(index);
        if (element != null) {
            return element.getLabel();
        }
        return null;
    }