1 28 29 package com.caucho.xml.readers; 30 31 import com.caucho.vfs.ReadStream; 32 import com.caucho.xml.XmlParser; 33 34 import java.io.IOException ; 35 36 39 public class Utf16Reader extends XmlReader { 40 boolean isReverse; 41 44 public Utf16Reader() 45 { 46 } 47 48 51 public Utf16Reader(XmlParser parser, ReadStream is) 52 { 53 super(parser, is); 54 } 55 56 public void setReverse(boolean isReverse) 57 { 58 this.isReverse = isReverse; 59 } 60 61 public boolean getReverse() 62 { 63 return isReverse; 64 } 65 66 69 public int read() 70 throws IOException 71 { 72 int ch1 = _is.read(); 73 int ch2 = _is.read(); 74 75 if (ch2 < 0) { 76 return -1; 77 } 78 else if (isReverse) 79 return (ch2 << 8) + ch1; 80 else 81 return (ch1 << 8) + ch2; 82 } 83 } 84 85 | Popular Tags |