Package org.milyn.edisax.interchange

Examples of org.milyn.edisax.interchange.ControlBlockHandlerFactory


        if(registry == null) {
            throw new IllegalStateException("'mappingsRegistry' not set.  Cannot parse EDI stream.");
        }

        try {
            ControlBlockHandlerFactory handlerFactory = new UNEdifact41ControlBlockHandlerFactory(hierarchyChangeListener);
          BufferedSegmentReader segmentReader = new BufferedSegmentReader(unedifactInterchange, defaultUNEdifactDelimiters);
          boolean validate = getFeature(EDIParser.FEATURE_VALIDATE);
          String segCode;
         
          segmentReader.mark();
          segmentReader.setIgnoreNewLines(getFeature(EDIParser.FEATURE_IGNORE_NEWLINES));

          contentHandler.startDocument();
          AttributesImpl attrs = new AttributesImpl();
          attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, ControlBlockHandlerFactory.ENVELOPE_PREFIX, XMLConstants.XMLNS_ATTRIBUTE + ":" + ControlBlockHandlerFactory.ENVELOPE_PREFIX, "CDATA", handlerFactory.getNamespace());
            String envElementQName = ControlBlockHandlerFactory.ENVELOPE_PREFIX + ":unEdifact";
            contentHandler.startElement(handlerFactory.getNamespace(), "unEdifact", envElementQName, attrs);
 
          while(true) {
            segCode = segmentReader.peek(3, true);
            if(segCode.length() == 3) {
                    interchangeContext = createInterchangeContext(segmentReader, validate, handlerFactory, namespaceDeclarationStack);
                    namespaceDeclarationStack = interchangeContext.getNamespaceDeclarationStack();

                    if(hierarchyChangeListener != null) {
                        hierarchyChangeListener.attachXMLReader(interchangeContext.getControlSegmentParser());
                    } else if (!interchangeContext.isContainerManagedNamespaceStack()) {
                        interchangeContext.getNamespaceDeclarationStack().pushReader(interchangeContext.getControlSegmentParser());
                    }

                    // Add the UN/EDIFACT namespace to the namespace stack...
                    namespaceDeclarationStack.pushNamespaces(envElementQName, handlerFactory.getNamespace(), attrs);

                    ControlBlockHandler handler = handlerFactory.getControlBlockHandler(segCode);

          interchangeContext.indentDepth.value++;
              handler.process(interchangeContext);
          interchangeContext.indentDepth.value--;
            } else {
              break;
            }
          }
         
          contentHandler.characters(new char[] {'\n'}, 0, 1);
          contentHandler.endElement(handlerFactory.getNamespace(), "unEdifact", envElementQName);
          contentHandler.endDocument();
        } finally {
            if (namespaceDeclarationStack != null) {
                namespaceDeclarationStack.popNamespaces();
                if(hierarchyChangeListener != null) {
View Full Code Here

TOP

Related Classes of org.milyn.edisax.interchange.ControlBlockHandlerFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.