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
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) 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
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: *
023: * $Id: MDLDocReferenceImpl.java 6044 2007-03-18 03:55:52Z mpreston $
024: */
025: package com.bostechcorp.cbesb.common.mdl.impl;
026:
027: import org.jdom.Attribute;
028: import org.jdom.Element;
029:
030: import com.bostechcorp.cbesb.common.mdl.IMDLDocReference;
031: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
032: import com.bostechcorp.cbesb.common.mdl.MDLDocConstants;
033:
034: public class MDLDocReferenceImpl implements IMDLDocReference {
035:
036: /**
037: *
038: */
039: private byte type;
040:
041: /**
042: *
043: */
044: private String defLocation;
045:
046: /**
047: *
048: */
049: private String namespace;
050:
051: /**
052: *
053: */
054: private IMDLDocument mdlDoc;
055:
056: /**
057: * constructor
058: */
059: public MDLDocReferenceImpl() {
060:
061: }
062:
063: /* (non-Javadoc)
064: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#getType()
065: */
066: public byte getType() {
067: return type;
068: }
069:
070: /* (non-Javadoc)
071: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#setType(byte)
072: */
073: public void setType(byte type) {
074: this .type = type;
075: }
076:
077: /* (non-Javadoc)
078: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#getDefLocation()
079: */
080: public String getDefLocation() {
081: return defLocation;
082: }
083:
084: /* (non-Javadoc)
085: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#setDefLocation(java.lang.String)
086: */
087: public void setDefLocation(String defLocation) {
088: this .defLocation = defLocation;
089: }
090:
091: /* (non-Javadoc)
092: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#getNamespace()
093: */
094: public String getNamespace() {
095: return namespace;
096: }
097:
098: /* (non-Javadoc)
099: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#setNamespace(java.lang.String)
100: */
101: public void setNamespace(String namespace) {
102: this .namespace = namespace;
103: }
104:
105: /* (non-Javadoc)
106: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#getMDLDocument()
107: */
108: public IMDLDocument getMDLDocument() {
109: return mdlDoc;
110: }
111:
112: /* (non-Javadoc)
113: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocReference#setMDLDocument(com.bostechcorp.cbesb.legacydata.mdl.MDLDocument)
114: */
115: public void setMDLDocument(IMDLDocument mdlDoc) {
116: this .mdlDoc = mdlDoc;
117: }
118:
119: public void serializeToJDom(MDLSerializerUtil serializerUtil,
120: Element mdlRoot) {
121: if (type == IMDLDocReference.TYPE_IMPORT) {
122: Element elemImport = serializerUtil
123: .createElement(MDLDocConstants.MDL_IMPORT);
124: if (defLocation != null && !defLocation.equals("")) {
125: Attribute attrDefLoc = serializerUtil.createAttribute(
126: MDLDocConstants.MDL_DEFLOCATION, defLocation);
127: elemImport.setAttribute(attrDefLoc);
128: }
129: if (namespace != null && !namespace.equals("")) {
130: Attribute attrNamespace = serializerUtil
131: .createAttribute(
132: MDLDocConstants.MDL_IMPORT_NAMESPACE,
133: namespace);
134: elemImport.setAttribute(attrNamespace);
135:
136: serializerUtil.addNamespace(namespace);
137: }
138: mdlRoot.addContent(elemImport);
139:
140: } else if (type == IMDLDocReference.TYPE_INCLUDE) {
141: Element elemInclude = serializerUtil
142: .createElement(MDLDocConstants.MDL_INCLUDE);
143: if (defLocation != null && !defLocation.equals("")) {
144: Attribute attrDefLoc = serializerUtil.createAttribute(
145: MDLDocConstants.MDL_DEFLOCATION, defLocation);
146: elemInclude.setAttribute(attrDefLoc);
147: }
148: mdlRoot.addContent(elemInclude);
149: }
150: }
151:
152: }
|