Source Code Cross Referenced for U8Vector.java in  » Scripting » Kawa » gnu » lists » 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 » Scripting » Kawa » gnu.lists 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2001, 2002, 2003  Per M.A. Bothner and Brainfood Inc.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.lists;
005:
006:        import java.io.*;
007:
008:        /** Simple adjustable-length vector of unsigned 8-bit integers (bytes). */
009:
010:        public class U8Vector extends SimpleVector implements  Externalizable
011:        /* #ifdef JAVA2 */
012:        , Comparable
013:        /* #endif */
014:        {
015:            byte[] data;
016:
017:            public U8Vector() {
018:                data = S8Vector.empty;
019:            }
020:
021:            public U8Vector(int size, byte value) {
022:                byte[] array = new byte[size];
023:                data = array;
024:                this .size = size;
025:                while (--size >= 0)
026:                    array[size] = value;
027:            }
028:
029:            public U8Vector(int size) {
030:                this .data = new byte[size];
031:                this .size = size;
032:            }
033:
034:            public U8Vector(byte[] data) {
035:                this .data = data;
036:                size = data.length;
037:            }
038:
039:            public U8Vector(Sequence seq) {
040:                data = new byte[seq.size()];
041:                addAll(seq);
042:            }
043:
044:            /** Get the allocated length of the data buffer. */
045:            public int getBufferLength() {
046:                return data.length;
047:            }
048:
049:            public void setBufferLength(int length) {
050:                int oldLength = data.length;
051:                if (oldLength != length) {
052:                    byte[] tmp = new byte[length];
053:                    System.arraycopy(data, 0, tmp, 0,
054:                            oldLength < length ? oldLength : length);
055:                    data = tmp;
056:                }
057:            }
058:
059:            protected Object getBuffer() {
060:                return data;
061:            }
062:
063:            public final byte byteAt(int index) {
064:                if (index > size)
065:                    throw new IndexOutOfBoundsException();
066:                return data[index];
067:            }
068:
069:            public final byte byteAtBuffer(int index) {
070:                return data[index];
071:            }
072:
073:            public final int intAtBuffer(int index) {
074:                return data[index] & 0xff;
075:            }
076:
077:            public final Object get(int index) {
078:                if (index > size)
079:                    throw new IndexOutOfBoundsException();
080:                return Convert.toObjectUnsigned(data[index]);
081:            }
082:
083:            public final Object getBuffer(int index) {
084:                return Convert.toObjectUnsigned(data[index]);
085:            }
086:
087:            public Object setBuffer(int index, Object value) {
088:                byte old = data[index];
089:                data[index] = Convert.toByteUnsigned(value);
090:                return Convert.toObjectUnsigned(old);
091:            }
092:
093:            public final void setByteAt(int index, byte value) {
094:                if (index > size)
095:                    throw new IndexOutOfBoundsException();
096:                data[index] = value;
097:            }
098:
099:            public final void setByteAtBuffer(int index, byte value) {
100:                data[index] = value;
101:            }
102:
103:            protected void clearBuffer(int start, int count) {
104:                while (--count >= 0)
105:                    data[start++] = 0;
106:            }
107:
108:            public int getElementKind() {
109:                return INT_U8_VALUE;
110:            }
111:
112:            public String getTag() {
113:                return "u8";
114:            }
115:
116:            public boolean consumeNext(int ipos, Consumer out) {
117:                int index = ipos >>> 1;
118:                if (index >= size)
119:                    return false;
120:                out.writeInt(data[index] & 0xff);
121:                return true;
122:            }
123:
124:            public void consumePosRange(int iposStart, int iposEnd, Consumer out) {
125:                if (out.ignoring())
126:                    return;
127:                int i = iposStart >>> 1;
128:                int end = iposEnd >>> 1;
129:                if (end > size)
130:                    end = size;
131:                for (; i < end; i++)
132:                    out.writeInt(data[i] & 0xff);
133:            }
134:
135:            public int compareTo(Object obj) {
136:                return compareToInt(this , (U8Vector) obj);
137:            }
138:
139:            /**
140:             * @serialData Write 'size' (using writeInt),
141:             *   followed by 'size' elements in order (using writeByte).
142:             */
143:            public void writeExternal(ObjectOutput out) throws IOException {
144:                int size = this .size;
145:                out.writeInt(size);
146:                for (int i = 0; i < size; i++)
147:                    out.writeByte(data[i]);
148:            }
149:
150:            public void readExternal(ObjectInput in) throws IOException,
151:                    ClassNotFoundException {
152:                int size = in.readInt();
153:                byte[] data = new byte[size];
154:                for (int i = 0; i < size; i++)
155:                    data[i] = in.readByte();
156:                this.data = data;
157:                this.size = size;
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.