Java Doc for ByteChunk.java in  » Portal » stringbeans-3.5 » com » nabhinc » util » md » 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 » Portal » stringbeans 3.5 » com.nabhinc.util.md 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.nabhinc.util.md.ByteChunk

ByteChunk
final public class ByteChunk implements Cloneable,Serializable(Code)
This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. The buffer can be modified and used for both input and output. There are 2 modes: The chunk can be associated with a sink - ByteInputChannel or ByteOutputChannel, which will be used when the buffer is empty ( on input ) or filled ( on output ). For output, it can also grow. This operating mode is selected by calling setLimit() or allocate(initial, limit) with limit != -1. Various search and append method are defined - similar with String and StringBuffer, but operating on bytes. This is important because it allows processing the http headers directly on the received bytes, without converting to chars and Strings until the strings are needed. In addition, the charset is determined later, from headers or user code.
author:
   dac@sun.com
author:
   James Todd [gonzo@sun.com]
author:
   Costin Manolache
author:
   Remy Maucherat

Inner Class :public static interface ByteInputChannel
Inner Class :public static interface ByteOutputChannel

Field Summary
final public static  StringDEFAULT_CHARACTER_ENCODING
     Default encoding used to convert to strings.

Constructor Summary
public  ByteChunk()
     Creates a new, uninitialized ByteChunk object.
public  ByteChunk(int initial)
    

Method Summary
public  voidallocate(int initial, int limit)
    
public  voidappend(char c)
     Append a char, by casting it to byte.
public  voidappend(byte b)
    
public  voidappend(ByteChunk src)
    
public  voidappend(byte src, int off, int len)
    
final public static  byte[]convertToBytes(String value)
     Convert specified String to a byte array.
public  booleanequals(String s)
     Compares the message bytes to the specified String object.
public  booleanequals(ByteChunk bb)
    
public  booleanequals(byte b2, int off2, int len2)
    
public  booleanequals(CharChunk cc)
    
public  booleanequals(char c2, int off2, int len2)
    
public  booleanequalsIgnoreCase(String s)
     Compares the message bytes to the specified String object.
public static  intfindChar(byte buf, int start, int end, char c)
     Find a character, no side effects.
public static  intfindChars(byte buf, int start, int end, byte c)
     Find a character, no side effects.
public static  intfindNotChars(byte buf, int start, int end, byte c)
    
public  voidflushBuffer()
     Send the buffer to the sink.
public  byte[]getBuffer()
     Returns the message bytes.
public  byte[]getBytes()
     Returns the message bytes.
public  ByteChunkgetClone()
    
public  StringgetEncoding()
    
public  intgetEnd()
    
public  intgetInt()
    
public  intgetLength()
     Returns the length of the bytes.
public  intgetLimit()
    
public  longgetLong()
    
public  intgetOffset()
    
public  intgetStart()
     Returns the start offset of the bytes.
public  inthash()
    
public  inthashIgnoreCase()
    
public  intindexOf(String src, int srcOff, int srcLen, int myOff)
    
public  intindexOf(char c, int starting)
     Returns true if the message bytes starts with the specified string.
public static  intindexOf(byte bytes, int off, int end, char qq)
    
public  booleanisNull()
    
public  voidrecycle()
     Resets the message buff to an uninitialized state.
public  voidreset()
    
public  voidsetByteInputChannel(ByteInputChannel in)
     When the buffer is empty, read the data from the input channel.
public  voidsetByteOutputChannel(ByteOutputChannel out)
     When the buffer is full, write the data to the output channel.
public  voidsetBytes(byte[] b, int off, int len)
     Sets the message bytes to the specified subarray of bytes.
public  voidsetEncoding(String enc)
    
public  voidsetEnd(int i)
    
public  voidsetLimit(int limit)
     Maximum amount of data in this buffer.
public  voidsetOffset(int off)
    
public  voidsetOptimizedWrite(boolean optimizedWrite)
    
public  booleanstartsWith(String s)
     Returns true if the message bytes starts with the specified string.
public  booleanstartsWith(byte[] b2)
    
public  booleanstartsWithIgnoreCase(String s, int pos)
     Returns true if the message bytes starts with the specified string.
public  intsubstract()
    
public  intsubstract(ByteChunk src)
    
public  intsubstract(byte src, int off, int len)
    
public  StringtoString()
    
public  StringtoStringInternal()
    

Field Detail
DEFAULT_CHARACTER_ENCODING
final public static String DEFAULT_CHARACTER_ENCODING(Code)
Default encoding used to convert to strings. It should be UTF8, as most standards seem to converge, but the servlet API requires 8859_1, and this object is used mostly for servlets.




Constructor Detail
ByteChunk
public ByteChunk()(Code)
Creates a new, uninitialized ByteChunk object.



ByteChunk
public ByteChunk(int initial)(Code)




Method Detail
allocate
public void allocate(int initial, int limit)(Code)



append
public void append(char c) throws IOException(Code)
Append a char, by casting it to byte. This IS NOT intended for unicode.
Parameters:
  c -
throws:
  IOException -



append
public void append(byte b) throws IOException(Code)



append
public void append(ByteChunk src) throws IOException(Code)



append
public void append(byte src, int off, int len) throws IOException(Code)
Add data to the buffer



convertToBytes
final public static byte[] convertToBytes(String value)(Code)
Convert specified String to a byte array. This ONLY WORKS for ascii, UTF chars will be truncated.
Parameters:
  value - to convert to byte array the byte array value



equals
public boolean equals(String s)(Code)
Compares the message bytes to the specified String object.
Parameters:
  s - the String to compare true if the comparison succeeded, false otherwise



equals
public boolean equals(ByteChunk bb)(Code)



equals
public boolean equals(byte b2, int off2, int len2)(Code)



equals
public boolean equals(CharChunk cc)(Code)



equals
public boolean equals(char c2, int off2, int len2)(Code)



equalsIgnoreCase
public boolean equalsIgnoreCase(String s)(Code)
Compares the message bytes to the specified String object.
Parameters:
  s - the String to compare true if the comparison succeeded, false otherwise



findChar
public static int findChar(byte buf, int start, int end, char c)(Code)
Find a character, no side effects. index of char if found, -1 if not



findChars
public static int findChars(byte buf, int start, int end, byte c)(Code)
Find a character, no side effects. index of char if found, -1 if not



findNotChars
public static int findNotChars(byte buf, int start, int end, byte c)(Code)
Find the first character != c index of char if found, -1 if not



flushBuffer
public void flushBuffer() throws IOException(Code)
Send the buffer to the sink. Called by append() when the limit is reached. You can also call it explicitely to force the data to be written.
throws:
  IOException -



getBuffer
public byte[] getBuffer()(Code)
Returns the message bytes.



getBytes
public byte[] getBytes()(Code)
Returns the message bytes.



getClone
public ByteChunk getClone()(Code)



getEncoding
public String getEncoding()(Code)



getEnd
public int getEnd()(Code)



getInt
public int getInt()(Code)



getLength
public int getLength()(Code)
Returns the length of the bytes. XXX need to clean this up



getLimit
public int getLimit()(Code)



getLong
public long getLong()(Code)



getOffset
public int getOffset()(Code)



getStart
public int getStart()(Code)
Returns the start offset of the bytes. For output this is the end of the buffer.



hash
public int hash()(Code)



hashIgnoreCase
public int hashIgnoreCase()(Code)



indexOf
public int indexOf(String src, int srcOff, int srcLen, int myOff)(Code)



indexOf
public int indexOf(char c, int starting)(Code)
Returns true if the message bytes starts with the specified string.
Parameters:
  c - the character
Parameters:
  starting - The start position



indexOf
public static int indexOf(byte bytes, int off, int end, char qq)(Code)



isNull
public boolean isNull()(Code)



recycle
public void recycle()(Code)
Resets the message buff to an uninitialized state.



reset
public void reset()(Code)



setByteInputChannel
public void setByteInputChannel(ByteInputChannel in)(Code)
When the buffer is empty, read the data from the input channel.



setByteOutputChannel
public void setByteOutputChannel(ByteOutputChannel out)(Code)
When the buffer is full, write the data to the output channel. Also used when large amount of data is appended. If not set, the buffer will grow to the limit.



setBytes
public void setBytes(byte[] b, int off, int len)(Code)
Sets the message bytes to the specified subarray of bytes.
Parameters:
  b - the ascii bytes
Parameters:
  off - the start offset of the bytes
Parameters:
  len - the length of the bytes



setEncoding
public void setEncoding(String enc)(Code)



setEnd
public void setEnd(int i)(Code)



setLimit
public void setLimit(int limit)(Code)
Maximum amount of data in this buffer. If -1 or not set, the buffer will grow undefinitely. Can be smaller than the current buffer size ( which will not shrink ). When the limit is reached, the buffer will be flushed ( if out is set ) or throw exception.



setOffset
public void setOffset(int off)(Code)



setOptimizedWrite
public void setOptimizedWrite(boolean optimizedWrite)(Code)



startsWith
public boolean startsWith(String s)(Code)
Returns true if the message bytes starts with the specified string.
Parameters:
  s - the string



startsWith
public boolean startsWith(byte[] b2)(Code)



startsWithIgnoreCase
public boolean startsWithIgnoreCase(String s, int pos)(Code)
Returns true if the message bytes starts with the specified string.
Parameters:
  s - the string
Parameters:
  pos - The position



substract
public int substract() throws IOException(Code)



substract
public int substract(ByteChunk src) throws IOException(Code)



substract
public int substract(byte src, int off, int len) throws IOException(Code)



toString
public String toString()(Code)



toStringInternal
public String toStringInternal()(Code)



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.