1 17 18 19 20 package org.apache.fop.render.afp.modca; 21 22 import java.io.IOException ; 23 import java.io.OutputStream ; 24 import java.io.UnsupportedEncodingException ; 25 26 import org.apache.fop.render.afp.tools.BinaryUtils; 27 28 47 public class TagLogicalElement extends AbstractAFPObject { 48 49 52 private String _tleName = null; 53 54 57 private String _tleValue = null; 58 59 62 private byte[] _tleByteName = null; 63 64 67 private byte[] _tleByteValue = null; 68 69 74 public TagLogicalElement(String name, String value) { 75 76 _tleName = name; 77 _tleValue = value; 78 79 try { 80 81 _tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); 82 _tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); 83 84 } catch (UnsupportedEncodingException usee) { 85 86 _tleByteName = name.getBytes(); 87 _tleByteValue = value.getBytes(); 88 log.warn( 89 "Constructor:: UnsupportedEncodingException translating the name " 90 + name); 91 92 } 93 94 } 95 96 102 public void writeDataStream(OutputStream os) throws IOException { 103 104 byte[] data = new byte[17 + _tleName.length() + _tleValue.length()]; 105 106 data[0] = 0x5A; 107 byte[] rl1 = 109 BinaryUtils.convert(16 + _tleName.length() + _tleValue.length(), 2); 110 data[1] = rl1[0]; 112 data[2] = rl1[1]; 113 114 data[3] = (byte) 0xD3; 116 data[4] = (byte) 0xA0; 117 data[5] = (byte) 0x90; 118 119 data[6] = 0x00; data[7] = 0x00; data[8] = 0x00; 123 125 byte[] rl2 = BinaryUtils.convert(_tleName.length() + 4, 1); 126 data[9] = rl2[0]; data[10] = 0x02; data[11] = 0x0B; data[12] = 0x00; 130 131 int pos = 13; 132 for (int i = 0; i < _tleByteName.length; i++) { 133 data[pos++] = _tleByteName[i]; 134 } 135 136 byte[] rl3 = BinaryUtils.convert(_tleByteValue.length + 4, 1); 137 data[pos++] = rl3[0]; data[pos++] = 0x36; data[pos++] = 0x00; data[pos++] = 0x00; 142 for (int i = 0; i < _tleByteValue.length; i++) { 143 data[pos++] = _tleByteValue[i]; 144 } 145 os.write(data); 146 147 } 148 149 } 150 | Popular Tags |