Add the marker to this formatting object. If this object can contain markers it checks that the marker has a unique class-name for this object and that it is the first child. @param marker Marker to add.
(Marker marker)
| 405 | * @param marker Marker to add. |
| 406 | */ |
| 407 | protected void addMarker(Marker marker) { |
| 408 | String mcname = marker.getMarkerClassName(); |
| 409 | if (firstChild != null) { |
| 410 | // check for empty childNodes |
| 411 | for (FONodeIterator iter = getChildNodes(); iter.hasNext();) { |
| 412 | FONode node = iter.next(); |
| 413 | if (node instanceof FObj |
| 414 | || (node instanceof FOText |
| 415 | && ((FOText) node).willCreateArea())) { |
| 416 | getFOValidationEventProducer().markerNotInitialChild(this, getName(), |
| 417 | mcname, locator); |
| 418 | return; |
| 419 | } else if (node instanceof FOText) { |
| 420 | iter.remove(); |
| 421 | notifyChildRemoval(node); |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | if (markers == null) { |
| 426 | markers = new HashMap<String, Marker>(); |
| 427 | } |
| 428 | if (!markers.containsKey(mcname)) { |
| 429 | markers.put(mcname, marker); |
| 430 | } else { |
| 431 | getFOValidationEventProducer().markerNotUniqueForSameParent(this, getName(), |
| 432 | mcname, locator); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * @return true if there are any Markers attached to this object |
no test coverage detected