001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id: X12Parser.java 3622 2006-12-12 03:04:08Z lzheng $
023: */
024: package com.bostechcorp.cbesb.runtime.parser.impl;
025:
026: import java.io.File;
027: import java.io.InputStream;
028: import java.net.URI;
029:
030: import org.apache.commons.logging.Log;
031: import org.apache.commons.logging.LogFactory;
032: import org.w3c.dom.Document;
033:
034: import com.bostechcorp.cbesb.common.mdl.MDLDocumentFactory;
035: import com.bostechcorp.cbesb.common.mdl.x12.X12DocLocationResolver;
036: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
037: import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
038: import com.bostechcorp.cbesb.common.mdl.IVariableFormatDefinition;
039: import com.bostechcorp.cbesb.common.mdl.MDLException;
040: import com.bostechcorp.cbesb.common.mdl.MDLParser;
041: import com.bostechcorp.cbesb.runtime.parser.ParserException;
042:
043: public class X12Parser extends VariantParser {
044:
045: private char segmentTerminator = 0;
046: private char fieldSeparator = 0;
047: private char compositeSeparator = 0;
048:
049: private static final Log log = LogFactory.getLog(X12Parser.class);
050:
051: /**
052: * @return the compositeSeparator
053: */
054: public char getCompositeSeparator() {
055: return compositeSeparator;
056: }
057:
058: /**
059: * @param compositeSeparator the compositeSeparator to set
060: */
061: public void setCompositeSeparator(char compositeSeparator) {
062: this .compositeSeparator = compositeSeparator;
063: }
064:
065: /**
066: * @return the fieldSeparator
067: */
068: public char getFieldSeparator() {
069: return fieldSeparator;
070: }
071:
072: /**
073: * @param fieldSeparator the fieldSeparator to set
074: */
075: public void setFieldSeparator(char fieldSeparator) {
076: this .fieldSeparator = fieldSeparator;
077: }
078:
079: /**
080: * @return the segmentTerminator
081: */
082: public char getSegmentTerminator() {
083: return segmentTerminator;
084: }
085:
086: /**
087: * @param segmentTerminator the segmentTerminator to set
088: */
089: public void setSegmentTerminator(char segmentTerminator) {
090: this .segmentTerminator = segmentTerminator;
091: }
092:
093: /* (non-Javadoc)
094: * @see com.bostechcorp.cbesb.runtime.parser.impl.VariantParser#getFsmClassName(java.lang.String)
095: */
096: @Override
097: protected String getFsmClassName(String messageName) {
098: String retVal;
099: if (getVariant() == null || getVariant().equals(""))
100: retVal = "com.bostechcorp.cbesb.fsmparser.x12."
101: + getVersion() + "." + "messages." + messageName
102: + "." + messageName + "." + messageName;
103: else {
104: retVal = "com.bostechcorp.cbesb.fsmparser."
105: + getProjectName().replace(File.separatorChar, '.')
106: + ".x12." + getVersion() + "." + getVariant()
107: + ".messages." + messageName + "." + messageName
108: + "." + messageName;
109: }
110: return retVal;
111: }
112:
113: /* (non-Javadoc)
114: * @see com.bostechcorp.cbesb.runtime.parser.impl.VariantParser#preProcessMessage(java.lang.StringBuffer)
115: */
116: @Override
117: protected void preProcessMessage(StringBuffer msgData)
118: throws ParserException {
119: //No modifications to the message is necessary
120: //Just override special characters if values
121: //have been set.
122: if (segmentTerminator != 0) {
123: overrideMsgDefProperty("SegmentTerminator", String
124: .valueOf(segmentTerminator));
125: }
126: if (fieldSeparator != 0) {
127: overrideMsgDefProperty("FieldSeparator", String
128: .valueOf(fieldSeparator));
129: }
130: if (compositeSeparator != 0) {
131: overrideMsgDefProperty("CompositeSeparator", String
132: .valueOf(compositeSeparator));
133: }
134: }
135:
136: }
|