Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Apache Ant Source Code Files
Apache Ant Source Code Files are inside the Apache Ant source package file
like apache-ant-1.10.10-src.zip.
Unzip the source package file and go to the "src/main" sub-directory,
you will see source code files.
Here is the list of Java source code files of the Apache Ant 1.10.10 in \Users\fyicenter\apache-ant-1.10.10\src\main:
✍: FYIcenter.com
⏎ org/apache/tools/zip/ZipLong.java
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.zip;
import static org.apache.tools.zip.ZipConstants.BYTE_MASK;
import static org.apache.tools.zip.ZipConstants.WORD;
/**
* Utility class that represents a four byte integer with conversion
* rules for the big endian byte order of ZIP files.
*
*/
public final class ZipLong implements Cloneable {
//private static final int BYTE_BIT_SIZE = 8;
private static final int BYTE_1 = 1;
private static final int BYTE_1_MASK = 0xFF00;
private static final int BYTE_1_SHIFT = 8;
private static final int BYTE_2 = 2;
private static final int BYTE_2_MASK = 0xFF0000;
private static final int BYTE_2_SHIFT = 16;
private static final int BYTE_3 = 3;
private static final long BYTE_3_MASK = 0xFF000000L;
private static final int BYTE_3_SHIFT = 24;
private final long value;
/** Central File Header Signature */
public static final ZipLong CFH_SIG = new ZipLong(0X02014B50L);
/** Local File Header Signature */
public static final ZipLong LFH_SIG = new ZipLong(0X04034B50L);
/**
* Data Descriptor signature
*/
public static final ZipLong DD_SIG = new ZipLong(0X08074B50L);
/**
* Value stored in size and similar fields if ZIP64 extensions are
* used.
*/
static final ZipLong ZIP64_MAGIC = new ZipLong(ZipConstants.ZIP64_MAGIC);
/**
* Create instance from a number.
* @param value the long to store as a ZipLong
* @since 1.1
*/
public ZipLong(long value) {
this.value = value;
}
/**
* Create instance from bytes.
* @param bytes the bytes to store as a ZipLong
* @since 1.1
*/
public ZipLong(byte[] bytes) {
this(bytes, 0);
}
/**
* Create instance from the four bytes starting at offset.
* @param bytes the bytes to store as a ZipLong
* @param offset the offset to start
* @since 1.1
*/
public ZipLong(byte[] bytes, int offset) {
value = ZipLong.getValue(bytes, offset);
}
/**
* Get value as four bytes in big endian byte order.
* @since 1.1
* @return value as four bytes in big endian order
*/
public byte[] getBytes() {
return ZipLong.getBytes(value);
}
/**
* Get value as Java long.
* @since 1.1
* @return value as a long
*/
public long getValue() {
return value;
}
/**
* Get value as four bytes in big endian byte order.
* @param value the value to convert
* @return value as four bytes in big endian byte order
*/
public static byte[] getBytes(long value) {
byte[] result = new byte[WORD];
putLong(value, result, 0);
return result;
}
/**
* put the value as four bytes in big endian byte order.
* @param value the Java long to convert to bytes
* @param buf the output buffer
* @param offset
* The offset within the output buffer of the first byte to be written.
* must be non-negative and no larger than <code>buf.length-4</code>
*/
public static void putLong(long value, byte[] buf, int offset) {
buf[offset++] = (byte) ((value & BYTE_MASK));
buf[offset++] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT);
buf[offset++] = (byte) ((value & BYTE_2_MASK) >> BYTE_2_SHIFT);
buf[offset] = (byte) ((value & BYTE_3_MASK) >> BYTE_3_SHIFT);
}
public void putLong(byte[] buf, int offset) {
putLong(value, buf, offset);
}
/**
* Helper method to get the value as a Java long from four bytes starting at given array offset
* @param bytes the array of bytes
* @param offset the offset to start
* @return the corresponding Java long value
*/
public static long getValue(byte[] bytes, int offset) {
long value = (bytes[offset + BYTE_3] << BYTE_3_SHIFT) & BYTE_3_MASK;
value += (bytes[offset + BYTE_2] << BYTE_2_SHIFT) & BYTE_2_MASK;
value += (bytes[offset + BYTE_1] << BYTE_1_SHIFT) & BYTE_1_MASK;
value += (bytes[offset] & BYTE_MASK);
return value;
}
/**
* Helper method to get the value as a Java long from a four-byte array
* @param bytes the array of bytes
* @return the corresponding Java long value
*/
public static long getValue(byte[] bytes) {
return getValue(bytes, 0);
}
/**
* Override to make two instances with same value equal.
* @param o an object to compare
* @return true if the objects are equal
* @since 1.1
*/
@Override
public boolean equals(Object o) {
return o instanceof ZipLong && value == ((ZipLong) o).getValue();
}
/**
* Override to make two instances with same value equal.
* @return the value stored in the ZipLong
* @since 1.1
*/
@Override
public int hashCode() {
return (int) value;
}
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException cnfe) {
// impossible
throw new RuntimeException(cnfe); //NOSONAR
}
}
@Override
public String toString() {
return "ZipLong value: " + value;
}
}
⏎ org/apache/tools/zip/ZipLong.java
Or download all of them as a single archive file:
File name: apache-ant-1.10.10-fyi.zip File size: 2392938 bytes Release date: 2021-04-17 Download
⇐ Download Apache Ant Source Package
2021-07-10, ≈401🔥, 0💬
Popular Posts:
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
Apache Avalon began in 1999 as the Java Apache Server Framework and in late 2002 separated from the ...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...