Java Doc for CharToByteConverter.java in  » 6.0-JDK-Modules » j2me » sun » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sun.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sun.io.CharToByteConverter

All known Subclasses:   sun.io.CharToByteDBCS_EBCDIC,  sun.io.CharToByteSingleByte,  sun.io.CharToByteASCII,  sun.io.CharToByteUnicode,  sun.io.CharToByteDoubleByte,  sun.io.CharToByteEUC_TW,  sun.io.CharToByteUTF8,  sun.io.CharToByteISO8859_1,  sun.io.CharToByteCp949C,  sun.io.CharToByteDBCS_ASCII,  sun.io.CharToByteCp949,  sun.io.CharToByteCp970,  sun.io.CharToByteEUC,  sun.io.CharToByteISO2022,  sun.io.CharToByteCp933,
CharToByteConverter
abstract public class CharToByteConverter (Code)
An abstract base class for subclasses which convert Unicode characters into an external encoding.
author:
   Asmus Freytag
author:
   Lloyd Honomichl, Novell, Inc.


Field Summary
protected  intbadInputLength
     Length of bad input that caused conversion to stop.
protected  intbyteOff
     Offset of next byte to be output.
protected  intcharOff
     Offset of next character to be converted.
protected  byte[]subBytes
     Bytes to substitute for unmappable input.
protected  booleansubMode
     Substitution mode flag.


Method Summary
public  booleancanConvert(char c)
     Returns true if the given character can be converted to the target character encoding.
abstract public  intconvert(char[] input, int inStart, int inEnd, byte[] output, int outStart, int outEnd)
     Converts an array of Unicode characters into an array of bytes in the target character encoding.
public  byte[]convertAll(char input)
     Converts an array of Unicode characters into an array of bytes in the target character encoding.
public  intconvertAny(char[] input, int inStart, int inEnd, byte[] output, int outStart, int outEnd)
    
abstract public  intflush(byte[] output, int outStart, int outEnd)
     Writes any remaining output to the output buffer and resets the converter to its initial state.
public  intflushAny(byte[] output, int outStart, int outEnd)
     Writes any remaining output to the output buffer and resets the converter to its initial state.
public  intgetBadInputLength()
     Returns the length, in chars, of the input which caused a MalformedInputException.
abstract public  StringgetCharacterEncoding()
     Returns the character set id for the conversion.
public static  CharToByteConvertergetConverter(String encoding)
     Returns appropriate CharToByteConverter subclass instance.
public static  CharToByteConvertergetDefault()
     Create an instance of the default CharToByteConverter subclass.
abstract public  intgetMaxBytesPerChar()
     Returns the maximum number of bytes needed to convert a char.
public  intnextByteIndex()
     Returns the index of the byte just past the last byte written by the previous call to convert.
public  intnextCharIndex()
     Returns the index of the character just past the last character successfully converted by the previous call to convert.
abstract public  voidreset()
     Resets converter to its initial state.
public  voidsetSubstitutionBytes(byte[] newSubBytes)
     Sets the substitution bytes to use when the converter is in substitution mode.
public  voidsetSubstitutionMode(boolean doSub)
     Sets converter into substitution mode.
public  StringtoString()
     Returns a string representation of the class.

Field Detail
badInputLength
protected int badInputLength(Code)
Length of bad input that caused conversion to stop.



byteOff
protected int byteOff(Code)
Offset of next byte to be output.



charOff
protected int charOff(Code)
Offset of next character to be converted.



subBytes
protected byte[] subBytes(Code)
Bytes to substitute for unmappable input.



subMode
protected boolean subMode(Code)
Substitution mode flag.





Method Detail
canConvert
public boolean canConvert(char c)(Code)
Returns true if the given character can be converted to the target character encoding. true if given character is translatable, false otherwise.
Parameters:
  c - character to test



convert
abstract public int convert(char[] input, int inStart, int inEnd, byte[] output, int outStart, int outEnd) throws MalformedInputException, UnknownCharacterException, ConversionBufferFullException(Code)
Converts an array of Unicode characters into an array of bytes in the target character encoding. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. If a call to convert results in an exception, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method. the number of bytes written to output.
Parameters:
  input - array containing Unicode characters to be converted.
Parameters:
  inStart - begin conversion at this offset in input array.
Parameters:
  inEnd - stop conversion at this offset in input array (exclusive).
Parameters:
  output - byte array to receive conversion result.
Parameters:
  outStart - start writing to output array at this offset.
Parameters:
  outEnd - stop writing to output array at this offset (exclusive).
exception:
  MalformedInputException - if the input buffer contains anysequence of chars that is illegal in Unicode (principally unpairedsurrogates and \uFFFF or \uFFFE). After this exception is thrown,the method nextCharIndex can be called to obtain the index of thefirst invalid input character. The MalformedInputException canbe queried for the length of the invalid input.
exception:
  UnknownCharacterException - for any character thatthat cannot be converted to the external character encoding. Thrownonly when converter is not in substitution mode.
exception:
  ConversionBufferFullException - if output array is filled priorto converting all the input.



convertAll
public byte[] convertAll(char input) throws MalformedInputException(Code)
Converts an array of Unicode characters into an array of bytes in the target character encoding. Unlike convert, this method does not do incremental conversion. It assumes that the given input array contains all the characters to be converted. The state of the converter is reset at the beginning of this method and is left in the reset state on successful termination. The converter is not reset if an exception is thrown. This allows the caller to determine where the bad input was encountered by calling nextCharIndex.

This method uses substitution mode when performing the conversion. The method setSubstitutionBytes may be used to determine what bytes are substituted. Even though substitution mode is used, the state of the converter's substitution mode is not changed at the end of this method. an array of bytes containing the converted characters.
Parameters:
  input - array containing Unicode characters to be converted.
exception:
  MalformedInputException - if the input buffer contains anysequence of chars that is illegal in Unicode (principally unpairedsurrogates and \uFFFF or \uFFFE). After this exception is thrown,the method nextCharIndex can be called to obtain the index of thefirst invalid input character and getBadInputLength can be calledto determine the length of the invalid input.
See Also:   CharToByteConverter.nextCharIndex
See Also:   CharToByteConverter.setSubstitutionMode
See Also:   CharToByteConverter.setSubstitutionBytes
See Also:   CharToByteConverter.getBadInputLength




convertAny
public int convertAny(char[] input, int inStart, int inEnd, byte[] output, int outStart, int outEnd) throws ConversionBufferFullException(Code)



flush
abstract public int flush(byte[] output, int outStart, int outEnd) throws MalformedInputException, ConversionBufferFullException(Code)
Writes any remaining output to the output buffer and resets the converter to its initial state.
Parameters:
  output - byte array to receive flushed output.
Parameters:
  outStart - start writing to output array at this offset.
Parameters:
  outEnd - stop writing to output array at this offset (exclusive).
exception:
  MalformedInputException - if the output to be flushed containeda partial or invalid multibyte character sequence. Will occur if theinput buffer on the last call to convert ended with the first characterof a surrogate pair. flush will write what it can to the output bufferand reset the converter before throwing this exception. An additionalcall to flush is not required.
exception:
  ConversionBufferFullException - if output array is filled before all the output can be flushed. flush will write what it canto the output buffer and remember its state. An additional call toflush with a new output buffer will conclude the operation.



flushAny
public int flushAny(byte[] output, int outStart, int outEnd) throws ConversionBufferFullException(Code)
Writes any remaining output to the output buffer and resets the converter to its initial state. May only be called when substitution mode is turned on, and never complains about malformed input (always substitutes).
Parameters:
  output - byte array to receive flushed output.
Parameters:
  outStart - start writing to output array at this offset.
Parameters:
  outEnd - stop writing to output array at this offset (exclusive). number of bytes writter into output.
exception:
  ConversionBufferFullException - if output array is filled before all the output can be flushed. flush will write what it canto the output buffer and remember its state. An additional call toflush with a new output buffer will conclude the operation.



getBadInputLength
public int getBadInputLength()(Code)
Returns the length, in chars, of the input which caused a MalformedInputException. Always refers to the last MalformedInputException thrown by the converter. If none have ever been thrown, returns 0.



getCharacterEncoding
abstract public String getCharacterEncoding()(Code)
Returns the character set id for the conversion.



getConverter
public static CharToByteConverter getConverter(String encoding) throws UnsupportedEncodingException(Code)
Returns appropriate CharToByteConverter subclass instance.
Parameters:
  string - represets encoding



getDefault
public static CharToByteConverter getDefault()(Code)
Create an instance of the default CharToByteConverter subclass.



getMaxBytesPerChar
abstract public int getMaxBytesPerChar()(Code)
Returns the maximum number of bytes needed to convert a char. Useful for calculating the maximum output buffer size needed for a particular input buffer.



nextByteIndex
public int nextByteIndex()(Code)
Returns the index of the byte just past the last byte written by the previous call to convert.



nextCharIndex
public int nextCharIndex()(Code)
Returns the index of the character just past the last character successfully converted by the previous call to convert.



reset
abstract public void reset()(Code)
Resets converter to its initial state.



setSubstitutionBytes
public void setSubstitutionBytes(byte[] newSubBytes) throws IllegalArgumentException(Code)
Sets the substitution bytes to use when the converter is in substitution mode. The given bytes should represent a valid character in the target character encoding and must not be longer than the value returned by getMaxBytesPerChar for this converter.
Parameters:
  newSubBytes - the substitution bytes
exception:
  IllegalArgumentException - if given byte array is longer thanthe value returned by the method getMaxBytesPerChar.
See Also:   CharToByteConverter.setSubstitutionMode
See Also:   CharToByteConverter.getMaxBytesPerChar



setSubstitutionMode
public void setSubstitutionMode(boolean doSub)(Code)
Sets converter into substitution mode. In substitution mode, the converter will replace untranslatable characters in the source encoding with the substitution character set by setSubstitutionBytes. When not in substitution mode, the converter will throw an UnknownCharacterException when it encounters untranslatable input.
Parameters:
  doSub - if true, enable substitution mode.
See Also:   CharToByteConverter.setSubstitutionBytes



toString
public String toString()(Code)
Returns a string representation of the class.



Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.