if (shape instanceof OMPoly) {
if (!(shape instanceof EsriPolyline) && shape instanceof OMPoly) {
    public void add(OMGraphic shape) {        try {            if (shape instanceof OMPoly) {                shape = EsriPolyline.convert((OMPoly) shape);            } else if (shape instanceof OMLine) {                shape = EsriPolyline.convert(EsriPolylineList.convert((OMLine) shape));            }            if (shape instanceof OMGraphicList) {                OMGraphicList list = (OMGraphicList) shape;                EsriGraphic graphic = (EsriGraphic) list.getOMGraphicAt(0);                if (graphic instanceof EsriPolyline                        || graphic instanceof EsriPolylineList) {                    graphics.add(shape);                    addExtents(((EsriGraphicList) shape).getExtents());                } else if (graphic instanceof OMGraphic) {                    // Try recursively...                    add((OMGraphic) graphic);                } else {                    Debug.message("esri",                            "EsriPolylineList.add()- graphic list isn't EsriPolylineList, can't add.");                }            } else if (shape instanceof EsriPolyline) {                graphics.add(shape);                addExtents(((EsriPolyline) shape).getExtents());            } else {                Debug.message("esri",                        "EsriPolylineList.add()- graphic isn't EsriPolyline, can't add.");            }        } catch (ClassCastException cce) {        }    }