KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > webman > attr > TKWMXmlMConverter


1 package com.teamkonzept.webman.attr;
2
3 import com.teamkonzept.lib.*;
4
5 /**
6  * Konvertierungsklasse fuer XML-Text-Codierung mit Beruecksichtung von TK-Markups
7  * @author $Author: mischa $
8  * @version $Revision: 1.3 $
9  */

10 public class TKWMXmlMConverter extends TKConverter {
11     public final static String JavaDoc CONV_ID = "XMLM";
12     public final static String JavaDoc CONV_NAME = "XMLM-ISO-8859_1";
13
14     public String JavaDoc getName()
15     {
16         return CONV_NAME;
17     }
18     
19     public int getMaxBytesPerChar()
20     {
21         return 8;
22     }
23     
24     public int minCharSize(int byteCount)
25     {
26         return byteCount;
27     }
28     
29     public byte[] doYourself (String JavaDoc src) {
30
31         TKWMAttrText attrText = new TKWMAttrText (null,src);
32         attrText.completeMarkups ();
33         String JavaDoc converted = attrText.convert2Xml();
34         
35         return converted.getBytes();
36     }
37
38     public int charsToBytes(char src[], byte dst[], int srcBegin, int length, int dstBegin)
39     {
40         int lastPos = srcBegin+length;
41         int firstPos = dstBegin;
42
43         for( int i=srcBegin; i<lastPos; i++ )
44             dst[dstBegin++] = (byte) (src[i]);
45         
46         return dstBegin - firstPos;
47     }
48     
49     public int bytesToChars(byte src[], char dst[], int srcBegin, int length, int dstBegin)
50     {
51         int lastPos = srcBegin+length;
52         int firstPos = dstBegin;
53         int i=srcBegin;
54         
55         while( i<lastPos )
56             dst[dstBegin++] = (char) (src[i++]);
57
58         return dstBegin - firstPos;
59     }
60 }
61
62
Popular Tags