class TemplateHandler {

    public boolean mapTemplates(IAtomContainer molecule) throws CDKException {
        // match element patterns first so hetero atoms are oriented correctly
        for (Pattern anonPattern : elemPatterns) {
            for (Map<IAtom, IAtom> atoms : anonPattern.matchAll(molecule).toAtomMap()) {
                for (Map.Entry<IAtom, IAtom> e : atoms.entrySet()) {
                    e.getValue().setPoint2d(new Point2d(e.getKey().getPoint2d()));
                    e.getValue().setFlag(CDKConstants.ISPLACED, true);
                }
                if (!atoms.isEmpty())
                    return true;
            }
        }
        // no element pattern matched, try anonymous patterns
        for (Pattern anonPattern : anonPatterns) {
            for (Map<IAtom, IAtom> atoms : anonPattern.matchAll(molecule).toAtomMap()) {
                for (Map.Entry<IAtom, IAtom> e : atoms.entrySet()) {
                    e.getValue().setPoint2d(new Point2d(e.getKey().getPoint2d()));
                    e.getValue().setFlag(CDKConstants.ISPLACED, true);
                }
                if (!atoms.isEmpty())
                    return true;
            }
        }
        return false;
    }

    public  TemplateHandler(IChemObjectBuilder builder);
    public  TemplateHandler();

}