private void mergeUnknownNode(Node node) throws IIOInvalidTreeException {
  MarkerSegment newGuy=new MarkerSegment(node);
  int lastUnknown=findLastUnknownMarkerSegmentPosition();
  boolean hasJFIF=(findMarkerSegment(JFIFMarkerSegment.class,true) != null);
  int firstAdobe=findMarkerSegmentPosition(AdobeMarkerSegment.class,true);
  if (lastUnknown != -1) {
    markerSequence.add(lastUnknown + 1,newGuy);
  }
 else   if (hasJFIF) {
    markerSequence.add(1,newGuy);
  }
  if (firstAdobe != -1) {
    markerSequence.add(firstAdobe,newGuy);
  }
 else {
    markerSequence.add(0,newGuy);
  }
}

private void mergeUnknownNode ( Node node ) throws IIOInvalidTreeException { MarkerSegment newGuy = new MarkerSegment ( node ) ; int lastUnknown = findLastUnknownMarkerSegmentPosition ( ) ; boolean hasJFIF = ( findMarkerSegment ( JFIFMarkerSegment . class , true ) != null ) ; int firstAdobe = findMarkerSegmentPosition ( AdobeMarkerSegment . class , true ) ; if ( lastUnknown != - 1 ) { markerSequence . add ( lastUnknown + 1 , newGuy ) ; } else if ( hasJFIF ) { markerSequence . add ( 1 , newGuy ) ; } if ( firstAdobe != - 1 ) { markerSequence . add ( firstAdobe , newGuy ) ; } else { markerSequence . add ( 0 , newGuy ) ; } }
merge the given unknown node into the marker sequence . a new unknown marker segment is created and added to the sequence as follows : if there already exist unknown marker segments , the new one is inserted after the last one . if there are no unknown marker segments , the new unknown marker segment is inserted after the jfif segment , if there is one . if there is no jfif segment , the new unknown segment is inserted before the adobe marker segment , if there is one . if there is no adobe segment , the new unknown segment is inserted at the beginning of the sequence .
