public Token next ( ) { if ( ! splitTokens . isEmpty ( ) ) { return splitTokens . remove ( ) ; } var value = stringIterator . next ( ) ; if ( argumentEscapeEncountered ) { return new ArgumentToken ( value ) ; } if ( Objects . equals ( value , argumentTerminator ) ) { argumentTerminator = null ; return new ArgumentToken ( value ) ; } if ( argumentTerminator != null ) { return new ArgumentToken ( value ) ; } if ( isArgumentEscape ( value ) ) { argumentEscapeEncountered = true ; return next ( ) ; } if ( isSwitch ( value ) ) { if ( isShortSwitchList ( value ) ) { splitTokens . addAll ( splitSwitchTokens ( value ) ) ; return splitTokens . remove ( ) ; } else { return new SwitchToken ( value . substring ( 2 ) , value ) ; } } else { return new ArgumentToken ( value ) ; } }
this is a mess - needs to be cleaned up