Source Code Cross Referenced for ArUtils.java in  » Swing-Library » jEdit » de » masters_of_disaster » ant » tasks » ar » 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 » Swing Library » jEdit » de.masters_of_disaster.ant.tasks.ar 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.masters_of_disaster.ant.tasks.ar;
002:
003:        /**
004:         * This class provides static utility methods to work with byte streams.
005:         */
006:        public class ArUtils {
007:            /**
008:             * Parse an octal string from a header buffer. This is used for the
009:             * file permission mode value.
010:             *
011:             * @param header The header buffer from which to parse.
012:             * @param offset The offset into the buffer from which to parse.
013:             * @param length The number of header bytes to parse.
014:             * @return The long value of the octal string.
015:             */
016:            public static long parseOctal(byte[] header, int offset, int length) {
017:                long result = 0;
018:                int end = offset + length;
019:
020:                for (int i = offset; i < end; i++) {
021:                    if (header[i] == (byte) ' ') {
022:                        break;
023:                    }
024:                    result = (result << 3) + (header[i] - '0');
025:                }
026:
027:                return result;
028:            }
029:
030:            /**
031:             * Parse an entry name from a header buffer.
032:             *
033:             * @param header The header buffer from which to parse.
034:             * @param offset The offset into the buffer from which to parse.
035:             * @param length The number of header bytes to parse.
036:             * @return The header's entry name.
037:             */
038:            public static StringBuffer parseName(byte[] header, int offset,
039:                    int length) {
040:                StringBuffer result = new StringBuffer(length);
041:                int end = offset + length;
042:
043:                for (int i = offset; i < end; i++) {
044:                    if (header[i] == ' ') {
045:                        break;
046:                    }
047:
048:                    result.append((char) header[i]);
049:                }
050:
051:                return result;
052:            }
053:
054:            /**
055:             * Write a name into a byte array.
056:             *
057:             * @param name The name to write.
058:             * @param buf The byte array into which to write.
059:             * @param offset The offset into the buffer from which to write.
060:             * @param length The number of header bytes to write.
061:             * @return The number of bytes written to the buffer.
062:             */
063:            public static int getNameBytes(StringBuffer name, byte[] buf,
064:                    int offset, int length) {
065:                int i;
066:                int c = name.length();
067:
068:                for (i = 0; i < length && i < c; i++) {
069:                    buf[offset + i] = (byte) name.charAt(i);
070:                }
071:
072:                while (i < length) {
073:                    buf[offset + i] = (byte) ' ';
074:                    i++;
075:                }
076:
077:                return offset + length;
078:            }
079:
080:            /**
081:             * Write a long value into a byte array.
082:             *
083:             * @param value The value to write.
084:             * @param buf The byte array into which to write.
085:             * @param offset The offset into the buffer from which to write.
086:             * @param length The number of header bytes to write.
087:             * @return The number of bytes written to the buffer.
088:             */
089:            public static int getLongBytes(long value, byte[] buf, int offset,
090:                    int length) {
091:                int i;
092:                String tmp = Long.toString(value);
093:                int c = tmp.length();
094:
095:                for (i = 0; i < length && i < c; i++) {
096:                    buf[offset + i] = (byte) tmp.charAt(i);
097:                }
098:
099:                while (i < length) {
100:                    buf[offset + i] = (byte) ' ';
101:                    i++;
102:                }
103:
104:                return offset + length;
105:            }
106:
107:            /**
108:             * Write an int value into a byte array.
109:             *
110:             * @param value The value to write.
111:             * @param buf The byte array into which to write.
112:             * @param offset The offset into the buffer from which to write.
113:             * @param length The number of header bytes to write.
114:             * @return The number of bytes written to the buffer.
115:             */
116:            public static int getIntegerBytes(int value, byte[] buf,
117:                    int offset, int length) {
118:                int i;
119:                String tmp = Integer.toString(value);
120:                int c = tmp.length();
121:
122:                for (i = 0; i < length && i < c; i++) {
123:                    buf[offset + i] = (byte) tmp.charAt(i);
124:                }
125:
126:                while (i < length) {
127:                    buf[offset + i] = (byte) ' ';
128:                    i++;
129:                }
130:
131:                return offset + length;
132:            }
133:
134:            /**
135:             * Write an octal value into a byte array.
136:             *
137:             * @param value The value to write.
138:             * @param buf The byte array into which to write.
139:             * @param offset The offset into the buffer from which to write.
140:             * @param length The number of header bytes to write.
141:             * @return The number of bytes written to the buffer.
142:             */
143:            public static int getOctalBytes(long value, byte[] buf, int offset,
144:                    int length) {
145:                int i;
146:                String tmp = Long.toOctalString(value);
147:                int c = tmp.length();
148:
149:                for (i = 0; i < length && i < c; i++) {
150:                    buf[offset + i] = (byte) tmp.charAt(i);
151:                }
152:
153:                while (i < length) {
154:                    buf[offset + i] = (byte) ' ';
155:                    i++;
156:                }
157:
158:                return offset + length;
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.