StandardReader extends EDIReader { protected void parseSegmentElement(Token t) throws SAXException { EDIAttributes attributes; String elementId = t.getElementId(); switch (t.getType()) { case SIMPLE: if (t.getValueLength() == 0 || !t.containsNonSpace()) return; attributes = getDocumentAttributes(); attributes.clear(); attributes.addCDATA(getXMLTags().getIdAttribute(), elementId); startElement(getXMLTags().getElementTag(), attributes); getContentHandler().characters(t.getValueChars(), 0, t.getValueLength()); endElement(getXMLTags().getElementTag()); if (segmentPluginController != null) segmentPluginController.noteElement(getContentHandler(), elementId, t.getValueChars(), 0, t.getValueLength()); break; case SUB_ELEMENT: attributes = getDocumentAttributes(); if (t.isFirst()) { attributes.clear(); attributes.addCDATA(getXMLTags().getIdAttribute(), elementId); attributes.addCDATA(getXMLTags().getCompositeIndicator(), "yes"); startElement(getXMLTags().getElementTag(), attributes); } attributes.clear(); attributes.addAttribute( "", getXMLTags().getSubElementSequence(), getXMLTags().getSubElementSequence(), "CDATA", String.valueOf(1 + t.getSubIndex())); startElement(getXMLTags().getSubElementTag(), attributes); getContentHandler().characters(t.getValueChars(), 0, t.getValueLength()); endElement(getXMLTags().getSubElementTag()); if (t.isLast()) { endElement(getXMLTags().getElementTag()); } break; case SUB_EMPTY: if (t.isFirst()) { attributes = getDocumentAttributes(); attributes.clear(); attributes.addCDATA(getXMLTags().getIdAttribute(), elementId); attributes.addCDATA(getXMLTags().getCompositeIndicator(), "yes"); startElement(getXMLTags().getElementTag(), attributes); } if (t.isLast()) { endElement(getXMLTags().getElementTag()); } break; } }  @Override void parse(InputSource source); void setControlDateAndTime(String overrideValue); int getGroupCount(); void setGroupCount(int groupCount); String getInterchangeControlNumber(); void setInterchangeControlNumber(String interchangeControlNumber); String getGroupControlNumber(); void setGroupControlNumber(String groupControlNumber); int getDocumentCount(); void setDocumentCount(int documentCount); RecoverableSyntaxException getSyntaxException(); void setSyntaxException(RecoverableSyntaxException syntaxException); ReplyGenerator getAckGenerator(); void setAckGenerator(ReplyGenerator generator); ReplyGenerator getAlternateAckGenerator(); void setAlternateAckGenerator(ReplyGenerator generator); PluginControllerFactoryInterface getPluginControllerFactory(); @Override void setPluginControllerFactory(PluginControllerFactoryInterface pluginControllerFactory);  }
@Test public void segmentElement_simple() throws SAXException { reader = new DefaultStandardReader(); final MyContentHandler handler = new MyContentHandler(); reader.setContentHandler(handler); reader.parseSegmentElement(new MyToken(TokenType.SIMPLE, "abc")); reader.parseSegmentElement(new MyToken(TokenType.EMPTY, null)); reader.parseSegmentElement(new MyToken(TokenType.SUB_ELEMENT, "123", true, false)); reader.parseSegmentElement(new MyToken(TokenType.SUB_EMPTY, null, false, false)); reader.parseSegmentElement(new MyToken(TokenType.SUB_EMPTY, null, false, false)); reader.parseSegmentElement(new MyToken(TokenType.SUB_EMPTY, null, false, true)); reader.parseSegmentElement(new MyToken(TokenType.EMPTY, null)); Assert.assertEquals("start(element, abc) end(element) start(element, null) start(subelement, 123) end(subelement) end(element)", handler.getLog()); }