Java Doc for CharsetDetector.java in  » Internationalization-Localization » icu4j » com » ibm » icu » text » 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 » Internationalization Localization » icu4j » com.ibm.icu.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.text.CharsetDetector

CharsetDetector
public class CharsetDetector (Code)
CharsetDetector provides a facility for detecting the charset or encoding of character data in an unknown format. The input data can either be from an input stream or an array of bytes. The result of the detection operation is a list of possibly matching charsets, or, for simple use, you can just ask for a Java Reader that will will work over the input data.

Character set detection is at best an imprecise operation. The detection process will attempt to identify the charset that best matches the characteristics of the byte data, but the process is partly statistical in nature, and the results can not be guaranteed to always be correct.

For best accuracy in charset detection, the input data should be primarily in a single language, and a minimum of a few hundred bytes worth of plain text in the language are needed. The detection process will attempt to ignore html or xml style markup that could otherwise obscure the content.



Field Summary
 shortfByteStats
    
 booleanfC1Bytes
    
 StringfDeclaredEncoding
    
 byte[]fInputBytes
    
 intfInputLen
    
 InputStreamfInputStream
    
 byte[]fRawInput
    
 intfRawLength
    
 booleanfStripTags
    

Constructor Summary
public  CharsetDetector()
    

Method Summary
public  CharsetMatchdetect()
     Return the charset that best matches the supplied input data.
public  CharsetMatch[]detectAll()
     Return an array of all charsets that appear to be plausible matches with the input data.
public  booleanenableInputFilter(boolean filter)
     Enable filtering of input text.
public static  String[]getAllDetectableCharsets()
     Get the names of all char sets that can be recognized by the char set detector.
public  ReadergetReader(InputStream in, String declaredEncoding)
     Autodetect the charset of an inputStream, and return a Java Reader to access the converted input data.

This is a convenience method that is equivalent to this.setDeclaredEncoding(declaredEncoding).setText(in).detect().getReader();

For the input stream that supplies the character data, markSupported() must be true; the charset detection will read a small amount of data, then return the stream to its original position via the InputStream.reset() operation.

public  StringgetString(byte[] in, String declaredEncoding)
     Autodetect the charset of an inputStream, and return a String containing the converted input data.
public  booleaninputFilterEnabled()
     Test whether or not input filtering is enabled.
public  CharsetDetectorsetDeclaredEncoding(String encoding)
     Set the declared encoding for charset detection. The declared encoding of an input text is an encoding obtained from an http header or xml declaration or similar source that can be provided as additional information to the charset detector.
public  CharsetDetectorsetText(byte[] in)
     Set the input text (byte) data whose charset is to be detected.
public  CharsetDetectorsetText(InputStream in)
     Set the input text (byte) data whose charset is to be detected.

The input stream that supplies the character data must have markSupported() == true; the charset detection process will read a small amount of data, then return the stream to its original position via the InputStream.reset() operation.


Field Detail
fByteStats
short fByteStats(Code)



fC1Bytes
boolean fC1Bytes(Code)



fDeclaredEncoding
String fDeclaredEncoding(Code)



fInputBytes
byte[] fInputBytes(Code)
The following items are accessed by individual CharsetRecongizers during the recognition process



fInputLen
int fInputLen(Code)



fInputStream
InputStream fInputStream(Code)



fRawInput
byte[] fRawInput(Code)



fRawLength
int fRawLength(Code)



fStripTags
boolean fStripTags(Code)




Constructor Detail
CharsetDetector
public CharsetDetector()(Code)
Constructor




Method Detail
detect
public CharsetMatch detect()(Code)
Return the charset that best matches the supplied input data. Note though, that because the detection only looks at the start of the input data, there is a possibility that the returned charset will fail to handle the full set of input data.

Raise an exception if

  • no charset appears to match the data.
  • no input text has been provided
a CharsetMatch object representing the best matching charset, ornull if there are no matches.



detectAll
public CharsetMatch[] detectAll()(Code)
Return an array of all charsets that appear to be plausible matches with the input data. The array is ordered with the best quality match first.

Raise an exception if

  • no charsets appear to match the input data.
  • no input text has been provided
An array of CharsetMatch objects representing possibly matching charsets.



enableInputFilter
public boolean enableInputFilter(boolean filter)(Code)
Enable filtering of input text. If filtering is enabled, text within angle brackets ("<" and ">") will be removed before detection.
Parameters:
  filter - true to enable input text filtering. The previous setting.



getAllDetectableCharsets
public static String[] getAllDetectableCharsets()(Code)
Get the names of all char sets that can be recognized by the char set detector. an array of the names of all charsets that can be recognizedby the charset detector.



getReader
public Reader getReader(InputStream in, String declaredEncoding)(Code)
Autodetect the charset of an inputStream, and return a Java Reader to access the converted input data.

This is a convenience method that is equivalent to this.setDeclaredEncoding(declaredEncoding).setText(in).detect().getReader();

For the input stream that supplies the character data, markSupported() must be true; the charset detection will read a small amount of data, then return the stream to its original position via the InputStream.reset() operation. The exact amount that will be read depends on the characteristics of the data itself.

Raise an exception if no charsets appear to match the input data.
Parameters:
  in - The source of the byte data in the unknown charset.
Parameters:
  declaredEncoding - A declared encoding for the data, if available,or null or an empty string if none is available.




getString
public String getString(byte[] in, String declaredEncoding)(Code)
Autodetect the charset of an inputStream, and return a String containing the converted input data.

This is a convenience method that is equivalent to this.setDeclaredEncoding(declaredEncoding).setText(in).detect().getString();

Raise an exception if no charsets appear to match the input data.
Parameters:
  in - The source of the byte data in the unknown charset.
Parameters:
  declaredEncoding - A declared encoding for the data, if available,or null or an empty string if none is available.




inputFilterEnabled
public boolean inputFilterEnabled()(Code)
Test whether or not input filtering is enabled. true if input text will be filtered.
See Also:   CharsetDetector.enableInputFilter



setDeclaredEncoding
public CharsetDetector setDeclaredEncoding(String encoding)(Code)
Set the declared encoding for charset detection. The declared encoding of an input text is an encoding obtained from an http header or xml declaration or similar source that can be provided as additional information to the charset detector. A match between a declared encoding and a possible detected encoding will raise the quality of that detected encoding by a small delta, and will also appear as a "reason" for the match.

A declared encoding that is incompatible with the input data being analyzed will not be added to the list of possible encodings.
Parameters:
  encoding - The declared encoding




setText
public CharsetDetector setText(byte[] in)(Code)
Set the input text (byte) data whose charset is to be detected.
Parameters:
  in - the input text of unknown encoding This CharsetDetector



setText
public CharsetDetector setText(InputStream in) throws IOException(Code)
Set the input text (byte) data whose charset is to be detected.

The input stream that supplies the character data must have markSupported() == true; the charset detection process will read a small amount of data, then return the stream to its original position via the InputStream.reset() operation. The exact amount that will be read depends on the characteristics of the data itself.
Parameters:
  in - the input text of unknown encoding This CharsetDetector




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(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.