code: private void flush() {
      	switch(state){
      	case TEXT:
      	case CDATA:
              if(text.length() > 0) {
                  doc.text(text.toString());
              }
              break;
      	case COMMENT:
          	if (comment != null) {
                  comment.comment(text.toString());
              }
          	break;
      	case ATTRIBUTE_KEY:
              attributekey = text.toString();
              if (html)
                  attributekey = attributekey.toLowerCase();
      		break;
      	case QUOTE:
      	case ATTRIBUTE_VALUE:
          	attributevalue = text.toString();
              attributes.put(attributekey,attributevalue);
              break;
      	default:
      		// do nothing
      	}
          text.setLength(0);
      }
docs: Flushes the text that is currently in the buffer.
  The text can be ignored, added to the document
  as content or as comment,... depending on the current state.