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: FixedChildAttributesImpl.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.IFixedChildAttributes;
031: import com.bostechcorp.cbesb.common.mdl.MDLDocConstants;
032:
033: public class FixedChildAttributesImpl extends FormatChildAttributesImpl
034: implements IFixedChildAttributes {
035:
036: /**
037: * This specifies the length of this field in characters in the raw data.
038: */
039: private int length;
040:
041: /**
042: * This specifies a fill character that is ignored if the actual data is less
043: * than the length of the field. The default value is the space character.
044: */
045: private char fillChar;
046:
047: /**
048: * Specifies if the data is right or left justified.
049: * Valid values are "left" and "right". The default value is "left".
050: */
051: private byte justification;
052:
053: /**
054: * Constructor
055: */
056: public FixedChildAttributesImpl() {
057: length = 0;
058: fillChar = 0;
059: justification = JUSTIFICATION_LEFT;
060: }
061:
062: /* (non-Javadoc)
063: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#getLength()
064: */
065: public int getLength() {
066: return length;
067: }
068:
069: /* (non-Javadoc)
070: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#setLength(int)
071: */
072: public void setLength(int length) {
073: this .length = length;
074: }
075:
076: /* (non-Javadoc)
077: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#getFillChar()
078: */
079: public char getFillChar() {
080: return fillChar;
081: }
082:
083: /* (non-Javadoc)
084: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#setFillChar(char)
085: */
086: public void setFillChar(char fillChar) {
087: this .fillChar = fillChar;
088: }
089:
090: /* (non-Javadoc)
091: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#getJustification()
092: */
093: public byte getJustification() {
094: return justification;
095: }
096:
097: /* (non-Javadoc)
098: * @see com.bostechcorp.cbesb.legacydata.mdl.FixedChildAttributes#setJustification(byte)
099: */
100: public void setJustification(byte justification) {
101: this .justification = justification;
102: }
103:
104: public void populateJDomAttributes(
105: MDLSerializerUtil serializerUtil, Element elem) {
106: Attribute attrLength = serializerUtil.createAttribute(
107: MDLDocConstants.MDL_FIXED_LENGTH, Integer
108: .toString(length));
109: elem.setAttribute(attrLength);
110:
111: if (fillChar != 0) {
112: Attribute attrFillChar = serializerUtil.createAttribute(
113: MDLDocConstants.MDL_FIXED_FILLCHAR, Character
114: .toString(fillChar));
115: elem.setAttribute(attrFillChar);
116: }
117:
118: //Left justification is default, only set if right is selected
119: if (justification == IFixedChildAttributes.JUSTIFICATION_RIGHT) {
120: Attribute attrJustification = serializerUtil
121: .createAttribute(
122: MDLDocConstants.MDL_FIXED_JUSTIFICATION,
123: MDLDocConstants.MDL_FIXED_RIGHT);
124: elem.setAttribute(attrJustification);
125: }
126: }
127:
128: }
|